Exchange Rate

👍

HTTPS POST / Server-to-Server

Sandbox endpoint : sandbox-pgw.2c2p.com/payment/4.1/ExchangeRate/secure
Run test with Swagger Editor

To go live, refer to: Live endpoint guide

The Exchange Rate API allows merchant to retrieve foreign exchange rates.

Exchange Rate Request


To prepare an exchange rate request, refer to the guidelines below.

  1. Prepare payload data.

The sample code below demonstrates the correct structure for an API request.

For API specifications, refer to: Exchange Rate Request Parameters

{
      "merchantID": "JT01",
      "providerCode": "MCP",
      "currencyCode": "SGD"
}

 

  1. Generate JWT Token. Refer to: Generate JWT Token
  2. Assign the JWT token to payload and send the API request.
{
    "payload": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXltZW50VG9rZW4iOiIyNTRiNzdhNS01NTY4LTQ5Y2EtOWUwZS0yZjhkMjhiZTk1ZTciLCJpbnZvaWNlTm8iOiIyNTRiNzdhYWJjIiwibG9jYWxlIjoiZW4ifQ.r8EEFRXlNcLi566BrzroOh6qbjGSyWq
J9ZARSR5XwQ4"
}

 

Exchange Rate Response


To process an Exchange Rate API response, refer to the guidelines below.

  1. The Exchange Rate API will return response data that contains a JWT token. The sample code below demonstrates the structure of the JWT payload response.
{
    "payload": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjaGFudElEIjoiSlQwMSIsInByb3ZpZGVyQ29kZSI6IlNDQiIsImN1cnJlbmN5Q29kZSI6IlNHRCIsImV4cGlyZSI6MTU5NDc2MDQxMSwiZnhSYXRlcyI6W3sic2VxdWVuY2VObyI6MSwiaWQiOiIyQzJQMTBJUzcxQjBaWDZVVCIsIm5hbWUiOiJQb3VuZCBTdGVybGluZyIsImljb25VcmwiOm51bGwsImFtb3VudCI6bnVsbCwiZngiOjEuNjkzNzM4MiwiY3VycmVuY3lDb2RlIjoiR0JQIn0seyJzZXF1ZW5jZU5vIjoyLCJpZCI6IjJDMlAxQzlFM0hBT1BJMkVYIiwibmFtZSI6IkF1c3RyYWxpYW4gRG9sbGFyIiwiaWNvblVybCI6bnVsbCwiYW1vdW50IjpudWxsLCJmeCI6MC45MzY0MjYsImN1cnJlbmN5Q29kZSI6IkFVRCJ9LHsic2VxdWVuY2VObyI6MywiaWQiOiIyQzJQMUJEUE44NFlLTEoxMiIsIm5hbWUiOiJFdXJvIiwiaWNvblVybCI6bnVsbCwiYW1vdW50IjpudWxsLCJmeCI6MS41MzA3MTM4LCJjdXJyZW5jeUNvZGUiOiJFVVIifSx7InNlcXVlbmNlTm8iOjQsImlkIjoiMkMyUDFMSE5OMzYxWk5LQlUiLCJuYW1lIjoiVVMgRG9sbGFyIiwiaWNvblVybCI6bnVsbCwiYW1vdW50IjpudWxsLCJmeCI6MS4zNDk1Mjc3LCJjdXJyZW5jeUNvZGUiOiJVU0QifSx7InNlcXVlbmNlTm8iOjUsImlkIjoiMkMyUDE4TTRPMk4xWVZMRFEiLCJuYW1lIjoiWWVuIiwiaWNvblVybCI6bnVsbCwiYW1vdW50IjpudWxsLCJmeCI6MC4wMTI1NzIzLCJjdXJyZW5jeUNvZGUiOiJKUFkifSx7InNlcXVlbmNlTm8iOjYsImlkIjoiMkMyUDExQUxGSktTQVJBWEIiLCJuYW1lIjoiTmV3IFplYWxhbmQgRG9sbGFyIiwiaWNvblVybCI6bnVsbCwiYW1vdW50IjpudWxsLCJmeCI6MC44ODIwMjg3LCJjdXJyZW5jeUNvZGUiOiJOWkQifSx7InNlcXVlbmNlTm8iOjcsImlkIjoiMkMyUDFQNEFBM1UzNlBUNzAiLCJuYW1lIjoiSG9uZyBLb25nIERvbGxhciIsImljb25VcmwiOm51bGwsImFtb3VudCI6bnVsbCwiZngiOjAuMTc0MTA5OSwiY3VycmVuY3lDb2RlIjoiSEtEIn1dLCJyZXNwQ29kZSI6IjAwMDAiLCJyZXNwRGVzYyI6IlN1Y2Nlc3MifQ.1CzD4LX2HtnurYFiTsRbbLLirsXxHatDBi2OmjEApJo"
}
  1. The JWT token must be decoded. Refer to: Decode JWT Token

The sample code below demonstrates the structure for the decoded API response. For more details on the specific parameters, refer to: Exchange Rate Response Parameters

{
  "merchantID": "JT01",
  "providerCode": "MCP",
  "currencyCode": "SGD",
  "expire": 1594760411,
  "fxRates": [
    {
      "sequenceNo": 1,
      "id": "2C2P10IS71B0ZX6UT",
      "name": "Pound Sterling",
      "iconUrl": null,
      "amount": null,
      "fx": 1.6937382,
      "currencyCode": "GBP"
    },
    {
      "sequenceNo": 2,
      "id": "2C2P1C9E3HAOPI2EX",
      "name": "Australian Dollar",
      "iconUrl": null,
      "amount": null,
      "fx": 0.936426,
      "currencyCode": "AUD"
    },
    {
      "sequenceNo": 3,
      "id": "2C2P1BDPN84YKLJ12",
      "name": "Euro",
      "iconUrl": null,
      "amount": null,
      "fx": 1.5307138,
      "currencyCode": "EUR"
    },
    {
      "sequenceNo": 4,
      "id": "2C2P1LHNN361ZNKBU",
      "name": "US Dollar",
      "iconUrl": null,
      "amount": null,
      "fx": 1.3495277,
      "currencyCode": "USD"
    },
    {
      "sequenceNo": 5,
      "id": "2C2P18M4O2N1YVLDQ",
      "name": "Yen",
      "iconUrl": null,
      "amount": null,
      "fx": 0.0125723,
      "currencyCode": "JPY"
    },
    {
      "sequenceNo": 6,
      "id": "2C2P11ALFJKSARAXB",
      "name": "New Zealand Dollar",
      "iconUrl": null,
      "amount": null,
      "fx": 0.8820287,
      "currencyCode": "NZD"
    },
    {
      "sequenceNo": 7,
      "id": "2C2P1P4AA3U36PT70",
      "name": "Hong Kong Dollar",
      "iconUrl": null,
      "amount": null,
      "fx": 0.1741099,
      "currencyCode": "HKD"
    }
  ],
  "respCode": "0000",
  "respDesc": "Success"
}