php - Trouble with HTTP POS REQUEST HASH KEY -
i'm trying connect payment gateway , have form below sent http post:
<form name="submit2gtpay_form" action="" target="_self" method="post"> <input type="hidden" name="gtpay_mert_id" value="17" /> <input type="hidden" name="gtpay_tranx_id" value="" /> <input type="hidden" name="gtpay_tranx_amt" value="5000" /> <input type="hidden" name="gtpay_tranx_curr" value="566" /> <input type="hidden" name="gtpay_cust_id" value="458742" /> <input type="hidden" name="gtpay_cust_name" value="test customer" /> <input type="hidden" name="gtpay_tranx_memo" value="mobow" /> <input type="hidden" name="gtpay_no_show_gtbank" value="yes" /> <input type="hidden" name="gtpay_echo_data" value="test" /> <input type="hidden" name="gtpay_gway_name" value="" /> <input type="hidden" name="gtpay_tranx_hash" value="" /> <input type="hidden" name="gtpay_tranx_noti_url" value="" /> <input type="submit" value="pay via gtpay" name="btnsubmit"/> <input type="hidden" name="gtpay_echo_data" value=""> </form>
i'm required perform sha512 hash of [gtpay_tranx_id + gtpay_tranx_amt +gtpay_tranx_noti_url + hashkey]
the transaction amount should in kobo , strings should concatenated hashkey before getting sha512 hash of entire string.
but value of gtpay_tranx_hash variable, how do becuase when echo it, missing value
please appreciated
<?php //the has key requested $key = hash('sha512','664879809+500000+myurl+thekeytheysupply'); //create array of data posted $post_data['gtpay_mert_id'] = 3649; $post_data['gtpay_tranx_id'] = 664879809; $post_data['gtpay_tranx_amt'] = 500000; $post_data['gtpay_tranx_curr'] = 566; $post_data['gtpay_cust_id'] = 458742; $post_data['gtpay_cust_name'] = 'test customer'; $post_data['gtpay_tranx_memo'] = 'mobow'; $post_data['gtpay_no_show_gtbank'] = 'yes'; $post_data['gtpay_echo_data'] ='test'; $post_data['gtpay_tranx_hash'] = $key; $post_data['gtpay_tranx_noti_url'] = 'mynotificationurl'; //traverse array , prepare data posting (key1=value1) foreach ( $post_data $key => $value) { $post_items[] = $key . '=' . $value; } //create final string posted using implode() $post_string = implode ('&', $post_items); //usrl $url = 'thebankurl'; $ch = curl_init(); //initialize curl handle // enable below 2 linesfor https sites curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_url, $url); //set url //curl_setopt($ch, curlopt_httpheader, $header); curl_setopt($ch, curlopt_returntransfer,1); //return variable //curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_post, 1); //set post method curl_setopt($ch, curlopt_postfields, $post_string); //set post variables curl_setopt($ch, curlopt_http_version, curl_http_version_1_1); $response = curl_exec($ch); //run whole process , return response curl_close($ch); //close curl handle
Comments
Post a Comment