Inquiry
  • 20 Jan 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Inquiry

  • Dark
    Light
  • PDF

Article summary

Request message

Input request parameterDescription
Merchant Authentication TokenY2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy
MessageID 2
MerchantIDSTSPayOneM
OriginalTransactionID12345678901234567890
Version1.0
Parameters Order
MerchantID, MessageID, OriginalTransactionID, Version
Note: The parameters are ordered alphabetically in the secure hash.
The input to the Secure Hash generation routine 
Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2IySTSPayOneM2123456789012345678901.0
Output
74012d2538c65ab3b03a50f665828a99a6e5eb574049a9930495d062b4bfb9fc

Response message

Input response parameterDescription
Merchant Authentication TokenY2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy
Response.MessageID 2
Response.TransactionID12345678901234567890
Response.StatusCode00000
Response.StatusDescriptionPayment processed successfully
Response.GatewayStatusCode0000
Response.GatewayStatusDescriptionSample Gateway Description
Response.GatewayNameTestGateway
Response.Amount100
Response.ApprovalCode 654321
Response.CardExpiryDate0416
Response.CardHolderName Card Holder
Response.CurrencyISOCode400
Response.CardNumber400555******0001
Response.Token17b61316feafe09feb806ce33cdbfc85aed1b4173ed604f8
fd5fa3cf72a02e27
Response.MerchantIDSTSPayOneM
Response.RRN123456
Response.MessageStatus00000
Response.ReversalStatus1
Response.AuthorizedCurrencyISOCode400
Response.AuthorizedAmount100
Parameters Order
Response.Amount, Response.ApprovalCode, Response.AuthorizedAmount, 

Response.AuthorizedCurrencyISOCode ,Response.CardExpiryDate,
Response.CardHolderName, Response.CardNumber, Response.CurrencyISOCode,
Response.GatewayName, Response.GatewayStatusCode,
Response.GatewayStatusDescription, Response.MerchantID, Response.MessageID,
Response.MessageStatus, Response.RRN, Response.ReversalStatus, Response.StatusCode,
Response.StatusDescription, Response.TransactionID, Response.Token 

Note: The parameters are ordered alphabetically in the secure hash.
The input to the Secure Hash generation routine 

Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy1006543211004000416Card
Holder
400555******0001400TestGateway0000Sample+Gateway+DescriptionSTSPayOneM20
0000
123456100000Payment+processed+successfully1234567890123456789017b61316feafe
09feb806ce33cdbfc85aed1b4173ed604f8fd5fa3cf72a02e27
 

Output
d7cc3f1565b12e92caa9ad2da77cf5931f7c9f25c040d372d13a898e41d43b07

Sample Code (Java)

//Step 1: Generate Secure Hash 
String SECRET_KEY = "Y2FkMTdlOWZiMzJjMzY4ZGFkMzhkMWIz"; // Use Yours, Please Store Your 
Secret Key in safe Place (e.g. database) 
 
// put the parameters in a TreeMap to have the parameters to have them sorted 
alphabetically. 
Map <String,String> parameters = new TreeMap<String,String> (); 
 
String transactionId=String.valueOf(System.currentTimeMillis()); 
 
// fill required parameters 
parameters.put("MessageID", "2"); 
parameters.put("OriginalTransactionID", "1440954863817"); 
parameters.put("MerchantID", "ANBRedirectM"); 
parameters.put("Version", "1.0"); 
 
//Create an ordered String of The Parameters Map with Secret Key 
StringBuilder orderedString = new StringBuilder(); 
orderedString.append(SECRET_KEY); 
for (String treeMapKey : parameters.keySet()) { 
    orderedString.append(parameters.get(treeMapKey)); 
} 
 
System.out.println("orderdString "+orderedString); 
// Generate SecureHash with SHA256 
// Using DigestUtils from appache.commons.codes.jar Library 
String secureHash = new String(DigestUtils.sha256Hex(orderedString.toString()).getBytes()); 

Other Request Code (.Net /PHP)

Sample Code (.Net)

1.            String SECRET_KEY = "Y2FkMTdlOWZiMzJjMzY4ZGFkMzhkMWIz"; // Use Yours, 
Please Store Your Secret Key in safe Place (e.g.database) 
2.          // put the parameters in a SortedDictionary to have the parameters to have 
them sorted alphabetically. 
3.          SortedDictionary<string, string> parameters = new SortedDictionary<String, S
tring>(StringComparer.Ordinal); 
4.    
5.          // fill required parameters 
6.          parameters.Add("MessageID", "2"); 
7.          parameters.Add("OriginalTransactionID", "1440954863817"); 
8.          parameters.Add("MerchantID", "ANBRedirectM"); 
9.          parameters.Add("Version", "1.0"); 
10.    
11.   //Create an ordered String of The Parameters SortedDictionary with Secret Key 
12.    StringBuilder orderedString = new StringBuilder(); 
13.    orderedString.Append(SECRET_KEY); 
14.    foreach (KeyValuePair<string, string> kv in parameters) 
15.   { 
16.              orderedString.Append(kv.Value); 
17.          } 
18.          String orderTest = orderedString.ToString().ToString(); 
19.          Console.WriteLine("orderdString " + orderTest); 
20.    
21.          // Generate SecureHash with SHA256 
22.          SHA256 sha256; 
23.          byte[] bytes, hash; 
24.          string secureHash = string.Empty; 
25.    
26.          bytes = Encoding.UTF8.GetBytes(orderedString.ToString().ToString()); 
27.          sha256 = SHA256Managed.Create(); 
28.          hash = sha256.ComputeHash(bytes);         
29.          foreach (byte x in hash) 
30.          { 
31.              secureHash += String.Format("{0:x2}", x); 
32.          } 
33.    
34.          Console.WriteLine("Secure Hash: " + secureHash.ToString());  

Sample Code (PHP)

1.   $SECRET_KEY = "Y2FkMTdlOWZiMzJjMzY4ZGFkMzhkMWIz"; // Use Yours, Please Store Your 
Secret Key in safe Place(e.g. database) 
2.  // put the parameters in a array to have the parameters to have them sorted 
alphabetically via ksort. 
3.  $parameters = []; 
4.  // fill required parameters 
5.  $parameters['MessageID'] = "2"; 
6.  $parameters['OriginalTransactionID'] = "1440954863817"; 
7.  $parameters["MerchantID"] = "ANBRedirectM"; 
8.  $parameters["Version"] = "1.0"; 
9.    
10.  //Create an Ordered String of The Parameters array with Secret Key 
11.  //order parameters alphabatically using ksort 
12.  ksort($parameters); 
13.  $orderedString = $SECRET_KEY; 
14.  foreach($parameters as $param){ 
15.          $orderedString .= $param; 
16.  } 
17.  echo ("orderdString ". $orderedString); 
18.    
19.  // Generate SecureHash with SHA256 
20.  $secureHash = hash('sha256', $orderedString, false); 
21.    

What's Next