PayPal REST API: how to make an immediate payment and not ask for a delivery address

I am trying to use the PayPal REST API instead of the PayPal Classic API, but it seems that the REST API does not have two functions that the classic API has:

  • immediate payment: when the user goes to the PayPal page, show him the button "Pay now", and not the button "Continue" and "You are almost done. You will confirm your payment by ...".
  • there is no delivery address: do not ask the user to confirm their delivery address on the PayPal page (in the classic API it is executed with the parameter NOSHIPPING = 1, if I remember well)

So my question is: is it possible to make an immediate payment without requesting a delivery address using the REST API? Should I go back to the classic API?

I provide here a little more information on how I use the PayPal REST API. I am using PayPal REST Java SDK. This is an example 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 his answer:

{
    "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"
        }
    ]
}
+4
source share
4 answers

Unfortunately, the REST API is still far beyond the classic API with its functions. These features that you mentioned are pretty much what I saw, and as far as I know they are not yet available with REST services.

Classic, , REST. PHP ( ), PayPal. API- , Packagist, Composer.

+2

API REST API API .

- no_shipping . .

.

+2

, - , ...

:

paypal api:

, - "no_shipping", 1, , , .

, " . xxx. ' , !

, - , - , , , paypal api...

+2

REST API this

I believe that this means that you do not need to create any “profiles” as such and just transfer them along with the payment call ...

Further explanation on request :)

Below is an example of passing the PayPal experience parameters together with a specific payment call using the client-side JS method for express verification.

        payment: function(data, actions) {
        return actions.payment.create({
            payment: {
                transactions: [
                    {
                        amount: { total: '1.00', currency: 'USD' }
                    }
                ]
            },

            experience: {
                input_fields: {
                    no_shipping: 1
                }
            }
        });
    },

Hope you feel good guys! :)

+2
source

Source: https://habr.com/ru/post/1546460/


All Articles