将用户发送到PayPal Guest Checkout

时间:2017-08-07 20:53:24

标签: php paypal paypal-sandbox paypal-rest-sdk

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

2 个答案:

答案 0 :(得分:0)

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

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

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

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

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