0

I am trying to get Encryption Token by calling the bluesnap API endpoint via browser. But request is blocked by CORS policy. How to get that token through browser, since i need to provide an input for user to enter the amount he wished to recharge.

I am calling this API in my react app through axios.

let xmls = `<param-encryption xmlns="http://ws.plimus.com"><parameters><parameter>
  <param-key>amount</param-key>
  <param-value>220</param-value>
</parameter>
<parameter>
  <param-key>currency</param-key>
  <param-value>USD</param-value>
</parameter>
<parameter>
  <param-key>language</param-key>
  <param-value>ENGLISH</param-value>
</parameter>

`

axios.post("https://sandbox.bluesnap.com/services/2/tools/paramencryption",
    xmls,
    {
      headers: {
        "Content-Type": "application/xml",
        "Authorization": "Basic QVBJXzE1NDQwGTQ0NzIxMTE5ODg2MTc1MzY6TW9udHkxJhJ="
      }
    }
  )
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.log(err);
  });

By calling this API i should get Encrypted Token

Malik Awan
  • 463
  • 5
  • 13

1 Answers1

1

I was running into the same problem. After chatting with Bluesnap support this is what I got.

The payment token request needs to occur with a server-to-server HTTP POST call. You won't be able to use a browser to have the payment token generated.

  • Ya i figured it out after reading their docs. Made another API Endpoint in my Nodejs and Just sent the POST request to bluesnap with xml data. Got the token, converted it into json and send the response to the browser. – Malik Awan May 15 '19 at 18:11