1

I am using "paypal-adaptive" for implementing paypal preapproval.(https://www.npmjs.com/package/paypal-adaptive). what i have is:

  export const paypalPreapproval = async () => {
    let result = null;
     await paypalSdk.preapproval(payload, function (err, response) {
     if (err) {
       console.log("err......", err);
     } else {
    console.log("response....", response);----->here i getting the response

  if (response.preapprovalUrl) {
  result = response;
  return result;
  }
  }
 });
 console.log("result", result); ---->But here it is null
};

How do i get the response here?It is my server side i need to return this result to client side so how i get the response here? where i went wrong?How can i solve this issue?

Khushi
  • 1,759
  • 6
  • 26
  • 45
  • If you expect it to return a promise (that you could `await`), then you should not pass a callback. If it does not return a promise and you must pass a callback, you should [promisify](https://stackoverflow.com/q/22519784/1048572) it. – Bergi Apr 28 '20 at 12:07

1 Answers1

0

Is this a new integration? PayPal Adaptive Payments is old and deprecated and should not be used for any new integrations. You will not be able to obtain an App ID nor go live with such an integration.

You should use a supported integration, such as PayPal Checkout or the Subscriptions API.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44