Payouts not working with live Credentials

mustangmath
New Community Member

I have code that works perfectly when in sandbox mode. However, when switching to live mode, I get a 'Authorization Error' issue. I've double checked that I'm using the right credentials and URLs, but I just get an authentication error. 
This is the code I'm using to try and access the API:

function createPayoutBatch(payoutItems) {
  const apiUrl = 'https://api.paypal.com/v1/payments/payouts';
  const clientId = 'my-client-id-is-here'
  const clientSecret = 'my-secret-is-here'
  // PayPal access token
  var accessToken = getPayPalAccessToken(clientId, clientSecret, true);
  Logger.log("TOKEN " + accessToken) //Access Token is generated properly
  var payload = {
    "sender_batch_header": {
      "sender_batch_id": Utilities.getUuid(),
      "email_subject": "Tutoring Payout"
    },
    "items": payoutItems
  };
  Logger.log(JSON.stringify(payload))
  var options = {
    'method': 'post',
    'headers': {
      'Authorization': 'Bearer ' + accessToken,
      'Content-Type': 'application/json',
    },
    'payload': JSON.stringify(payload),
  };

  var response = UrlFetchApp.fetch(apiUrl, options);
  return response;
}

Again, the format of the payload has to be fine because the code works in the Sandbox. I've also double checked that the 'Payouts' checkbox is checked and saved in the API Key setup.


Login to Me Too
1 REPLY 1

Kavyar
Moderator
Moderator

Good day @mustangmath 

 

Thank you for posting to the PayPal community.

 

We regret to inform you that your account is currently not authorized to use payouts.

 

Kindly refer to the detailed guide link - https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#error-AUTHORIZATION_ERROR

 

I would suggest to please contact our PayPal Customer service via link -  https://www.paypal.com/smarthelp/contact-us (then choose at the bottom one of the contact methods - email or phone) who should be able to help you regarding the request.

 

They will be able to assist you further as they are specially trained to address this type of account inquiry.

 

Sincerely,

Kavya

PayPal MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

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.