【发布时间】:2014-11-05 09:16:30
【问题描述】:
我尝试使用 PayPal 的沙盒 IPN 模拟器发送一些测试付款,但 IPN 日志仍然显示 IPN 失败。我尝试进入Profile > Selling Tools > Language Encoding > Changed to UTF-8 仍然没有用。 IPN 日志说
[09/11/2014 10:02 PM] - FAIL: IPN Validation Failed.
IPN POST Vars from Paypal:
residence_country=US, invoice=abc1234, address_city=San Jose, first_name=John, payer_id=TESTBUYERID01, shipping=3.04, mc_fee=0.44, txn_id=222972945, receiver_email=seller@paypalsandbox.com, quantity=1, custom=xyz123, payment_date=04:59:06 11 Sep 2014 PDT, address_country_code=US, address_zip=95131, tax=2.02, item_name=something, address_name=John Smith, last_name=Smith, receiver_id=seller@paypalsandbox.com, item_number=AK-1234, verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AMzH.1OGLzhiRtwR90w31D5sjl55, address_country=United States, payment_status=Completed, address_status=confirmed, business=seller@paypalsandbox.com, payer_email=buyer@paypalsandbox.com, notify_version=2.1, txn_type=web_accept, test_ipn=1, payer_status=verified, mc_currency=USD, mc_gross=12.34, address_state=CA, mc_gross1=9.34, payment_type=instant, address_street=123, any street,
IPN Response from Paypal Server:
HTTP/1.0 302 Found
Location: https://www.sandbox.paypal.com
Server: BigIP
Connection: close
Content-Length: 0
根据 PayPal 的文档,我去过https://gist.github.com/xcommerce-gists/3440401/download# PayPal 的文档中提到了这个链接。并尝试使用相同的代码,并在 PayPal IPN 设置和 IPN 模拟器的通知 URL 中设置了 URL。但仍然无法正常工作。不幸的是,上面链接中的代码没有向日志文件添加任何记录。
我还有另一个代码在日志文件中记录但记录为失败。
代码:
<?php
ob_start();
if($_SESSION == null) {
session_start();
}
error_reporting(0);
require_once('paypal.class.php'); // include the class file
$p = new paypal_class; // initiate an instance of the class
$p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; // testing paypal url
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (empty($_GET['action'])) $_GET['action'] = 'process';
switch ($_GET['action']) {
case 'ipn':
if ($p->validate_ipn()) {
$subject = 'Instant Payment Notification - Recieved Payment';
$p->send_report ( $subject );
}
else {
$subject = 'Instant Payment Notification - Payment Fail';
$p->send_report ( $subject );
}
break;
}
?>
【问题讨论】:
-
今天刚遇到同样的问题。解决为这个帖子:stackoverflow.com/questions/11746644/…
标签: php session paypal paypal-ipn