This API will receive a payment creation request with necessary information.
Introduction
The eStorePay 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:
Payment Panel
Request Headers
Include the following request headers:
Header Name | Value |
---|---|
Content-Type | "application/json" |
Accept | "application/json" |
ESP-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 |
metadata | Mandatory | JSON object | A JSON object for additional project-specific data. |
redirect_url | Mandatory | string | Base URL of the merchant's platform. eStorePay will generate separate callback URLs for success, failure, and canceled transactions based on this URL. |
cancel_url | Mandatory | string | URL for canceled transaction notifications. |
webhook_url | Mandatory | string | IPN callback URL for manual data submission from the admin dashboard. |
Success Response Parameters
Property | Type | Description |
---|---|---|
status | string | 1 |
paymentID | string | Payment ID |
payment_url | string | The URL of eStorePay where the customer should be forwarded to complete his payment. Example: https://pay.yorudomain.com/payment/?ref=12345678 |
Error Response Parameters
Property | Type | Description |
---|---|---|
status | string | 0 |
message | string | The message associated with the status, explains the status. |
Sample Request
<?php
$baseURL = 'https://pay.yourdomain.com/api/';
$apiKEY = '2353452345235235';
$fields = [
'full_name' => 'John Doe',
'email' => 'userEmail@gmail.com',
'amount' => '100',
'metadata' => [
'user_id' => '10',
'order_id' => '50'
],
'redirect_url' => 'https://your-domain.com/success.php',
'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 . "create",
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 => [
"ESP-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://pay.yourdomain.com/api/create \
--header 'ESP-API-KEY: 23452352352353' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"full_name": "John Doe",
"email": "userEmail@gmail.com",
"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://pay.yourdomain.com/api/create',
headers: {
accept: 'application/json',
'ESP-API-KEY': '2523452345235234',
'content-type': 'application/json'
},
data: {
full_name: 'John Doe',
email: 'userEmail@gmail.com',
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://pay.yourdomain.com/api/create"
payload = {
"full_name": "John Doe",
"email": "userEmail@gmail.com",
"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",
"ESP-API-KEY": "43523523452345234",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Sample Response
{
"status": "1",
"paymentID": "1241241234124123",
"payment_url": "https://pay.yourdomain.com/payment/?ref=53245234532523"
}