简体   繁体   中英

paypal subscription for multiple product using paypal api

I am trying to do Paypal subscription, but i did not getting any demo or sdk related Paypal subscription with multiple product. it only allow me to insert only one product information at time.

So unfortunately i had to combine all information and price in one product. Is there any solution regarding this issue?

On this website you can find a very nice REST API.

Here is example how to make multiple items:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM