PayPal REST API:如何立即付款而无需询问送货地址 [英] PayPal REST API: how to do an immediate payment and without asking for shipping address

查看:194
本文介绍了PayPal REST API:如何立即付款而无需询问送货地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PayPal REST API代替PayPal Classic API,但是REST API似乎缺少Classic API具有的两个功能:

I'm trying to use PayPal REST API instead of PayPal Classic API but it seems that the REST API is lacking two features that the Classic API has:

  1. 立即付款:当用户转到PayPal页面时,向他显示立即付款"按钮,而不是继续"按钮,并显示您快要付款了.您将在...上确认付款".
  2. 没有收货地址:避免在PayPal页面上要求用户确认其收货地址(如果我记得很好的话,Classic API是使用NOSHIPPING = 1参数完成的)

所以我的问题是:是否可以在不使用REST API要求提供送货地址的情况下立即付款?我必须回到经典API吗?

So my question is: is it possibile do perform an immediate payment without asking for shipping address using REST API? Do I have to go back to Classic API?

我在这里提供有关如何使用PayPal REST API的更多信息. 我正在使用PayPal REST Java SDK. 这是一个示例请求:

I provide here a little more informations about how I'm using the PayPal REST API. I'm using the PayPal REST Java SDK. This is a sample request:

{
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "currency": "USD",
        "total": "5",
        "details": {
          "subtotal": "5"
        }
      },
      "description": "This is the payment transaction description.",
      "item_list": {
        "items": [
          {
            "quantity": "1",
            "name": "Item 1",
            "price": "5",
            "currency": "USD"
          }
        ]
      }
    }
  ],
  "redirect_urls": {
    "return_url": "http://XXX/handlePayment.jsp?guid\u003dXXX",
    "cancel_url": "http://XXX/cancelPayment.jsp?guid\u003dXXX"
  }
}

及其回应:

{
    "id": "XXX",
    "create_time": "2014-06-29T08:52:55Z",
    "update_time": "2014-06-29T08:52:55Z",
    "state": "created",
    "intent": "sale",
    "payer": {
        "payment_method": "paypal",
        "payer_info": {
            "shipping_address": {}
        }
    },
    "transactions": [
        {
            "amount": {
                "total": "5.00",
                "currency": "USD",
                "details": {
                    "subtotal": "5.00"
                }
            },
            "description": "This is the payment transaction description.",
            "item_list": {
                "items": [
                    {
                        "name": "Item 1",
                        "price": "5.00",
                        "currency": "USD",
                        "quantity": "1"
                    }
                ]
            }
        }
    ],
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/XXX",
            "rel": "self",
            "method": "GET"
        },
        {
            "href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=XXX",
            "rel": "approval_url",
            "method": "REDIRECT"
        },
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/XXX/execute",
            "rel": "execute",
            "method": "POST"
        }
    ]
}

推荐答案

不幸的是,REST API仍比其提供的功能落后于Classic API.您提到的这些功能是我已经看到的很多东西,据我所知,它们尚未在REST服务中提供.

Unfortunately, the REST API is still a long ways behind the Classic API with features it provides. These features you mentioned are things I've seen come up quite a bit, and to my knowledge they are not yet available with the REST services.

我个人一直坚持使用Classic,因为它们可以提供所有内容,而我自己使用REST确实没有优势.如果您碰巧正在使用PHP(我一直这样做),您可能会对我的可在Packagist上使用,因此您可以轻松使用Composer.

I personally have stuck with Classic as they provide everything and I really see no advantage to using REST myself. If you happen to be working with PHP (which I always do) you may be interested in my class library for PayPal. It makes all of the Classic API calls very quick and easy for you, and it's available on Packagist so you can use with Composer easily.

这篇关于PayPal REST API:如何立即付款而无需询问送货地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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