【问题标题】:Paypal sandbox Recurring Payments ipnPaypal 沙盒定期付款 ipn
【发布时间】:2016-10-27 18:08:14
【问题描述】:

我正在进行定期付款。付款完成并恢复到退货网址后,我没有收到 ipn 响应。这是我的定期付款代码:

    $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
}?>

【问题讨论】:

  • 你有什么错误吗?
  • 我在响应 [auth] 和 [form_charset] 中只得到两个变量。我想要交易ID和付款状态

标签: php paypal paypal-sandbox


【解决方案1】:

在 PHP 中你首先不需要使用 JavaScript 来重定向。

$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 处理程序。

【讨论】:

    猜你喜欢
    • 2015-07-01
    • 2017-03-09
    • 2015-08-19
    • 1970-01-01
    • 2014-01-23
    • 2012-11-07
    • 2012-03-18
    • 2013-06-17
    • 1970-01-01
    相关资源
    最近更新 更多