问题描述
我是 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.
现在我可以创建一个正常的付款并且一切正常.现在我想将登录页面类型设置为 billing.在文档页面中,我被告知将 land_page_type 设置为 billing.我怎样才能在我的 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/#流配置对象
我的 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 集成到我的 $payment 中
What to do next ? How to integrage this $billing in my $payment
推荐答案
要设置登陆页面类型,您应该创建一个 Payment Experience 并在请求中指定登陆页面:
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 中使用对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!