Convert amount
GET https://{domainname}/client/v1/{customerId}/services/convert/amount
Services
Request
Using the convert amount API you can ask our system to convert an amount from one currency into another currency. We will use the rate set configured for your account to perform the conversion.
All amount fields in our API are in cents with each amount having 2 decimals, regardless of the actual decimal places the currency has. So JPY has no decimals in it currency, but you will need to add two zeros as cents.
Query parameters
Query parameters for this method
Property | Type | Required | Repeat | Details |
---|---|---|---|---|
source | string | yes | no | read close |
close
DescriptionThree-letter ISO currency code representing the source currency
|
||||
target | string | yes | no | read close |
close
DescriptionThree-letter ISO currency code representing the target currency
|
||||
amount | integer | yes | no | read close |
close
DescriptionAmount to be converted in cents and always having 2 decimals
|
Request example
SDK: Swift
This scenario you will probably use the most
-
import IngenicoConnectKit let clientSessionId = "<clientSessionId from Create Session>" let customerId = "<customerId from Create Session>" let baseURL = "<clientApiUrl from Create Session>" let assetBaseURL = "<assetUrl from Create Session>" let appIdentifier = "<your app name>" let session = Session(clientSessionId: clientSessionId, customerId: customerId, baseURL: baseURL, assetBaseURL: assetBaseURL, appIdentifier: appIdentifier) let amountInCents = 100 let source: CurrencyCode = .EUR let target: CurrencyCode = .USD session.convert(amountInCents: amountInCents, source: source, target: target, success: { convertedAmountInCents in // Process converted amount in cents. }, failure: { error in Macros.DLog(message: "Error while converting amount: \(error.localizedDescription)") })
Responses
Please find below an overview of the possible responses.
Response 200 - OKConvertAmount
The response contains the converted amount
Properties
|
|||
Property | Type | Required | Details |
---|---|---|---|
convertedAmount | integer | no | read close |
close
DescriptionConverted amount in cents
|
Response example
SDK: Swift
This scenario you will probably use the most
-
{ "convertedAmount" : 138 }
Response 400 - Bad requestErrorResponse
Properties
|
|||
Property | Type | Required | Details |
---|---|---|---|
errorId | string | yes | read close |
close
DescriptionUnique reference, for debugging purposes, of this error response
|
|||
array of object | yes | read close | |
close
DescriptionList of one or more errors
|
|||
object | no | read close | |
category | string | no | read close |
close
DescriptionCategory the error belongs to. The category should give an indication of the type of error you are dealing with.
Possible values:
|
|||
code | string | yes | read close |
close
DescriptionError code
|
|||
httpStatusCode | integer | no | read close |
close
DescriptionHTTP status code for this error that can be used to determine the type of error
|
|||
id | string | no | read close |
close
DescriptionID of the error. This is a short human-readable message that briefly describes the error.
|
|||
message | string | no | read close |
close
DescriptionHuman-readable error message that is not meant to be relayed to customer as it might tip off people who are trying to commit fraud
|
|||
propertyName | string | no | read close |
close
DescriptionReturned only if the error relates to a value that was missing or incorrect.
Contains a location path to the value as a JSonata query. Some common examples:
|
|||
requestId | string | no | read close |
close
DescriptionID of the request that can be used for debugging purposes
|
Response example
SDK: Swift
This scenario you will probably use the most
-
{ "errorId" : "15eabcd5-30b3-479b-ae03-67bb351c07e6-00000092", "errors" : [ { "code" : "20000000", "propertyName" : "bankAccountBban.accountNumber", "message" : "PARAMETER_NOT_FOUND_IN_REQUEST" } ] }