【发布时间】:2018-08-23 00:02:30
【问题描述】:
我使用适用于 PHP 的 PayPal SDK 并希望在结账时不显示详细信息和总计而不是小计(如左图所示)。 谢谢!
这是我使用的代码。
$arrPrices = $this->getPrices();
$apiContext = $this->getApiContext();
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod("paypal");
$arrItems = [];
$item = new \PayPal\Api\Item();
$item->setName($saveValues['title'])->setCurrency('EUR')->setQuantity(1)->setPrice($arrPrices['raw']);
$arrItems[] = $item;
$itemList = new \PayPal\Api\ItemList();
$itemList->setItems($arrItems);
$details = new \PayPal\Api\Details();
$details->setTax($arrPrices['tax'])->setSubtotal($arrPrices['raw']);
$amount = new \PayPal\Api\Amount();
$amount->setCurrency("EUR")->setTotal($arrPrices['total'])->setDetails($details);
$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount)->setItemList($itemList)->setDescription("Vielen Dank für Deine Buchung & bis bald!");
$redirectUrls = new \PayPal\Api\RedirectUrls();
$url = \Environment::get('url') . '/' . $GLOBALS['SCRIPT_URL'];
$redirectUrls->setReturnUrl("$url?success=true")->setCancelUrl("$url?success=false");
$payment = new \PayPal\Api\Payment();
$payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->addTransaction($transaction);
try {
$payment->create($apiContext);
}
catch (\Exception $ex) {
return $ex->getData();
}
return $payment->getApprovalLink();
【问题讨论】: