convert
Using the methods of the convert model the merchant can:
- Perform the currencies convertation - convert.create
- Calculate the convertation parameters - convert.calc
- Receive info about chosen convertation transaction - convert.get
Caution!
Model methods are blocked for typed merchants, trying to use convert model methods for typed merchants the system will return an exception EStateForbidden.
endpoint
Queries for the model's methods are sent to endpoint https://api.any.money/.
convert.create
The method creates a convertation order for the transmitted currency pair and returns the representation of the operation details.
Input method arguments
| Param | Required | Example | Description |
|---|---|---|---|
| externalid | yes | "123" | ID specified by the merchant |
| in_amount | yes* | "2345" | credit amount |
| in_curr | yes | "USD" | credit currency |
| out_amount | yes* | "345" | debit amount |
| out_curr | yes | "UAH" | debit currency |
| callback_url | no | "https://any_money.redirect.com" | url-address for messages about order status changes. Messages format |
* in_amount or out_amount is required
Method response data
order representation of the convert type transaction
Exceptions
- EParamAmountFormatInvalid
- the transmitted amount does not match the currency parameters. For example, the fractional part does not match
- EParamAmountTooBig
- the processed amount exceeds the maximum convertation amount
- EParamAmountTooSmall
- the processed amount is less than minimum convertation amount
- EParamCurrencyInvalid
- the currency is not present in a system
- EParamFieldInvalid
- invalid callback_url argment is transmitted
- EParamInvalid
- wrong values of in_amount, out amount are transmitted, no one of in_amount, out amount is transmitted or they are transmitted together
- EParamUnique
- order with transmitted externalid allready exists
- EStateCurrencyInactive
- transmitted in_curr, out_curr currency is not active (disabled)
- EStateExchangeUnavail
- in_curr and out_curr are equial or convertation direction is unavailable
- EStateForbidden
- attempt to use the method for a typed merchant
- EStateInsufficientFunds
- the required amount exceeds the merchant balance of the debit currency
convert.calc
Method for calculating the convertation order parameters taking into account the transaction amount and currencies names.
Input method arguments
| Param | Required | Example | Description |
|---|---|---|---|
| in_amount | yes* | "100" | credit amount |
| in_curr | yes | "UAH" | credit currency |
| out_amount | yes* | "100" | debit amount |
| out_curr | yes | "USD" | debit currency |
| validate_balance | no | true | the key for sufficiency verification of the debit currency balance for transaction completion (true = verification is required, false = not) default = true. It's important to transmit the parameter as boolean, not string. Values like "false" will be counted as default true |
* in_amount or out_amount is required
Method response data
Parameters of the convert type order
- in_amount
- credit currency amount required for convertation
- orig_amount
- original sum, the debit or credit amount, booked with the order creation
- out_amount
- amount of debit currency resulting after the convertation
- rate
- convertation rate, if the convertation performed. In
"rate": ["25.30301", "1"]format
Exceptions
- EParamAmountFormatInvalid
- the transferred amount does not match the currency parameters. For example, the fractional part does not match
- EParamAmountTooBig
- the processed amount exceeds the maximum convertation amount
- EParamAmountTooSmall
- the processed amount is less than minimum convertation amount
- EParamCurrencyInvalid
- the in_curr and/or out_curr currency are not present in a system
- EParamInvalid
- invalid argument value is transmitted
- EStateCurrencyInactive
- transmitted in_curr, out_curr currency is not active (disabled)
- EStateExchangeUnavail
- in_curr and out_curr are equial or convertation direction is unavailable
- EStateForbidden
- attempt to use the method for a typed merchant
- EStateInsufficientFunds
- the required amount exceeds the merchant's balance of the debit currency
convert.get
Method for search and receive the convert (currency exchange) type order parameters by its ID.
Input method arguments
| Param | Required | Example | Description |
|---|---|---|---|
| externalid | yes | "123" | unique ID specified by the merchant |
Method response data
Exceptions
- EParamInvalid
- wrong externalid argument value transmitted
- EParamNotFound
- no order was found with the appropriate externalid
- EStateForbidden
- attempt to use the method for a typed merchant