HTTP POS REQUEST HASH KEY出现问题

时间:2015-05-15 07:13:04

标签: php http hasp

我正在尝试连接到支付网关,我将此表格发送为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>

我需要执行[gtpay_tranx_id + gtpay_tranx_amt + gtpay_tranx_noti_url + hashkey]的sha512哈希

在获取整个字符串的sha512哈希之前,事务量应该是kobo并且所有字符串应该与hashkey连接在一起。

但是gtpay_tranx_hash的值是一个变量,我怎么做呢,因为当我回应它时,我得到了缺失值

请任何帮助将不胜感激

<?php 
  //the has key requested
 $key = hash('sha512','664879809+500000+myurl+thekeytheysupply');
  //create array of data to be 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 and prepare data for posting (key1=value1)
 foreach ( $post_data as $key => $value) {
    $post_items[] = $key . '=' . $value;
     }

   //create the final string to be 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 the url

    //curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //return as a variable

    //curl_setopt($ch, CURLOPT_HEADER, 0);

    curl_setopt($ch, CURLOPT_POST, 1); //set POST method

   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); //set the POST variables

    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

    $response = curl_exec($ch); //run the whole process and return the response

    curl_close($ch); //close the curl handle

0 个答案:

没有答案