2017-08-07 53 views
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) 
{ 

I need this place

Instead this one

回答

0

不幸的是,客人結賬尚不支持REST的API中。如果您想強制訪客結帳,則需要使用Classic API Express Checkout。

您可以使用我們的PayPal PHP class library快速輕鬆地獲得經典通話設置。然後,你只需要設置以下參數在SetExpressCheckout請求:

  • SOLUTIONTYPE =鞋底
  • 的LandingPage =結算
  • USERSELECTEDFUNDINGSOURCE =信用卡式