在PAYPAL PHP REST API SDK中使用对象 [英] Using Objects in PAYPAL PHP REST API SDK
问题描述
我是Rest Api的新手.我正在尝试通过php sdk rest api使用paypal express checkout创建付款.我已经下载并安装了他们的官方sdk.
I am new to Rest Api's . 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脚本中做到这一点.
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.
链接: https://developer.paypal.com/docs/api/# flowconfig-object
我的php脚本看起来像
My php script looks something like
$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);
据我所知,我必须创建一个名为flow config的新对象,并向其添加登录页面.我尝试了类似的方法
So As for I understood ,I must create new object named flow config and add landing page to it.I tried something like
$billing = new FlowConfig();
$billing->setLandingPageType("billing");
下一步该怎么做?如何将此$ billing整合到我的$ payments中
What to do next ? How to integrage this $billing in my $payment
推荐答案
要设置登录页面类型,您应该创建一个付款体验并在请求中指定登录页面:
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
PHP SDK示例: https://github.com/paypal /PayPal-PHP-SDK/blob/master/sample/payment-experience/CreateWebProfile.php
PHP SDK sample: https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payment-experience/CreateWebProfile.php
响应中有一个付款体验配置文件ID. 然后将ExperienceProfileId添加到创建付款的请求中,如下所示:
There is a payment experience profile ID in the response. Then add the ExperienceProfileId to the request of Create a Payment like below:
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
->setExperienceProfileId(**********)
这篇关于在PAYPAL PHP REST API SDK中使用对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!