- 09 Mar 2022
- 2 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Redirect Payment
- Updated on 09 Mar 2022
- 2 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Request message
Input request parameter | Description |
Merchant Authentication Token | Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy |
MessageID | 1 |
TransactionID | 12345678901234567890 |
MerchantID | STSPayOneM |
Amount | 100 |
Language | En |
CurrencyISOCode | 400 |
PaymentDescription | Sample Payment Description |
ResponseBackURL | https://MerchatWebSite/PaymentResponse.do |
ThemeID | theme1 |
Channel | 0 |
Quantity | 1 |
Version | 1.0 |
Parameters Order | |
Amount, Channel, CurrencyISOCode, Language, MerchantID, MessageID, PaymentDescription, Quantity, ResponseBackURL, ThemeID, TransactionID, Version Note: The parameters are ordered alphabetically in the secure hash. | |
The input to the Secure Hash generation routine | |
Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy1000400EnSTSPayOneM1Sample+Payment+Descri | |
Output | |
ddf2b07b95a3d93cc1ba6cd38dc69dbc1cf36819aa0bf83f549c827f98e6a84f |
Response message
Input response parameter | Description |
Merchant Authentication Token | Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy |
Response.MessageID | 1 |
Response.TransactionID | 12345678901234567890 |
Response.StatusCode | 00000 |
Response.StatusDescription | Payment processed successfully |
Response.GatewayStatusCode | 0000 |
Response.GatewayName | TestGateway |
Response.GatewayStatusDescription | Sample Gateway Description |
Response.Amount | 100 |
Response.ApprovalCode | 654321 |
Response.CardExpiryDate | 0416 |
Response.CardHolderName | Card Holder |
Response.CurrencyISOCode | 400 |
Response.CardNumber | 400555******0001 |
Response.MerchantID | STSPayOneM |
Response.RRN | 123456 |
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 | |
6c4ef5c7365a15c88eee33cc0b90cd045b3bb548310107695f9e7d1ee71ce8f2 |
Sample Code (Java)
//Step 1: Generate Secure Hash
String SECRET_KEY = "Y2FkMTdlOWZiMzJjMzY4ZGFkMzhkMWIz"; // Use Yours, Please Store Your
Secret Key in safe Place (eg. 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("TransactionID", transactionId);
parameters.put("MerchantID", "ANBRedirectM");
parameters.put("Amount", "2000");
parameters.put("CurrencyISOCode", "840");
parameters.put("MessageID", "1");
parameters.put("Quantity", "1");
parameters.put("Channel", "0");
//fill some optional parameters
parameters.put("Language", "en");
parameters.put("ThemeID", "1000000001");
parameters.put("ResponseBackURL", "https://MerchantSite/RedirectPaymentResponsePage");// if
this url is configured for the merchant it's not required
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 Sample Code (.Net /PHP)
Sample Code (.Net)
1. //Step 1: Generate Secure Hash
2. String SECRET_KEY = "Y2FkMTdlOWZiMzJjMzY4ZGFkMzhkMWIz"; // Use Yours, Please Store
Your Secret Key in safe Place (eg.database)
3.
4. // put the parameters in a SortedDoctionary to have the parameters to have
them sorted alphabetically.
5. SortedDictionary<string, string> parameters = new SortedDictionary<String,
String>(StringComparer.Ordinal);
6.
7. //getting time in milliseconds
8.
9. Long transactionId = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
10.
11. // fill required parameters
12. parameters.Add("TransactionID", transactionId.ToString());
13.
14. parameters.Add("MerchantID", "ANBRedirectM");
15. parameters.Add("Amount", "2000");
16. parameters.Add("CurrencyISOCode", "840");
17. parameters.Add("MessageID", "1");
18. parameters.Add("Quantity", "1");
19. parameters.Add("Channel", "0");
20. //fill some optional parameters
21. parameters.Add("Language", "en");
22. parameters.Add("ThemeID", "1000000001");
23. parameters.Add("ResponseBackURL", "https://MerchantSite/RedirectPaym
entResponsePage");// if this url is configured for the merchant it's not required
24. parameters.Add("Version", "1.0");
25.
26. //Create an Ordered String of The Parameters Dictionary with Secret
Key
27. StringBuilder orderedString = new StringBuilder();
28. orderedString.Append(SECRET_KEY);
29. foreach (KeyValuePair<string, string> kv in parameters)
30. {
31. orderedString.Append(kv.Value);
32. }
33. Console.WriteLine("orderdString: " + orderedString);
34.
35. // Generate SecureHash with SHA256
36. SHA256 sha256;
37. byte[] bytes, hash;
38. string secureHash = string.Empty;
39.
40. bytes = Encoding.UTF8.GetBytes(orderedString.ToString().ToString());
41. sha256 = SHA256Managed.Create();
42. hash = sha256.ComputeHash(bytes);
43. foreach (byte x in hash)
44. {
45. secureHash += String.Format("{0:x2}", x);
46. }
Sample Code (PHP)
1. $PAYONE_SECRET_KEY = "Y2FkMTdlOWZiMzJjMzY4ZGFkMzhkMWIz"; // Use Yours,
Please Store Your Secret Key in safe Place(eg. database)
2. $transaction_id = (int)(microtime(true)*1000); //time in milleseconds
3.
4. $parameters = array();
5. // fill required parameters
6. $parameters['TransactionID'] = $transaction_id; //TMP:
7. $parameters['MerchantID'] = "ANBRedirectM";
8. $parameters['Amount'] = "2000";
9. $parameters['CurrencyISOCode'] = "840";
10. $parameters['MessageID'] = "1";
11. $parameters['Quantity'] = "1";
12. $parameters['Channel'] = "0";
13. //fill some optional parameters
14. $parameters['Language'] = "en";
15. $parameters['ThemeID'] = "1000000001";
16. $parameters['ResponseBackURL'] = "https://MerchantSite/RedirectPaymentRespon
sePage";// if this url is configured for the merchant it's not required
17. $parameters['Version'] = "1.0";
18.
19. //Create an Ordered String of The Parameters string with Secret Key by ksort
20. ksort($parameters);
21. $orderedString = $PAYONE_SECRET_KEY;
22. foreach($parameters as $k=>$param){
23. $orderedString .= $param;
24. }
25. echo "orderdString: " .$orderedString.chr(10);
26.
27. // Generate SecureHash with SHA256
28. $secureHash = hash('sha256', $orderedString, false);