Malik Awan
Malik Awan

Reputation: 463

Post call to bluesnap API for getting encryption token

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

Upvotes: 0

Views: 290

Answers (1)

Taylor Earl
Taylor Earl

Reputation: 66

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.

Upvotes: 1

Related Questions