Inquiry
- 20 Jan 2022
- 2 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Inquiry
- Updated on 20 Jan 2022
- 2 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Request message
Input request parameter | Description |
Merchant Authentication Token | Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy |
MessageID | 2 |
MerchantID | STSPayOneM |
OriginalTransactionID | 12345678901234567890 |
Version | 1.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 parameter | Description |
Merchant Authentication Token | Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy |
Response.MessageID | 2 |
Response.TransactionID | 12345678901234567890 |
Response.StatusCode | 00000 |
Response.StatusDescription | Payment processed successfully |
Response.GatewayStatusCode | 0000 |
Response.GatewayStatusDescription | Sample Gateway Description |
Response.GatewayName | TestGateway |
Response.Amount | 100 |
Response.ApprovalCode | 654321 |
Response.CardExpiryDate | 0416 |
Response.CardHolderName | Card Holder |
Response.CurrencyISOCode | 400 |
Response.CardNumber | 400555******0001 |
Response.Token | 17b61316feafe09feb806ce33cdbfc85aed1b4173ed604f8 fd5fa3cf72a02e27 |
Response.MerchantID | STSPayOneM |
Response.RRN | 123456 |
Response.MessageStatus | 00000 |
Response.ReversalStatus | 1 |
Response.AuthorizedCurrencyISOCode | 400 |
Response.AuthorizedAmount | 100 |
Parameters Order | |
Response.Amount, Response.ApprovalCode, Response.AuthorizedAmount, Response.AuthorizedCurrencyISOCode ,Response.CardExpiryDate, Note: The parameters are ordered alphabetically in the secure hash. | |
The input to the Secure Hash generation routine | |
Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy1006543211004000416Card | |
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.