簡體   English   中英

貝寶沙箱定期付款IPN

[英]Paypal sandbox Recurring Payments ipn

我正在執行定期付款。 付款完成並恢復為返回網址后,我沒有收到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
}?>

首先,您不需要使用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變量是否實際上指向了正確的帳戶,因為我希望它們會有所不同。 文檔所述, business變量是PayPal ID或與您的帳戶關聯的電子郵件地址。

如果您確定一切正確,那么我將使用Paypal的IPN模擬器檢查您的IPN處理程序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM