贝宝订阅多个产品使用贝宝api


paypal subscription for multiple product using paypal api

我正在尝试做贝宝订阅,但我没有得到任何演示或sdk相关贝宝订阅与多个产品。它只允许我一次插入一个产品信息。

所以不幸的是,我不得不把所有的信息和价格结合在一个产品中。这个问题有什么解决办法吗?

在这个网站上你可以找到一个非常好的REST API。

下面是如何制作多个项目的示例:

<?php
$paypal = new DPayPal(); //Create an object
$requestParams = array(
    'RETURNURL' => "http://yourwebsite.com", //Enter your webiste URL here
    'CANCELURL' => "http://yourwebsite.com/payment/cancelled"//URL where user will be redirected if he/she cancel the payment
);

$item = array(
    //Total order amount and currency    
    'PAYMENTREQUEST_0_AMT' => "155",//This has to be equal to sum of all items
    'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP',
    'PAYMENTREQUEST_0_ITEMAMT' => "155",//This has to be equal to sum of all items

    //Item 1
    'L_PAYMENTREQUEST_0_NAME0' => 'Item 1',
    'L_PAYMENTREQUEST_0_DESC0' => 'Item 1 description',
    'L_PAYMENTREQUEST_0_AMT0' => "55",
    'L_PAYMENTREQUEST_0_QTY0' => '1',
    //Item 2
    'L_PAYMENTREQUEST_0_NAME1' => 'Item 2',
    'L_PAYMENTREQUEST_0_DESC1' => 'Item 2 description',
    'L_PAYMENTREQUEST_0_AMT1' => "100",
    'L_PAYMENTREQUEST_0_QTY1' => '1',
);
//Call SetExpressCheckout
$response = $paypal->SetExpressCheckout($requestParams + $orderParams + $item);
if (is_array($response) && $response['ACK'] == 'Success') { //Request successful
    //Now we have to redirect user to the PayPal
    $token = $response['TOKEN'];
    header('Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . urlencode($token));
} else if (is_array($response) && $response['ACK'] == 'Failure') {
    echo "Error";
    exit;
}
相关文章:
  • 没有找到相关文章