generateAuthHash static method
Generate authentication hash for checkout/session token requests
Formula (as per Mobibox documentation): var to_md5 = order_number + order_amount + order_currency + order_description + merchant_pass; var hash = CryptoJS.SHA1(CryptoJS.MD5(to_md5.toUpperCase()).toString()); var result = CryptoJS.enc.Hex.stringify(hash);
This means: SHA1(MD5(toUpperCase).toString()) where MD5 is converted to hex string first
Implementation
static String generateAuthHash({
required String orderNumber,
required String orderAmount,
required String orderCurrency,
required String orderDescription,
required String password,
}) {
// Concatenate: order_number + order_amount + order_currency + order_description + merchant_pass
final concatenated = '$orderNumber$orderAmount$orderCurrency$orderDescription$password';
// Convert to uppercase
final upperCase = concatenated.toUpperCase();
// Calculate MD5 and convert to hex string
final md5Hash = md5.convert(utf8.encode(upperCase));
final md5HexString = md5Hash.toString();
// Calculate SHA1 of the MD5 hex string
final sha1Hash = sha1.convert(utf8.encode(md5HexString));
// Return SHA1 as hex string
return sha1Hash.toString();
}