This API will receive a payment creation request with necessary information.
Introduction
The AstimPay Create Charge API enables you to receive payment creation requests and initiate payments. This documentation offers comprehensive guidance on utilizing this API effectively.
Request URL
To create a payment request, use the following API endpoint:
{base_URL}/api/checkout-v1
Where {base_URL} is the location of your AstimPay installation, such as https://pay.your-domain.com.
Request Headers
Include the following request headers:
Header Name | Value |
---|---|
Content-Type | "application/json" |
Accept | "application/json" |
API-KEY | Collect API KEY From Dashboard |
Request Parameters
The API expects the following parameters in the request:
Property | Presence | Type | Description |
---|---|---|---|
full_name | Mandatory | string | User's full name |
Mandatory | string | User's email | |
amount | Mandatory | string | Payment amount |
invoice_id | optional | string | External transaction_id or invoice_id |
metadata | Mandatory | JSON object | A JSON object for additional project-specific data. |
redirect_url | Mandatory | string | Base URL of the merchant's platform. AstimPay will generate separate callback URLs for success, failure, and canceled transactions based on this URL. |
return_type | Optional | string | "POST" (default) or "GET." Specifies the return URL data format. In "POST" format, AstimPay sends the invoice_id with a POST request. In "GET" format, the invoice_id is sent as a query parameter. |
cancel_url | Mandatory | string | URL for canceled transaction notifications. |
webhook_url | Optional | string | IPN callback URL for manual data submission from the admin dashboard. |
Success Response Parameters
Property | Type | Description |
---|---|---|
status | bool | TRUE |
message | string | The message associated with the status, explaining the status. |
payment_url | string | The URL of AstimPay where the customer should be forwarded to complete his payment. Example: https://sandbox.astimpay.com/payment/64c0d6077f0be49801bdd142a05518193574d31d |
Error Response Parameters
Property | Type | Description |
---|---|---|
status | bool | FALSE |
message | string | The message associated with the status, explains the status. |
Sample Request
<?php
$baseURL = 'https://sandbox.astimpay.com/';
$apiKEY = '4a59f023cbc02521417f21a0add4e028febb2ca8';
$fields = [
'full_name' => 'John Doe',
'email' => '[email protected]',
'amount' => '100',
'invoice_id' => 'f993Y00ksStYwX2ElBT',
'metadata' => [
'user_id' => '10',
'order_id' => '50'
],
'redirect_url' => 'https://your-domain.com/success.php',
'return_type' => 'GET',
'cancel_url' => 'https://your-domain.com/cancel.php',
'webhook_url' => 'https://your-domain.com/ipn.php'
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $baseURL . "api/checkout-v1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($fields),
CURLOPT_HTTPHEADER => [
"API-KEY: " . $apiKEY,
"accept: application/json",
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request POST \
--url https://sandbox.astimpay.com/api/checkout-v1 \
--header 'API-KEY: 4a59f023cbc02521417f21a0add4e028febb2ca8' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"full_name": "John Doe",
"email": "[email protected]",
"amount": "100",
"metadata": {
"user_id": "10",
"order_id": "50"
},
"redirect_url": "https://your-domain.com/success",
"cancel_url": "https://your-domain.com/cancel",
"webhook_url": "https://your-domain.com/ipn"
}
'
const axios = require('axios');
const options = {
method: 'POST',
url: 'https://sandbox.astimpay.com/api/checkout-v1',
headers: {
accept: 'application/json',
'API-KEY': '4a59f023cbc02521417f21a0add4e028febb2ca8',
'content-type': 'application/json'
},
data: {
full_name: 'John Doe',
email: '[email protected]',
amount: '100',
metadata: {user_id: '10', order_id: '50'},
redirect_url: 'https://your-domain.com/success',
cancel_url: 'https://your-domain.com/cancel',
webhook_url: 'https://your-domain.com/ipn'
}
};
axios
.request(options)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.error(error);
});
import requests
url = "https://sandbox.astimpay.com/api/checkout-v1"
payload = {
"full_name": "John Doe",
"email": "[email protected]",
"amount": "100",
"metadata": {
"user_id": "10",
"order_id": "50"
},
"redirect_url": "https://your-domain.com/success",
"cancel_url": "https://your-domain.com/cancel",
"webhook_url": "https://your-domain.com/ipn"
}
headers = {
"accept": "application/json",
"API-KEY": "4a59f023cbc02521417f21a0add4e028febb2ca8",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Sample Response
{
"status": true,
"message": "Payment Url",
"payment_url": "https://sandbox.astimpay.com/payment/a5s9f023cbc02521417f21a0add4e028febb2ca8"
}