我想使用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)
{
答案 0 :(得分:0)
不幸的是,REST API尚不支持guest checkout。如果您想强制访客结账,则需要使用Classic API Express Checkout。
您可以使用我们的PayPal PHP class library快速轻松地设置经典电话。然后,您只需在SetExpressCheckout请求中设置以下参数:
答案 1 :(得分:0)
尝试:
$flowConfig = new \PayPal\Api\FlowConfig();
$flowConfig->setLandingPageType("Billing");
在webProfile
中设置此flowConfig,然后执行以下操作:
$webProfile->create($this->apiContext);
将ExperienceProfileId添加到创建付款的请求中,如下所示:
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
->setExperienceProfileId(**********)