Get Payment Status API
Pull information about your transactions whenever needed.
FawryPay delivers the Get Payment Status API as a responsive API for merchants who wishes to pull the status of their transactions whenever needed. Our valued merchants can use Get Payment Status API to retrieve the payment status for the charge request, usingGET method.
FawryPay Sample GET Request:
A sample GET where you can pull your transaction status updates whenever needed is provided below.
HTTP GET Parameters
Detailed description of the parameters that you need to incorporate into you GET request are given in the table below.
Parameter | type | Description | example |
---|---|---|---|
merchantCode | String |
The merchant code provided by FawryPay team during the account setup. | is0N+YQzlE4== |
merchantRefNumber | String |
The merchant reference number for the required order. | 9990076204 |
signature | String |
The request signature it contains the SHA-256 digest value for merchantCode + merchnatRefNumber + secureKey | a5701a2e1e865bf863f0c781829f709ea…. |
Example API Calls
An example call of get payment status API is given below.
function FawryPayGetPaymentStatus(transaction_data) {
const PaymentData = {
merchantCode: transaction_data.merchantCode,
merchantRefNumber: transaction_data.merchantRefNumber,
signature: transaction_data.signature
};
// Use fetch to send the Payment Data to FawryPay Get Payment status API.
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
const response = await fetch('https://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(PaymentData),
});
// Return and display the result of the charge.
return response.json();
}
$merchantCode = '1tSa6uxz2nRlhbmxHHde5A==';
$merchantRefNumber = '99900642041';
$merchant_sec_key = '259af31fc2f74453b3a55739b21ae9ef'; // For the sake of demonstration
$signature = hash('sha256' , $merchantCode . $merchantRefNumber . $merchant_sec_key);
$httpClient = new \GuzzleHttp\Client(); // guzzle 6.3
$response = $httpClient->request('GET', 'https://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status', [
'query' => [
'merchantCode' => $merchantCode,
'merchantRefNumber' => $merchantRefNumber,
'signature' => $signature
]
]);
$response = json_decode($response->getBody()->getContents(), true);
$paymentStatus = $response['payment_status']; // get response values
# importing the requests library
import requests
# importing Hash Library
import hashlib
# FawryPay Get Payment Status api-endpoint
URL = "https://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status"
# Payment Data
merchantCode = "1tSa6uxz2nRbgY+b+cZGyA=="
merchantRefNumber = "99900642041"
merchant_sec_key = "259af31fc2f74453b3a55739b21ae9ef"
signature = hashlib.sha256(merchantCode + merchantRefNumber + merchant_sec_key).hexdigest()
# defining a params dict for the parameters to be sent to the API
PaymentData = {'merchantCode':merchantCode,'merchantRefNumber':merchantRefNumber,'signature':signature}
# sending get request and saving the response as response object
status_request = requests.get(url = URL, params = PaymentData)
# extracting data in json format
status_response = status_request.json()
function FawryPayGetPaymentStatus() {
let merchantCode = "1tSa6uxz2nRbgY+b+cZGyA==";
let merchantRefNumber = "99900642041";
let merchant_sec_key = "259af31fc2f74453b3a55739b21ae9ef";
let signature_body = merchantCode.concat(merchantRefNumber,merchant_sec_key);
let sha256 = new jsSHA('SHA-256', 'TEXT');
sha256.update(signature_body);
let hash_signature = sha256.getHash("HEX");
axios.get('https://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status', {
merchantCode: merchantCode,
merchantRefNumber: merchantRefNumber,
signature: hash_signature
})
.then(response => {
// Get Response Contents
let type = response.data.type;
let paymentStatus = response.data.paymentStatus;
//
})
.catch(error => {
console.log(error.response.data)
})
}
$ curl https://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status \
-d merchantCode = 1tSa6uxz2nRbgY+b+cZGyA== \
-d merchantRefNumber = 99900642041 \
-d signature = 3f527d0209f4fa5e370caf46f66597c6a7c04580c827ca1f29927ec0d9215131 \
-X GET
URL url = new URL ("https://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Content-Type", "application/json; utf-8");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
String jsonInputString = "{
"merchantCode": "1tSa6uxz2nRbgY+b+cZGyA==",
"merchantRefNumber": "99900642041",
"signature": "3f527d0209f4fa5e370caf46f66597c6a7c04580c827ca1f29927ec0d9215131"
}";
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 FawryPayRequest
{
public class Program
{
static void Main(string[] args)
{
PostJson("https://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status", new fawrypay_request
{
merchantCode = "1tSa6uxz2nRbgY+b+cZGyA==",
merchantRefNumber = "99900642041",
signature = "3f527d0209f4fa5e370caf46f66597c6a7c04580c827ca1f29927ec0d9215131"
});
}
private static void PostJson(string uri, fawrypay_request postParameters)
{
string postData = JsonConvert.SerializeObject(postParameters);
byte[] bytes = Encoding.UTF8.GetBytes(postData);
var httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
httpWebRequest.Method = "GET";
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 fawrypay_request
{
public string merchantCode { get; set; }
public string merchantRefNumber { get; set; }
public string signature { get; set; }
}
}
Regardless of the choice of your preferred language, any of the code snippets above should produce a GET request containing the following JSON object in the request header:
{
"merchantCode":"dJWmdV+lPIE=",
"merchantRefNumber":"99662223332490123",
"signature":"67a3266b15ddbb9ce7a1eb8fa5c4f928defac59bc4f528e69f496f8e12fe4f4e"
}
FawryPay Sample Response:
Whenever you call FawryPay get payment status API, you may expect a response in the form of JSON object which contains all your up-to-date transaction information.
Sample Successful PAYATFAWRY Response
Sample Successful CARD Response
Sample Error Response
Response Parameters Description
Parameter | type | Description | example |
---|---|---|---|
type | String |
Specific type of the response. | PaymentStatusResponse |
referenceNumber | String |
The reference number of the order on merchant's system | 100162801 |
merchantRefNumber | String |
The reference number of the order on FawryPay system which is displayed to the customer and used during the payment | 99900642041 |
paymentAmount | Decimal |
The amount value received from merchant to be paid by the customer, the merchant can use it to verify that the customer has paid the required amount to enable the service to the customer. | 350.75 |
paymentDate | Integer |
Payment date | 1514747471138 |
expirationTime | Integer |
Payment Time | 151654747114 |
paymentStatus | String |
The updated status of your transaction | NEW, PAID, CANCELED, DELIVERED, REFUNDED, EXPIRED |
paymentMethod | String |
The payment method used for the subject transaction | PAYATFAWRY, CARD |
statusCode | Integer |
The response status code | 200 |
statusDescription | String |
Exact description of the status of FawryPay response. | Operation done successfully Wrong Signature |
signature | String |
SHA-256 digested message for the following concatenated string [referenceNumber + merchantRefNumber + statusCode + expirationTime + paymentAmount + paymentMethod + paymentStatus + paymentDate (if exist) + secureKey] | "b0ef178e2f06b215b18cfc7d82fb5d1 f7b95dfcc91e33f8a6ce1e1251fdd04ec" |
GEThttps://atfawry.fawrystaging.com/ECommerceWeb/Fawry/payments/status
Response
// API Response Data Should Appear here
// This is a sample successful Response
{
"type":"PaymentStatusResponse",
"referenceNumber":"100162801",
"merchantRefNumber":"99900642041",
"paymentAmount":20,
"paymentDate":1514747471138,
"expirationTime":151654747115,
"paymentStatus":"PAID",
"paymentMethod":"PAYATFAWRY",
"statusCode":200,
"statusDescription":"Operation done successfully"
}
Next steps
Was this page helpful?
Thank you for helping improve FawryPay's documentation. If you need help or have any questions, please consider contacting support.