简体   繁体   English

在PAYPAL PHP REST API SDK中使用对象

[英]Using Objects in PAYPAL PHP REST API SDK

I am new to Rest Api's . 我是Rest Api的新手。 I am trying to create a payment using paypal express checkout via php sdk rest api.I have downloaded and installed their official sdk. 我正在尝试通过php sdk rest api使用Paypal Express Checkout创建付款,我已经下载并安装了他们的官方sdk。

Now I can create a normal payment and everything is working fine.Now I want to set landing page type to billing.In documentation page I have been told to set landing_page_type to billing. 现在我可以创建正常付款,并且一切正常,现在我想将着陆页类型设置为开单。在文档页面中,我被告知将着陆页类型设置为开单。 How can I do that in my php script. 我该如何在我的PHP脚本中做到这一点。

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

My php script looks something like 我的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);

So As for I understood ,I must create new object named flow config and add landing page to it.I tried something like 因此,据我了解,我必须创建一个名为flow config的新对象并向其添加目标页面。

    $billing = new FlowConfig();
$billing->setLandingPageType("billing");

What to do next ? 接下来做什么 ? How to integrage this $billing in my $payment 如何将此$ billing整合到我的$ pay中

To set landing page type, you should create a Payment Experience and specify the landing page in the request: 要设置登录页面类型,您应该创建一个付款体验并在请求中指定登录页面:

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

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

There is a payment experience profile ID in the response. 响应中有一个付款体验配置文件ID。 Then add the ExperienceProfileId to the request of Create a Payment like below: 然后将ExperienceProfileId添加到创建付款的请求中,如下所示:

$payment->setIntent("sale")
    ->setPayer($payer)
    ->setRedirectUrls($redirectUrls)
    ->setTransactions(array($transaction));
    ->setExperienceProfileId(**********)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM