Refund
- 20 Jan 2022
- 2 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Refund
- 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 | 4 |
MerchantID | STSPayOneM |
TransactionID | 12345678901234567891 |
OriginalTransactionID | 12345678901234567890 |
Amount | 100 |
CurrencyISOCode | 400 |
Version | 1.0 |
Parameters Order | |
Amount, CurrencyISOCode, MerchantID, MessageID, OriginalTransactionID, TransactionID, Version Note: The parameters are ordered alphabetically in the secure hash. | |
The input to the Secure Hash generation routine | |
Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy100400STSPayOneM4123456789012345678901234 | |
Output | |
662e268fa5a3bcb255cab69261d6a950e3a225589d71b029ff6b6eafcb6c313e |
Response message
Input response parameter | Description |
Merchant Authentication Token | Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy |
Response.StatusCode | 0000 |
Response.OriginalTransactionID | 12345678901234567890 |
Response.TransactionID | 12345678901234567891 |
Response.Amount | 100 |
Response.CurrencyISOCode | 400 |
Response.StatusDescription | Payment processed successfully |
Response.MerchantID | STSPayOneM |
Response.MessageID | 4 |
Response.RRN | 123456 |
Parameters Order | |
Response.Amount, Response.CurrencyISOCode, Response.MerchantID, Response.MessageID, Response.OriginalTransactionID, Response.RRN, Note: The parameters are ordered alphabetically in the secure hash. | |
The input to the Secure Hash generation routine | |
Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy100400STSPayOneM4123456789012345678901234 | |
Output | |
ef85cce7db5b4e0da8b1906781f06b522978223e7597a41abdbd818c0047d018 |
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", "4");
parameters.put("TransactionID", transactionId);
parameters.put("OriginalTransactionID", "1440954863817");
parameters.put("MerchantID", "ANBRedirectM");
parameters.put("Amount", "2000");
parameters.put("CurrencyISOCode", "840");
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> dictionary = new SortedDictionary<String, S
tring>(StringComparer.Ordinal);
4.
5. long transactionId = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
6. // fill required parameters
7. dictionary.Add("MessageID", "4");
8. dictionary.Add("TransactionID", transactionId.ToString());
9. dictionary.Add("OriginalTransactionID", "1440954863817");
10. dictionary.Add("MerchantID", "ANBRedirectM");
11. dictionary.Add("Amount", "2000");
12. dictionary.Add("CurrencyISOCode", "840");
13. dictionary.Add("Version", "1.0");
14.
15. //Create an Ordered String of The Parameters Dictionary with Secret Key
16. StringBuilder stringBuilder = new StringBuilder();
17. stringBuilder.Append(SECRET_KEY);
18.
19. foreach (KeyValuePair<string, string> kv in dictionary)
20. {
21. stringBuilder.Append(kv.Value);
22. }
23. Console.WriteLine("ordered string: " + stringBuilder.ToString().ToString());
24. // Generate SecureHash with SHA256
25. SHA256 sha256;
26. byte[] bytes, hash;
27. StringBuilder secureHash;
28.
29. bytes = Encoding.UTF8.GetBytes(stringBuilder.ToString().ToString());
30.
31. sha256 = SHA256Managed.Create();
32. hash = sha256.ComputeHash(bytes);
33. secureHash = new StringBuilder(hash.Length * 2);
34.
35. Console.WriteLine("Secure Hash: " + stringBuilder.ToString().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. $transactionId = (int)(microtime(true)*1000); //time in milleseconds
5.
6. // fill required parameters
7. $parameters["MessageID"] = "4";
8. $parameters["TransactionID"] = $transactionId;
9. $parameters["OriginalTransactionID"] = "1440954863817";
10. $parameters["MerchantID"] = "ANBRedirectM";
11. $parameters["Amount"] = "2000";
12. $parameters["CurrencyISOCode"] = "840";
13. $parameters["Version"] = "1.0";
14.
15. //sort parameters alphabatically
16. ksort($parameters);
17. //Create an Ordered String of The Parameters Map with Secret Key
18.
19. $orderedString = $SECRET_KEY;
20. foreach ($parameters as $param) {
21. $orderedString .= $param;
22. }
23. echo "orderdString ". $orderedString;
24.
25. // Generate SecureHash with SHA256
26. $secureHash = hash('sha256', $orderedString, false);
27.