[英]Paypal sandbox Recurring Payments ipn
I am doing recurring payment. 我正在执行定期付款。 After the payment is complete and reverted back to the return url, I am not getting the ipn response.
付款完成并恢复为返回网址后,我没有收到ipn响应。 This is my code for recurring payment:
这是我的定期付款代码:
$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";
// Prepare query string
$query_string = http_build_query($query);
if( $select_paypal_detail[0]->payment_type == 'live' ){
?>
<!--/header('Location: https://www.paypal.com/cgi-bin/webscr?' . $query_string);
header('Location: https://www.sandbox.paypal.com/cgi-bin/webscr?' . $query_string);-->
<script type="text/javascript">
window.location="https://www.paypal.com/cgi-bin/webscr?<? echo $query_string ?>";
</script>
<?php } else { ?>
<script type="text/javascript">
window.location="https://www.sandbox.paypal.com/cgi-bin/webscr?<? echo $query_string ?>";
</script>
<?php
}?>
You don't need to use JavaScript to redirect in PHP first of all. 首先,您不需要使用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;
In terms of your actual problem, I would check business
variable is actually pointing to the right account depending on whether you are in sandbox mode or live mode because I would expect them to be different. 根据您的实际问题,我将根据您是处于沙盒模式还是实时模式来检查
business
变量是否实际上指向了正确的帐户,因为我希望它们会有所不同。 As the documentation mention, the business
variable is the PayPal ID or an email address associated with your account. 如文档所述,
business
变量是PayPal ID或与您的帐户关联的电子邮件地址。
If you are sure that everything is correct, then I would check your IPN handler using the Paypal's IPN simulator. 如果您确定一切正确,那么我将使用Paypal的IPN模拟器检查您的IPN处理程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.