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

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

问题描述

是否可以使用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参数(用户操作提交)来解决此问题.如果可以,我可以找到与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附加到roval_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.

因此,您将用户重定向到

So you redirect your user to

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

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

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

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