我试图做贝宝订阅,但我没有得到任何演示或sdk相关的贝宝订阅与多个产品。一次只允许我插入一个产品信息。
所以不幸的是,我不得不把所有的信息和价格综合在一个产品中。
关于这个问题有什么解决办法吗?
最佳答案
在this网站上,您可以找到一个非常好的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;
}
关于php - 使用Paypal API的多个产品的PayPal订阅,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31957791/