在 PAYPAL PHP REST API SDK 中使用对象

Vis*_*hnu 1 php api rest paypal

我是 Rest Api 的新手。我正在尝试通过 php sdk rest api 使用 paypal express checkout 创建付款。我已经下载并安装了他们的官方 sdk。

现在我可以创建一个正常的付款并且一切正常。现在我想将登录页面类型设置为 billing。在文档页面中,我被告知将landing_page_type 设置为 billing。我怎样才能在我的 php 脚本中做到这一点。

链接:https : //developer.paypal.com/docs/api/#flowconfig-object

我的 php 脚本看起来像

$transaction = new Transaction();
$transaction->setAmount($amount)
    ->setItemList($itemList)
    ->setDescription("Payment description")
    ->setInvoiceNumber(uniqid());



    $payment = new Payment();
    $payment->setIntent("sale")
        ->setPayer($payer)
        ->setRedirectUrls($redirectUrls)
        ->setTransactions(array($transaction));

    $payment->create($apiContext);
Run Code Online (Sandbox Code Playgroud)

因此,据我所知,我必须创建名为 flow config 的新对象并向其添加登录页面。我尝试了类似的操作

    $billing = new FlowConfig();
$billing->setLandingPageType("billing");
Run Code Online (Sandbox Code Playgroud)

接下来做什么 ?如何将此 $billing 集成到我的 $payment 中

小智 5

要设置登陆页面类型,您应该创建一个支付体验并在请求中指定登陆页面:

https://developer.paypal.com/docs/integration/direct/rest-experience-overview/ https://developer.paypal.com/docs/api/#payment-experience

PHP SDK 示例:https : //github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payment-experience/CreateWebProfile.php

响应中有一个支付体验配置文件 ID。然后将 ExperienceProfileId 添加到创建付款的请求中,如下所示:

$payment->setIntent("sale")
    ->setPayer($payer)
    ->setRedirectUrls($redirectUrls)
    ->setTransactions(array($transaction));
    ->setExperienceProfileId(**********)
Run Code Online (Sandbox Code Playgroud)