Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PayPal Partner Referrals API URL

I am having trouble setting up Partner Referrals when calling the PayPal API using Node.

Every time I attempt to call the API I receive the following error:

error: "invalid_token"
error_description: "The token passed in was not found in the system"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

According to the documentation the URL to call is https://api-m.sandbox.paypal.com/v2/customer/partner-referrals

Looking at the URL and the error message, I believe I am getting this error because I am using production credentials, not sandbox. However, I cannot find any documentation showing the production URL for this.

Am I correct in believing this is the sandbox URL? What is the production URL if so?

Ive followed the onboarding checklist but cant seem to make this work.

Here is my code:

 getAuthToken = async () => {
    const clientIdAndSecret = "mylongsecret";
    const authUrl = "https://api-m.paypal.com/v1/oauth2/token";
    const base64 = Buffer.from(clientIdAndSecret).toString('base64')

    const response = await fetch(authUrl, { 
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'Accept-Language': 'en_US',
            'Authorization': `Basic ${base64}`,
        },
        body: 'grant_type=client_credentials'
    });
    const data = await response.json();
    return data;
}

setUpMerchant = async () => {
    let authData = await this.getAuthToken();
    const partnerUrl = "https://api-m.sandbox.paypal.com/v2/customer/partner-referrals";
    const request = await fetch(partnerUrl, { 
        method: 'get', 
        headers: {
          'Authorization': 'Bearer '+authData.access_token, 
          'Content-Type': 'application/json'
        }, 
    });
    const partnerData = await request.json();
    return partnerData;
}

Edit: I discovered the issue was I was running a GET request instead of a POST. The accepted answer is the correct URL

>Solution :

According to the documentation the URL to call is https://api-m.sandbox.paypal.com/v2/customer/partner-referrals

The production URL does not have sandbox. in the domain.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading