Skip to content
logo
  • Products
    • Amwal Checkout
    • Merchant App
    • Merchant Control Panel
  • Pricing
  • Developers
  • About us
  • Contact Us
Sign In
BA Booking

BA Booking

2
  • BA Booking overview
  • BA Booking Installation
amwalpay woocommerce

Woocommerce

2
  • Overview
  • Woocommerce Installation
CS-Cart

CS Cart

2
  • CS-Cart Overview
  • CS CART Installation
Shopify

Shopify

2
  • Shopify Overview
  • Shopify Installation
odoo

Odoo

2
  • Odoo Overview
  • Odoo Installation
whmcs

WHMCS

2
  • WHMCS Overview
  • WHMCS Installation
Magento

Magento

2
  • Magento 2 Overview
  • Magento Installation
Opencart

Opencart

2
  • OpenCart Overview
  • Opencart Installtion
ZenCart

ZenCart

2
  • ZenCart Overview
  • Zencart Installation
Drupal

Drupal

2
  • Drupal Overview
  • Drupal Installation
PrestaShop

PrestaShop

2
  • PrestaShop Overview
  • PrestaShop Installation
Contact Form 7

Contact Form 7

2
  • Contact Form 7 Overview
  • Contact Form 7 Installation
Joomla

Joomla

2
  • Joomla Overview
  • Joomla Installation
AMWAL INTEGRATED PAYMENT LINK

Amwal Integrated Payment Link

3
  • Introduction
  • Example Code
  • Response and Hash Generation
Android SDk

Native Android SDK

3
  • Pre Requisites
  • Implementation
  • SecureHash Calculation
ios SDk

Native iOS SDK

3
  • Pre Requisites
  • Implementation
  • SecureHash Calculation
React SDk

React Native SDK

2
  • Installation
  • Configuration

AmwalPay Laravel Package

2
  • Installation
  • Configuration

SMARTBOX

3
  • Pre Requisites
  • Implementation
  • SecureHash Calculation
View Categories
  • Home
  • Developer | Amwalpay
  • Amwal Integrated Payment Link
  • Example Code

Example Code

Here are some sample code snippets that demonstrate how to calculate the secure hash in different programming languages.

function calcHash(obj: any, secret: string) {
try {
let objSorted = Object.keys(obj)
.sort()
.reduce(
(acc, key) => ({
...acc,
[key]: obj[key],
}),
{},
);
let dataPreparedForHashing = Object.entries(objSorted)
.map(([key, value]) => `${key}=${value}`)
.join('&');
// console.log(dataPreparedForHashing) should be like this
amount=0.111&billerRefNumber=&currency=512&emailNotificationV
alue=test@amwalpay.com&expireDateTime=&maxNumberOfPayment=100&merchantI
d=7921&notificationMethod=1&payerName=Amr&paymentMethod=9&paymentViewTy
pe=1&redirectUrl=&terminalId=221143

const hmac = crypto.createHmac('sha256', Buffer.from(secret, 'hex'));
const hashValue =hmac.update(dataPreparedForHashing, 'utf8').digest('hex');
return hashValue.toUpperCase();
}
catch (error)
{
return '';
}
}
let hash = calcHash(paramsObj, "YOUR_SECRET_KEY")

PHP Example #

<?php
 function encryptWithSHA256($input, $hexKey) {
 // Convert the hex key to binary
 $binaryKey = hex2bin($hexKey);
 // Calculate the SHA-256 hash using hash_hmac
 $hash = hash_hmac('sha256', $input, $binaryKey);
 return $hash;
}
 // Provided input text
$inputText="amount=0.111&billerRefNumber=&currency=512&emailNotificationV
alue=test@amwalpay.com&expireDateTime=&maxNumberOfPayment=100&merchantId=7921&notificationMethod
=1&payerName=Amr&paymentMethod=9&paymentViewType=1&redirectUrl=&terminalId=221143";
 // Provided hex key
 $hexKey =
"9FFA1F36D6E8A136482DF921E856709226DE5A974DB2673F84DB79DA788F7E19";
 // Calculate SHA-256 hash
 $result = encryptWithSHA256($inputText, $hexKey);
 ?>

Verification By Amwal #

  • Amwal Payment Gateway receives the data and hash.
  • The system verifies the authenticity of the request by regenerating the SHA-256 hash using the received data and the merchant’s stored secure key.
  • If the calculated hash matches the received hash, the transaction is considered secure and processed further.
Updated on August 24, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest
IntroductionResponse and Hash Generation
Table of Contents
  • PHP Example
  • Verification By Amwal

Secure. Seamless – Powering Payments for Every Business.

Sign Up
Support

4th Floor, Majan Tower Building
North Al Ghubrah, P.O. Box 233, P.C 118
Muscat, Sultanate of Oman

: support@amwal-pay.com

📞 : +96824121845

Resources
  • Developers
  • Careers
Company
  • About us
  • Contact Us
  • Contact Sales
  • Partners

2025 © AmwalPay. All Rights Reserved.

  • Terms & Conditions
  • Privacy Policy