如何使用Paypal PHP SDK为项目添加试用期?

时间:2017-02-08 15:56:44

标签: php paypal paypal-rest-sdk paypal-subscriptions

我正在开发一个应用程序,使用此SDK每月向我的用户收取订阅费用:https://github.com/paypal/PayPal-PHP-SDK

以下是代码:

$total = $price;
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$item = new Item();
$item->setName($productName)->setQuantity(1)->setPrice($price)->setCurrency($currency);
$itemList = new ItemList();
$itemList->setItems(array(
    $item
));
$details = new Details();
$details->setSubtotal($price);
$amount = new Amount();
$amount->setCurrency($currency)->setTotal($total)->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($itemList)->setDescription('Pay For ' . $productName)->setInvoiceNumber(uniqid());
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($returnUrl);
$payment = new Payment();
$payment->setIntent('sale')->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array(
    $transaction
));
$payment->create($paypal);
return $payment->getApprovalLink();

我想在订阅开始之前添加一个为期7天的试用期。使用Paypal SDK,我该怎么做?

0 个答案:

没有答案