Query Payment

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:

HeaderDescriptionRequired
Content-Typeapplication/jsonYES
X-APP-KEYApp key - Provided by EcommerzPayYES
X-APP-SECRETApp Secret Key - Provided by EcommerzPayYES

Response Parameters

ParameterTypeDescription
statusStringRequest status (True or False)
statusMessageStringRequest status message
dataArrayData 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",
}