【问题标题】:Send user to PayPal Guest Checkout将用户发送到 PayPal 访客结帐
【发布时间】:2018-01-15 06:27:37
【问题描述】:

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


    【解决方案1】:

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

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

    • SOLUTIONTYPE=鞋底
    • LANDINGPAGE=计费
    • USERSELECTEDFUNDINGSOURCE=信用卡

    【讨论】:

    • 你太棒了。
    【解决方案2】:

    试试:

    $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

    【讨论】:

    • 我已经设置好了...它显示了一个徽标,但除此之外它仍然需要 PayPal 帐户。
    猜你喜欢
    • 1970-01-01
    • 2016-07-06
    • 1970-01-01
    • 2014-05-03
    • 2015-11-07
    • 2016-03-10
    • 1970-01-01
    • 2011-12-10
    • 2020-01-28
    相关资源
    最近更新 更多