【发布时间】:2018-01-15 06:27:37
【问题描述】:
我想使用 PayPal 让我的客户使用信用卡或借记卡付款,我已经允许使用 PayPal 付款,我知道在登录 PayPal 表单的按钮下,它的按钮显示“使用信用卡或借记卡付款" 但我想直接将用户从脚本发送到 PayPal Guest Checkout。
我使用 PayPal SDK,这是我的代码:
if($Payment_Type == 0)
{
if(!isset($Payment_Type))
{
die();
}
$product = 'Reservation';
$price = $Total;
$shipping = 0.00;
$total = $price + $shipping;
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$item = new Item();
$item->setName($product)
->setCurrency('USD')
->setQuantity(1)
->setPrice($price);
$itemList = new ItemList();
$itemList->setItems([$item]);
$details = new Details();
$details->setShipping($shipping)
->setSubtotal($price);
$amount = new Amount();
$amount->setCurrency('USD')
->setTotal($total)
->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription('Service My Transfer In Cabo')
->setInvoiceNumber(uniqid());
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(SITE_URL . '/pay.php?success=true)
->setCancelUrl(SITE_URL . '/pay.php?success=false);
$payment = new Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions([$transaction]);
try { $payment->create($paypal); }
catch(Exception $e){ die($e); }
$approvalUrl = $payment->getApprovalLink();
header("Location: {$approvalUrl}");
}
elseif($Payment_Type == 2)
{
【问题讨论】:
标签: php paypal paypal-sandbox paypal-rest-sdk