How to get an authorisation ID from PayPal when using Express Checkout with checkout.js

TanjaBadNauheim
Contributor
Contributor

We do payment in a web app by PayPal with checkout.js . Everything works fine if we execute the payment with the intent : "sale". But now we want to authorize the payment with checkout.js at the frontend and capture later at the backend with PayPal REST API.

When we set the payment with intent : "authorize" we get response, but there is no authorisation ID we need for capture later. The related_recources array is empty. Can anybody tell me what is going wrong here? Tested with sandbox & production mode. Thanks in advance.

 

paypal.Button.render({

    env: 'sandbox',

    client: {
        sandbox: xxxxxxxxx
    },

    payment: function() {

       var env    = this.props.env;
       var client = this.props.client;

       return paypal.rest.payment.create(env, client, {

          intent: "authorize", 
          transactions: [
             {
                amount: { total: totalEur, currency: "EUR" },
                description: "Reservation..." 
             }
          ]
       });
   },

   commit: true, 

   onAuthorize: function(data, actions) {

      actions.payment.get().then(function(pdata) {

         console.dir(pdata);

         ...
Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

MTS_Andre
Moderator
Moderator

Hi, you get in the response the "Response payload" returned after a successful call with either the PayPal authorization ID or the pay key to process via REST (PAY-XXXXXXXXXX). Or once the authorization is processed you then can log-in into your PayPal profile and capture the payment from there.

If you open the developer tool/console (F12) just before you click the payment button then check into the Network tab and you will find the Response Payload in the response  area, attached image. This is returned in the response so you can use the response payload.

View solution in original post

Login to Me Too
1 REPLY 1
Solved

MTS_Andre
Moderator
Moderator

Hi, you get in the response the "Response payload" returned after a successful call with either the PayPal authorization ID or the pay key to process via REST (PAY-XXXXXXXXXX). Or once the authorization is processed you then can log-in into your PayPal profile and capture the payment from there.

If you open the developer tool/console (F12) just before you click the payment button then check into the Network tab and you will find the Response Payload in the response  area, attached image. This is returned in the response so you can use the response payload.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.