Create purchase
This endpoint will allow you to create a Purchase (Pay-in). In order to complete a Purchase, it must first be created, then the user must be directed to the Airtm website to confirm/checkout the Purchase, at which time they will be redirected to a URL of your choosing. See “Usage” below.
We will redirect the user to either confirmation_uri or cancel_uri with code as query parameter so you can process the Purchase as being either confirmed or cancelled.
Usage
-
Create a Purchase via an HTTP POST.
-
Extract the id from the response, and redirect user to: https://<API Host>/checkout/:id User will be redirected for authentication as necessary.
-
User will confirm or cancel purchase from Airtm’s website.
-
If confirmed, money will be transferred from user’s Airtm wallet, to partner's Airtm wallet, and redirected to the provided confirmation_uri. If canceled, no money will be transferred, and the user will be redirected to the provided cancel_uri.
Upon confirmation, or cancellation the purchase will be considered completed, and the URL residing at /checkout/:id will no longer function. Therefore, if you wish to complete an identical Purchase, you will need to create a new Purchase, and be provisioned a new id for that Purchase.
The confirmation_uri attribute should not be used for transaction completeness verification, if the URI was requested, it doesn't mean the transaction was completed successfully. Use webhooks to be notified when the purchase is completed, either if it was confirmed, canceled or failed, or check the transaction status using GET /operations/:id before any external movement.
[!tip] The way to emit a purchase refund is to create a payout from your Airtm Partner account and then commit it, this will move money from your Airtm account to your user's Airtm account.
Request
- Base URLhttps://payments.air-pay.io
- AuthHTTP basic
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"code": "ExternalIdentifier01",
"description": "Test purchase",
"cancel_uri": "https://your.site/cancel",
"confirmation_uri": "https://your.site/confirm",
"failure_uri": "https://your.site/failure",
"amount": 15,
"items": [
{
"description": "test item 2",
"amount": 3,
"quantity": 1
}
]
}Response
OK
Example response
{
"id": "5201de5f-03e6-43e1-ba36-bebaf3f429f6",
"status": "created",
"amount": "15.00",
"description": "Purchase test",
"confirmation_uri": "https://your.site/confirm",
"cancel_uri": "https://your.site/cancel",
"code": "ExternalIdentifier01",
"created_at": "2022-05-25T00:34:30.641Z",
"updated_at": "2022-05-25T00:34:30.641Z",
"operation_type": "purchase",
"callback_uri": "https://your.site/callback"
}Changes
No recorded changes to this operation across all 1 revision of this API.