以下是使用paypal PDT的PayPal接收文件的代码
<?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;
}
?>
我现在已经尝试了很多次..但它仍然在抛出错误...我有 测试服务器的卷曲和它与其他文件一起工作......任何人都可以 知道为什么这不起作用
每当我尝试print_r th响应..空并且什么也不显示
答案 0 :(得分:0)
要恢复对话:
$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;
}
?>