Convert currency
POST https://wallet.paysera.com/rest/v1/currency-conversion
Execute currency conversion in user's account.
Example: Convert EUR to 2.00 USD if price is no bigger than 1.50 EUR
Requirements​
- Scope CLIENT_CONVERT_CURRENCY needs to be granted to the client by Paysera. Request Paysera to provide it.
- Scope CONVERT_CURRENCY needs to be granted via OAuth by the wallet owner.
Authorization​
This endpoint requires MAC (Message Authentication Code) authentication.
Authorization Header Format:
Authorization: MAC id="CLIENT_ID", ts="TIMESTAMP", nonce="RANDOM_STRING", mac="MAC_HASH", ext="body_hash=BODY_HASH"
Example:
Authorization: MAC id="a9b8c7d6e5f4g3h2", ts="1234567890", nonce="xyz123abc456def", mac="dGhpcyBpcyBhIHJhbmRvbSBtYWMgaGFzaCB2YWx1ZQ==", ext="body_hash=cmFuZG9tQm9keUhhc2hWYWx1ZQ%3D%3D"
For more details, see the Authentication section.
Request Body​
Required parameters​
| Parameter | Type | Description |
|---|---|---|
account_number | string | Wallet account (IBAN-style) the conversion is executed on. Also used to resolve the wallet/user and check permissions. |
from_currency | string | ISO currency code to convert from. Must differ from to_currency. |
to_currency | string | ISO currency code to convert to. Must differ from from_currency. |
from_amount or from_amount_decimal or to_amount or to_amount_decimal | int (cents) / decimal string | Exactly one of these four must be present — it's the amount you're fixing. from_* = "convert exactly this much source currency." to_* = "receive exactly this much target currency." The other side is calculated from the live rate. |
Optional parameters​
| Parameter | Type | Requires | Description |
|---|---|---|---|
max_from_amount or max_from_amount_decimal | int (cents) / decimal string | Only valid when to_amount/to_amount_decimal was used | Caps how much of from_currency may be debited. If the live rate would cost more than this, the conversion fails instead of overcharging. Protects against unfavorable rate movement when you fixed the received amount. |
min_to_amount or min_to_amount_decimal | int (cents) / decimal string | Only valid when from_amount/from_amount_decimal was used | Guarantees a minimum amount of to_currency received. If the live rate would yield less than this, the conversion fails instead of shortchanging you. Protects against unfavorable rate movement when you fixed the sent amount. |
Example​
Request​
POST https://wallet.paysera.com/rest/v1/currency-conversion
Content-Type: application/json
Authorization: MAC id="CLIENT_ID", ts="TIMESTAMP", nonce="RANDOM_STRING", mac="MAC_HASH", ext="body_hash=BODY_HASH"
{
"from_currency": "EUR",
"to_currency": "USD",
"to_amount": 200,
"account_number": "EVP0010001000101",
"max_from_amount": 150
}
Response​
{
"id": 11221,
"date": 1391686980,
"from_currency": "EUR",
"to_currency": "USD",
"from_amount": 150,
"from_amount_decimal": "1.50",
"to_amount": 200,
"to_amount_decimal": "2.00",
"account_number": "EVP0010001000101"
}
AUTHORIZATION: HTTP
REQUEST
Base URL
https://wallet.paysera.com
Body REQUIRED
{
"from_currency": "EUR",
"to_currency": "USD",
"to_amount": 200,
"account_number": "EVP0010001000101",
"max_from_amount": 150
}
RESPONSE
Conversion successful
{
"id": 11221,
"date": 1391686980,
"from_currency": "EUR",
"to_currency": "USD",
"from_amount": 150,
"from_amount_decimal": "1.50",
"to_amount": 200,
"to_amount_decimal": "2.00",
"account_number": "EVP0010001000101"
}