Using this api, payment status of a payment can be found
Through this API, a information of a specific payment can be found. After calling the Create Payment API, Query Payment api can be called anytime.
Endpoint
{base_url}/payment/checkStatus/{txnID}
{base_url} is the api endpoint (sandbox or live). {txnID} is the merchant's provided Transaction ID.
Request Header
Include the following request headers:
| Header | Description | Required |
|---|---|---|
| Content-Type | application/json | YES |
| X-APP-KEY | App key - Provided by EcommerzPay | YES |
| X-APP-SECRET | App Secret Key - Provided by EcommerzPay | YES |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| status | String | Request status (True or False) |
| statusMessage | String | Request status message |
| data | Array | Data related to payment. See below response |
Example Code
<?php
$curl = curl_init();
$appKey = "Your App Key";
$appSecret = "Your App Secret";
$txnID = "Merchant Transaction ID";
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.ecommerzpay.com/v1.0.2-beta/payment/checkStatus/".$txnID,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"accept: application/json",
"x-app-key: ".$appKey,
"x-app-secret: ".$appSecret
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Success Response
{
"status": true,
"statusMessage": "Transaction data found",
"data": {
"pg_txnid": "EP874574578",
"merchant_txnid": "SDGS4744SDSFF",
"amount": "500.00",
"charge": "10.00",
"method": "nagad",
"method_txnid": "71FLE0AJ",
"meta_data": null,
"created_at": "2024-02-14 17:48:37",
"paid_at": "2024-02-15 10:19:03",
"status": "success"
}
}
Error Response
{
"status": false,
"statusMessage": "Transaction data not found",
}
