我的网站上有捐赠页面。 在Gateway上注册的商家将通过HTTP Post发送到GTPay的交易请求到URL https://ibank.gtbank.com/GTPay/Tranx.aspx
当我提交请求时,我看到上面网址的这个页面显示在我的捐款页面中,而不是带我到URL 以下是我的代码:
$url = 'https://ibank.gtbank.com/GTPay/Tranx.aspx';
$fields = array(
'gtpay_mert_id' => urlencode($gtpay_mert_id),
'gtpay_tranx_id' => urlencode($gtpay_tranx_id),
'gtpay_tranx_amt' => urlencode($gtpay_tranx_amt),
'gtpay_tranx_curr' => urlencode($gtpay_tranx_curr),
'gtpay_cust_id' => urlencode($gtpay_cust_id),
'gtpay_tranx_noti_url' => urlencode($gtpay_tranx_noti_url),
'gtpay_hash' => urlencode($gtpay_hash)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$form_files=array();
$form_options=array( 'cookies' => array( 'auth' => $auth ) );
http_post_fields($url, $fields, $form_files, $form_options);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
答案 0 :(得分:0)
使用cURL发出的请求不会将您带到URL。它只会处理请求并将数据返回给您。
您需要使用带有字段的HTML表单提交请求。
这样的事情:
<form action=" https://ibank.gtbank.com/GTPay/Tranx.aspx" method="post">
<!-- Saved buttons use the "secure click" command -->
<input type="hidden" name="cmd" value="_s-xclick">
<!-- Saved buttons are identified by their button IDs -->
<input type="hidden" name="hosted_button_id" value="221">
<!-- Saved buttons display an appropriate button image. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>