尝试设置PayPal IPN以验证我网站上的付款,但我尝试过的每一个请求都会返回INVALID
。我无法弄清楚问题是什么以及它可能在哪里搞砸了。我在想这个问题可能是Joomla!添加page
,view
和task
变量,因此我尝试将其从$_POST
中移除,但请求返回INVALID
所有相同的内容。
以下是PayPal发送给我的所有$_POST
数据的列表,我将返回验证有效性:
Array
(
[mc_gross] => 3.40
[protection_eligibility] => Eligible
[address_status] => confirmed
[payer_id] => F57P3MMS6UKNC
[tax] => 0.00
[address_street] => 1275, Chemin du Tremblay
Suite 201
[payment_date] => 06:51:30 Jul 28, 2014 PDT
[payment_status] => Completed
[charset] => UTF-8
[address_zip] => j4n 0g2
[first_name] => Michael
[mc_fee] => 0.40
[address_country_code] => CA
[address_name] => Michael Bourdeau
[notify_version] => 3.8
[custom] =>
[payer_status] => verified
[business] => gdwppsend@outlook.com
[address_country] => Canada
[address_city] => Longueuil
[quantity] => 1
[payer_email] => gdwpppay@outlook.com
[verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31AOvJSJy.aGpnmllVEvU2.7EGndXL
[txn_id] => 5RW992040P712271B
[payment_type] => instant
[last_name] => Bourdeau
[address_state] => Quebec
[receiver_email] => gdwppsend@outlook.com
[payment_fee] =>
[receiver_id] => BKHMT27W3EMDE
[txn_type] => web_accept
[item_name] => Géant du web - Facture #3884
[mc_currency] => CAD
[item_number] => 3884
[residence_country] => CA
[test_ipn] => 1
[handling_amount] => 0.00
[transaction_subject] =>
[payment_gross] =>
[shipping] => 0.00
[merchant_return_link] => click here
[auth] => AGtLwVTUzpbI8nw16O3Cv11hNv6uRom2.oebD1GgLQuWzNp7OqVXz-nY-qzw2QunZsrVzDZqDuwxvYR0vEmvkQg
[view] => paypalipn
[task] => run
)
发送请求的PHP代码的副本:
$postdata = $_POST;
//Get config file
$cfgFile = GDWCOMP_ADMINROOT.'includes'.DS.'cpanel.config.gdw.php';
if ( file_exists($cfgFile) ) {
include($cfgFile);
} else {
$gdwconf = array();
}
//Live or sandbox PayPal
if ($gdwconf['ppsandbox'] == 1) {
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
} else {
$url = 'https://www.paypal.com/cgi-bin/webscr';
}
$postFields = 'cmd=_notify-validate';
if (count($postdata) > 0) {
foreach($postdata as $key => $val) {
$postFields .= '&'.$key.'='.urlencode(stripslashes($val));
}
}
//Validate info sent with paypal
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields
));
$result = curl_exec($ch);
$curlerror = curl_error($ch);
if ($curlerror) {
die('CURL-ERROR: '.$curlerror);
}
echo $result;
echo $postFields;
echo '<pre>'; print_r($_POST); echo '</pre>';
//Log results
$file = ($result) ? 'pp_results_veri.txt' : 'pp_results_unveri.txt';
if (count($postdata) > 0) {
$this->writeLog($file, ": (".$result.") : ".json_encode($postdata));
} else {
$this->writeLog($file, ": (".$result.") "); //Write to log.
}
exit;