将用户发送到 PayPal Guest Checkout

Send user to PayPal Guest Checkout

我想使用 PayPal 让我的客户使用信用卡或借记卡付款,我已经允许使用 PayPal 付款,我知道在登录 PayPal 表单的按钮下,它是一个显示 "Pay with credit or debit card" 的按钮但我想将用户直接从脚本发送到 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)
{ 

I need this place

Instead this one

遗憾的是,REST API 尚不支持来宾结帐。如果您想强制访客结账,则需要使用经典 API 快速结账。

您可以使用我们的 PayPal PHP class library 快速轻松地设置经典通话。然后您只需在 SetExpressCheckout 请求中设置以下参数:

  • SOLUTIONTYPE=独家
  • LANDINGPAGE=计费
  • USERSELECTEDFUNDINGSOURCE=信用卡

尝试:

$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(**********)

参考: