[英]Paypal PDT curl request error
Below is the code for my paypal receive file for using paypal PDT 以下是我使用贝宝PDT的贝宝接收文件的代码
<?php
$tx = $_GET['tx'];
$ID = $_GET['cm'];
$amount = $_GET['amt'];
$currency = $_GET['cc'];
$auth = "#####";
// Init cURL
$ch = curl_init();
// Set request options
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$fields = array(
'cmd' => '_notify-synch',
'tx' => $tx,
'at' => $auth
);
curl_setopt($ch, CURLOPT_CAINFO, 'cacert.pem');
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_HEADER, FALSE);
// Execute request and get response and status code
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close connection
curl_close($ch);
print_r($response);
if($status == 200 AND strpos($response, 'SUCCESS') === 0)
{
//wp_redirect(home_url('/account'));
exit;
} else {
// wp_redirect(home_url());
exit;
}
?>
I have tried many times now..but it is still throwing error...i have tested server for curl and its working with other file...can anyone has any idea why this is not working 我已经尝试了很多次..但是它仍然抛出错误...我已经测试了服务器的curl及其与其他文件的关系...任何人都可以知道为什么这不起作用
Whenever i try to print_r th response ..its empty and show nothing 每当我尝试print_r th响应..它为空并且什么也不显示时
To resume the conversation : 要恢复对话:
$tx = $_GET['tx'];
$ID = $_GET['cm'];
$amount = $_GET['amt'];
$currency = $_GET['cc'];
$auth = "#####";
// Init cURL
$ch = curl_init();
// Set request options
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$fields = array(
'cmd' => '_notify-synch',
'tx' => $tx,
'at' => $auth
);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, 6); //force TLS 1.2
curl_setopt($ch,CURLOPT_CAINFO, realpath('cacert.pem'));
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_HEADER, FALSE);
// Execute request and get response and status code
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close connection
curl_close($ch);
print_r($response);
if($status == 200 AND strpos($response, 'SUCCESS') === 0)
{
//wp_redirect(home_url('/account'));
exit;
} else {
// wp_redirect(home_url());
exit;
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.