Check Transaction Status
You can use the transaction status API in order to know the transaction status and details. You should be in the development stage, you must make a call to the transaction status API using POST method at the following staging endpoint API point URL
http://aman-checkout-backend.mimocodes.com/api/v1/check-payment-status
Get Transaction Status API HTTP POST Parameters
Your request should contain:- Header:
- Bearer PublicKey: Your Aman merchant account Public Key.
- merchant ID: Your Aman account merchant ID.
- Json object containing the payment information:
- How To Create Hash Key To Send It With The Request:
Authorization: Bearer "PublicKey"
merchantReference : 256621052822799
{
"reference":"Your transaction reference id",
"currency":"Transaction currency",
"hash":"Hash key for transaction reference"
}
Key : Merchant Key
{
generateHMACForRefernce($data, $key)
{
$txt = sprintf(
"{TransactionReference:\"%s\",Currency:\"%s\"}",
$data['transactionReference'],
$data['currency'],
);
return hash_hmac('sha3-512', ($txt), $key);
}
}
The table below provides a detailed description of the parameters you must include in your POST request.
Below is an example of a transaction with reference 583850000.
function Cashier(transaction_data) {
const PaymentData = {
'reference'=> "583850000",
'currency' => "EGP",
'hash' => 'aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71' ,
};
const response = await fetch('http://aman-checkout-backend.mimocodes.com/api/v1/check-payment-status', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization' : 'Bearer AMAN9958c094204f3469fe2f120dffbfa8309bccd507f59',
'MerchantId' : '256619092316009'
},
body: JSON.stringify(PaymentData),
});
// Return and display the result of the charge.
return response.json();
}
$data = [
'reference'=> "583850000",
'currency' => "EGP",
'hash' => "aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71" ,
$httpClient = new \GuzzleHttp\Client(); // guzzle 6.3
$response = $httpClient->request('POST', 'http://aman-checkout-backend.mimocodes.com/api/v1/check-payment-status', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer AMAN9958c094204f3469fe2f120dffbfa8309bccd507f59',
'MerchantId' => '256619092316009'
],
'body' => json_encode( $data , true)
]);
$response = json_decode($response->getBody()->getContents(), true);
# importing the requests library
import requests
# CashierAPI Endpoint
URL = "http://aman-checkout-backend.mimocodes.com/api/v1/check-payment-status"
# defining a params dict for the parameters to be sent to the API
PaymentData = {
'reference'=> "583850000",
'currency' => "EGP",
'hash' => "aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71" ,
}
# Prepare Headers
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization': 'Bearer AMAN9958c094204f3469fe2f120dffbfa8309bccd507f59',
'MerchantId' : '256619092316009'
}
# sending post request and saving the response as response object
status_request = requests.post(url = URL, params = json.dumps(PaymentData) , headers=headers)
# extracting data in json format
status_response = status_request.json()
function Cashier() {
axios.post('http://aman-checkout-backend.mimocodes.com/api/v1/check-payment-status', {
'reference'=> "583850000",
'currency' => "EGP",
'hash' => "aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71" ,
})
.then(response => {
// Get Response Contents
let type = response.data.type;
let paymentStatus = response.data.paymentStatus;
//
})
.catch(error => {
console.log(error.response.data)
})
}
$ curl http://aman-checkout-backend.mimocodes.com/api/v1 \
-H "content-type: application/json , Authorization: Bearer AMAN9958c094204f3469fe2f120dffbfa8309bccd507f59 , MerchantId: 256619092316009" \
-X POST \
-d "{
'reference'=> "583850000",
'currency' => "EGP",
'hash' => "aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71" ,
}"
URL url = new URL ("http://aman-checkout-backend.mimocodes.com/api/v1");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json; utf-8");
con.setRequestProperty("Authorization", "Bearer PublicKey");
con.setRequestProperty("MerchantId", "256619092316009");
con.setDoOutput(true);
String jsonInputString = "{
'reference'=> "583850000",
'currency' => "EGP",
'hash' => "aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71" ,
}
";
try(OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
try(BufferedReader br = new BufferedReader(
new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;
namespace OPayRequest
{
public class Program
{
static void Main(string[] args)
{
PostJson("http://aman-checkout-backend.mimocodes.com/api/v1/check-payment-status", new aman_request
{
'reference'=> "583850000",
'currency' => "EGP",
'hash' => "aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71"
}
private static void PostJson(string uri, aman_request postParameters)
{
string postData = JsonConvert.SerializeObject(postParameters);
byte[] bytes = Encoding.UTF8.GetBytes(postData);
var httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.ContentType = "text/json";
using (Stream requestStream = httpWebRequest.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Count());
}
var httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("GET failed. Received HTTP {0}", httpWebResponse.StatusCode);
throw new ApplicationException(message);
}
}
}
public class aman_request
{
public string reference { get; set; }
public string currency { get; set; }
public string hash { get; set; }
}
}
Signature is calculated using the concatenation of the PublicKey and Bearer prefix: Bearer {PublicKey}
Aman Transaction Status Response
Sample Response
the details included in the response you get when you call Aman Transaction Status Make a JSON object for the API.
Sample Aman Transaction Status API Response
{
"message": "successfully",
"data": {
"transactionReference": 583850000,
"orderReference": "cdfda0f0-6fa6-4a3e-ac9a-c84bdf799e07",
"merchantReference": 170790021118955,
"paymentMethod": "ReferenceCode",
"amount": "1000.00",
"currency": "EGP",
"status": "EXPIRED",
"createdAt": "2024-02-15 11:31:57",
"updatedAt": "2024-02-15 11:45:00",
"transactionType": "PayIn",
"transactionFees": "30.00",
"customerName": "ahmed",
"customerPhoneNumber": "01112006005",
"customerEmail": "ahmed@gmail.com",
"customerAddress": "maadi",
"hmac": "aa7bc1f7ef9d672f8ab70478cf95ab7f2cd2ad303c44f0621c7bdf145316ed28eb26f0b0d748f589e56ebd933596945fbb2b138a3d94e558ae6e80be366b0d71"
}
Response Parameters Description
Parameter | type | Description | |
---|---|---|---|
transactionReference | String |
Aman transaction number. | |
orderReference | String |
merchant order number. | |
merchantReference | String |
Aman merchant id. | |
paymentMethod | String |
Payment method (AmanCard ReferenceCode). | |
amount | String |
Transaction Amount in EGP. | |
currency | String |
Transaction currency. | |
status | String |
Transaction status (SUCCESS, Failed, etc...). | |
createdAt | String |
Transaction creation time. | |
updatedAt | String |
Transaction update time. | |
transactionType | String |
Transaction type. | |
transactionFees | String |
Transaction fees Amount in EGP. | |
customerName | String |
customer name. | |
customerPhoneNumber | String |
customer phone. | |
customerEmail | String |
customer email. | |
customerAddress | String |
customer address. | |
hmac | String |
HMAC SHA512 signature of the callback payload. Signed using your Secret Key. |
How To Create Hash Key To Check The Returned Response
{
generateHMAC($data, $key): string
{
$txt = sprintf(
"{Amount:\"%s\",Currency:\"%s\",TransactionReference:\"%s\",TransactionFees:\"%s\",TransactionType:\"%s\",OrderReference:\"%s\",PaymentMethod:\"%s\",Status:\"%s\",CreatedAt:\"%s\",UpdatedAt:\"%s\",MerchantReference:\"%s\",customerName:\"%s\",customerPhoneNumber:\"%s\",customerEmail:\"%s\",customerAddress:\"%s\"}",
$data['amount'],
$data['currency'],
$data['transactionReference'],
$data['transactionFees'],
$data['transactionType'],
$data['orderReference'],
$data['paymentMethod'],
$data['status'],
$data['createdAt'],
$data['updatedAt'],
$data['merchantReference'],
$data['customerName'],
$data['customerPhoneNumber'],
$data['customerEmail'],
$data['customerAddress']
);
return hash_hmac('sha3-512', ($txt), $key);
}
}
Error Handling
You get a response from Aman after making an API call, letting you know that your
request was received and handled. If the Aman API is successful, it should return
the status code 00
. If there is a payment processing error, you will
receive an error code along with a message explaining the error's cause. Below is an
example error response.
{
"code": "09",
"message": "Time out",
"data": null
}
You should construct some logic to handle any errors that a request or the system may return based on the HTTP status code of the response. Below is a list of potential error codes that you might encounter. A full list of all possible error codes can be found in the Error Codes section.
Error Code | Error Message |
---|---|
09 | Time out. |
90 | System failure. |
96 | Search order error, please try again later. |
99 | Request channel parameters are not valid. |