PayPal Rest API 是否具有等效的经典用户操作 [英] Does PayPal Rest API have the classic useraction equivalent

查看:17
本文介绍了PayPal Rest API 是否具有等效的经典用户操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 PayPal REST Api 跳过两步确认过程?

Is there a way to skip the 2 step confirmation process using the PayPal REST Api?

我已经使用 PayPal REST api 成功实施了标准流程,该流程将用户带到 PayPal 网站,在那里他们输入他们的凭据,然后显示订单摘要,并提供继续"选项和文本 - "你快完成了.您将在 xxxx 商店确认您的付款".

I've successfully implemented the standard process using the PayPal REST api, which takes the user to the PayPal site where they enter their credentials and then get presented with the order summary with the option to "continue" With the text - "youre almost done. You will confirm your payment on xxxx store".

有没有办法让我们跳过这一步——所以不要让用户返回我的网站,然后他们必须再次查看订单并选择付款",而是在 PayPal 上显示立即付款"按钮,会执行付款吗?

Is there a way we can skip this step - so not returning the user to my site where they then again have to review the order and select "make payment", but rather display the "pay now" button at PayPal, which will execute payment?

我搜索了一下,经典的 API 似乎通过添加 url 参数 useraction commit 来处理这个问题.如果我能找到 REST api 的等价物就好了.

I've searched, and the classic API seems to handle this by adding the url parameter, useraction commit. If only I could find an equivalent for the REST api.

推荐答案

我遇到了同样的问题,我从 PayPal 支持那里得到了答案.

I had the same problem and I got an answer from the PayPal support.

TL;DR:只需将 &useraction=commit 附加到批准_url.

TL;DR: Just append &useraction=commit to the approval_url.

他们告诉我 REST API 重定向 URL 是常规 Express Checkout 重定向 URL,因此您可以使用相同的参数.

They told me the REST API redirection URL is a regular Express Checkout redirection URL and therefore you can use the same parameter.

如果您执行以下付款 API 调用:

If you do a payment API call like:

curl -v https://api.sandbox.paypal.com/v1/payments/payment
-H "Content-Type:application/json"
-H "Authorization:Bearer ACCESS_TOKEN_HERE"
-d '{
    "transactions": [{
        "amount": {
            "currency":"USD",
            "total":"12"
        },
        "description":"creating a payment"
    }],
    "payer": {
        "payment_method":"paypal"
    },
    "intent":"sale",
    "redirect_urls": {
        "cancel_url":"https://devtools-paypal.com/guide/pay_paypal/curl?cancel=true",
        "return_url":"https://devtools-paypal.com/guide/pay_paypal/curl?success=true"
    }
   }'

您将收到以下回复:

{
   "id":"PAY-XYZ",
   "create_time":"2015-02-26T15:14:27Z",
   "update_time":"2015-02-26T15:14:28Z",
   "state":"created",
   "intent":"sale",
   "payer":{
      "payment_method":"paypal",
      "payer_info":{
         "shipping_address":{

         }
      }
   },
   "transactions":[
      {
         "amount":{
            "total":"12.00",
            "currency":"USD",
            "details":{
               "subtotal":"12.00"
            }
         },
         "description":"creating a payment",
         "related_resources":[

         ]
      }
   ],
   "links":[
      {
         "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-XYZ",
         "rel":"self",
         "method":"GET"
      },
      {
         "href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-FOOBAR",
         "rel":"approval_url",
         "method":"REDIRECT"
      },
      {
         "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-XYZ/execute",
         "rel":"execute",
         "method":"POST"
      }
   ]
}

在此响应中,您将获得批准网址

In this response you get the approval url

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-FOOBAR

并且您只需使用参数 &useraction=commit 以编程方式扩展它.

and you just have to programmatically extend it with the parameter &useraction=commit.

因此您将用户重定向到

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-FOOBAR&useraction=commit

示例来自 PayPal 开发人员工具.

这篇关于PayPal Rest API 是否具有等效的经典用户操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆