将用户发送到PayPal Guest Checkout

问题描述 投票:0回答:2

我想使用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)
{ 

I need this place

Instead this one

php paypal paypal-sandbox paypal-rest-sdk
2个回答
0
投票

遗憾的是,REST API尚不支持guest checkout。如果您想强制访客结账,则需要使用Classic API Express Checkout。

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

  • SOLUTIONTYPE =鞋底
  • 的LandingPage =结算
  • USERSELECTEDFUNDINGSOURCE = CreditCard

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

请参阅:https://stackoverflow.com/a/32047084/212692

© www.soinside.com 2019 - 2024. All rights reserved.