使用PHP验证paypal通知数据时遇到问题

时间:2012-01-12 22:51:22

标签: php paypal

我正在尝试检查paypal在支付交易后发送给我的notify_url的数据(在这种情况下使用沙箱)。

我尝试过使用fsockopen的paypal示例代码,但我无法让它正常工作。我也通过手动提供证书来尝试使用cURL,但它也不是很好。

然而,经过一些改变,我设法找到了解决方案:

<?php
$_POST = array('mc_gross' => '9.90',
'protection_eligibility' => 'Eligible',
'address_status' => 'confirmed',
'payer_id' => '5PK5H93BE5RAQ',
'tax' => '0.00',
'address_street' => '1 Main St',
'payment_date' => '12:13:29 Jan 12, 2012 PST',
'payment_status' => 'Pending',
'charset' => 'windows-1252',
'address_zip' => '95131',
'first_name' => 'Test',
'address_country_code' => 'US',
'address_name' => 'Test User',
'notify_version' => '3.4',
'custom' => '523368657',
'payer_status' => 'verified',
'business' => 'seller_1326059109_biz@yahoo.fr',
'address_country' => 'United States',
'address_city' => 'San Jose',
'quantity' => '1',
'verify_sign' => 'AGilT0jx3itxd3XAujXRvUPipg93ATqSM88ML-PAwAoa7xGkRSWXhVR8',
'payer_email' => 'buyer_1326398444_per@yahoo.fr',
'txn_id' => '1C254380JG793833D',
'payment_type' => 'instant',
'last_name' => 'User',
'address_state' => 'CA',
'receiver_email' => 'seller_1326059109_biz@yahoo.fr',
'receiver_id' => 'FKBDH7FDLECEQ',
'pending_reason' => 'multi_currency',
'txn_type' => 'web_accept',
'item_name' => 'Compte premium winker',
'mc_currency' => 'EUR',
'item_number' => '',
'residence_country' => 'US',
'test_ipn' => '1',
'handling_amount' => '0.00',
'transaction_subject' => '523368657',
'payment_gross' => '',
'shipping' => '0.00',
'ipn_track_id' => '1v3OWX6MBMqE6Oe6-BSmCA');
$req = '?cmd=_notify-validate';
foreach ($_POST as $key => $value) {
  $value = urlencode(stripslashes($value));
  $req .= "&amp;$key=$value";
}

$url = 'https://sandbox.paypal.com/cgi-bin/webscr'.$req;
echo '<p><a href="'.$url.'" target="_blank">browse link</a></p>';

$content = file_get_contents($url);
var_dump($content);

我确实得到了一个结果,但它是“无效”,而如果我在浏览器上打开链接(具有完全相同的信息),则它是“已验证”!

有什么想法吗?

提前感谢您的回复

0 个答案:

没有答案