0
我想用PayPal讓我的客戶用信用卡或借記卡支付,我已經允許用PayPal支付,我知道在登錄PayPal表單的按鈕下,一個按鈕說「用信用卡或借記卡付款「,但我想直接從腳本發送用戶到PayPal遊客結帳。發送用戶到PayPal遊客結賬
我使用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)
{