Search code examples
paypalpaypal-rest-sdk

PayPal REST API: how to do an immediate payment and without asking for shipping address


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. immediate payment: when the user goes to PayPal page show him a "Pay now" button instead of a "Continue" button and "You’re almost done. You will confirm your payment on ..." phrase.
  2. no shipping address: avoid asking the user to confirm his shipping address while on PayPal page (in Classic API is done with NOSHIPPING=1 parameter, if I remember well)

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?

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"
  }
}

And its response:

{
    "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"
        }
    ]
}

Solution

  • 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.

    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.