Swap API
Last updated
Last updated
Give merchants the ability to swap funds between their wallets via API using our internal Klasha rates.
You can swap money in three easy steps:
Generate a bearer token
Generate a quote for the swap
Confirm swap
Encryption Algorithm can be gotten
Generate a bearer token
Using the Token endpoint on the Postman collection, the token can be obtained from the headers under the header name: token
POST
{{env_url}}
/auth/account/v2/login
username*
username
password*
password
Generate a quote
POST
{{env_url}}
/wallet/swap/generate/quote
Make a POST call to the Create Quote API to generate your quote. See an example of the payload you need to encrypt and send in order to generate your quote.
You’d need to pass, as header the x-auth-token
. This can be obtained from your merchant dashboard → Settings → Generate API keys → Merchant public key.
Authorization
Bearer {{token}}
x-auth-token
MERCHANT PUBLIC KEY
sourceCurrency*
String
NGN
destinationCurrency*
String
USD
destinationAmount*
1000.00
Confirm swap
POST
{{env_url}}
/wallet/swap/initiate
Make a POST call to the Confirm swap API to convert your quote into wallet swap transaction.
See an example of the payload you need to encrypt and send in order to generate your quote.
You’d need to pass, as header the x-auth-token
. This can be obtained from your merchant dashboard → Settings → Generate API keys → Merchant public key.
Authorization
Bearer {{token}}
x-auth-token
MERCHANT PUBLIC KEY
quoteToken*
String
97f20109-54e8-4861-ba12-0ea7d32351e9
Fetch all your payments
GET
{{env_url}}
/wallet/swap/fetch/by/reference/
{{transactionReference}}
Make a GET call to the Fetch by swap reference to retrieve a swap transaction.
You’d need to pass the transactionReference
you obtained when you initiated the swap, as a path variable.
You’d need to pass, as header the x-auth-token
. This can be obtained from your merchant dashboard → Settings → Generate API keys → Merchant public key.
Authorization
Bearer {{token}}
x-auth-token
MERCHANT PUBLIC KEY
Fetch a single payment by quote token
GET
{{env_url}}
/wallet/swap/fetch/by/token/
{{quoteToken}}
Make a GET call to the Fetch by token API to retrieve all your previously initiated quoted swaps.
You’d need to pass the quoteToken
you obtained when you initiated the swap, as a path variable.
You’d need to pass, as header the x-auth-token
. This can be obtained from your merchant dashboard → Settings → Generate API keys → Merchant public key.
Authorization
Bearer {{token}}
x-auth-token
MERCHANT PUBLIC KEY
Quote expiry logic
After you proceeded generating your quote, you can now convert that quote to confirm a swap transactions.
The confirmation would be successful if the quote is NOT expired.
A quote does not expire because of time but just if the rate in our system changed.
In case you try to initiate a payment with an expired quote, you’d have a Bad Request response with the the following body:
The encrypted JSON body for the request can be found in the Postman as well as other APIs.
The encrypted JSON body for the request can be found in the Postman as well as other APIs