Why can't I open my PayPal partner referral link in the browser?

46 Views Asked by At

Trying to integrate PayPal into my marketplace, I have a script to create test PayPal partner referral URLs for the on boarding process. I can successfully generate the URLs but when I paste the URL in my browser nothing loads. I create the link with a valid token so I am not sure where I am going wrong.

My marketplace is built using the MERN stack and this testing is done using a platform sandbox app. code is below.

Generates the URL:

const createReferal = async () => {
  const paypalApiUrl =
    'https://api-m.sandbox.paypal.com/v2/customer/partner-referrals';

  const requestBody = {
    operations: [{ operation: 'API_INTEGRATION' }],
    legal_consents: [{ type: 'SHARE_DATA_CONSENT', granted: true }],
    products: ['EXPRESS_CHECKOUT'],
  };

  axios
    .post(paypalApiUrl, requestBody, {
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer {VALID TOKEN GOES HERE}`,
      },
    })
    .then((response) => {
      console.log(response.data);
    })
    .catch((error) => {
      console.log({ error: error.message });
    });
};

What is returned after the API call:

{
  links: [
    {
      href: 'https://api.sandbox.paypal.com/v2/customer/partner-referrals/YzI3ODk0YmUtNTgyYi00MmNmLThiNmItMjBlNTNmMjhkM2UzOWEvc20xZHRhZmUzRS9nTENPYWozOXFpQjVlVmF5WDRubDhoR3Rqb0ZZMD12Mg==',
      rel: 'self',
      method: 'GET',
      description: 'Read Referral Data shared by the Caller.'
    },
    {
      href: 'https://www.sandbox.paypal.com/bizsignup/partner/entry?referralToken=YzI3ODk0YmUtNTgyYi00MmNmLThiNmItMjBlNTNmMjhkM2UzOWEvc20xZHRhZmUzRS9nTENPYWozOXFpQjVlVmF5WDRubDhoR3Rqb0ZZMD12Mg==',
      rel: 'action_url',
      method: 'GET',
      description: 'Target WEB REDIRECT URL for the next action. Customer should be redirected to this URL in the browser.'
    }
  ]
}

When I paste the action_url in a browser a blank page loads and when I open the referral data I get this: enter image description here

0

There are 0 best solutions below