Paypal沙箱定期付款ipn

时间:2016-06-25 04:28:56

标签: php paypal paypal-sandbox

我正在进行定期付款。付款完成并恢复到返回URL后,我没有得到ipn响应。这是我的定期付款代码:

{{1}}

1 个答案:

答案 0 :(得分:0)

首先,您不需要使用JavaScript在PHP中重定向。

$paypalHost = $select_paypal_detail[0]->payment_type == 'live' ? 'paypal.com' : 'sandbox.paypal.com';

$query = array();
$query['cmd'] = '_xclick-subscriptions';
$query['upload'] = '1';

$query['business'] = $select_paypal_detail[0]->business_mail;

$product = $_POST['package'];
//$product_price = $_POST['price'];
$product_quantity = $_POST['quantity'];

$query['a3'] = $_POST['price'];
$query['p3'] = 1;
$query['t3'] = 'D';
$query['no_note'] = 1;

//$query['amount'] = $_POST['price'];

$query['discount_rate'] = $_POST['discount'];
$query['item_name'] = $_POST['package'];

$query['quantity'] = $_POST['quantity'];

$query['currency'] =  'CAD';
$query['instId'] = '211616';
$query['testMode'] = 100;
$_SESSION['order_number'] = $order_number;
$query['cartId'] = 'Order Number '.$_POST['order_number'];
$query['return'] = $select_paypal_detail[0]->return_url;
$query['notify_url'] = "http://theelitecoachingacademy.com/?AngellEYE_Paypal_Ipn_For_Wordpress&action=ipn_handler";

header('Location: https://www.' . $paypalHost . '/cgi-bin/webscr?' . http_build_query($query));
// usually, it's a good idea to exit after redirecting... in this case, it doesn't matter as the redirect is the last thing
exit;

就您的实际问题而言,我会检查business变量实际上是指向正确的帐户,具体取决于您是处于沙盒模式还是实时模式,因为我希望它们不同。如documentation所述,business变量是PayPal ID或与您的帐户关联的电子邮件地址。

如果您确定一切正确,那么我会使用Paypal的IPN模拟器检查您的IPN处理程序。