- 20 Jan 2022
- 3 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
API Payment
- Updated on 20 Jan 2022
- 3 Minutes to read
- Contributors
- Print
- DarkLight
- PDF
Request message
Input request parameter | Description |
Merchant Authentication Token | Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy |
MessageID | 8 |
TransactionID | 12345678901234567890 |
MerchantID | STSPayOneM |
Amount | 2000 |
PaymentMethod | 1 |
CurrencyISOCode | 840 |
CardNumber | 4111111111111111 |
ExpiryDateYear | 22 |
ExpiryDateMonth | 01 |
SecurityCode | 854 |
PaymentDescription | Sample Payment |
ClientIPaddress | 188.888.50.125 |
Parameters Order | |
Amount, CardNumber, ClientIPaddress, CurrencyISOCode, ExpiryDateMonth, ExpiryDateYear,MerchantID, MessageID, PaymentDescription, PaymentMethod, Note: The parameters are ordered alphabetically in the secure hash. | |
The input to the Secure Hash generation routine | |
Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy20004111111111111111188.888.50.1258400122ST | |
Output | |
b6e4b31d5581d91d3b1022b3efb33ccfbbe5b7e7bd17dccaa9aa6beceb42b444 |
Request message- request includes the Agreement ID and Agreement Type
Input request parameter | Description |
Merchant Authentication Token | YTIzYzBhZmU5OTI2MTU3ZGM5ZjgzYmI5 |
AgreementID | 7879 |
AgreementType | recurring |
Amount | 2000 |
ApplePayToken | %7B%22paymentData%22%3A%7B%22version%22%3A%2 |
Channel | 0 |
ClientIPaddress | 1.2.3.4 |
CurrencyISOCode | 840 |
MerchantID | ANBMPGSMerchant |
MessageID | 8 |
PaymentDescription | Sample Payment |
PaymentMethod | 3 |
Quantity | 1 |
TransactionID | 1615377297480 |
Version | 1.0 |
Parameters Order | |
AgreementID , AgreementType, Amount, ApplePayToken , Channel, ClientIPaddress , CurrencyISOCode , MerchantID, MessageID, PaymentDescription, PaymentMethod , Note: The parameters are ordered alphabetically in the secure hash. | |
The input to the Secure Hash generation routine | |
YTIzYzBhZmU5OTI2MTU3ZGM5ZjgzYmI57879recurring2000%7B | |
Output | |
59a3c9e8935e08c804bba446455344928ff279082db475aad7b33817bdeab40d |
Response message
Input response parameter | Description |
Merchant Authentication Token | Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy |
Response.MessageID | 8 |
Response.TransactionID | 12345678901234567890 |
Response.StatusCode | 20001 |
Response.StatusDescription | 3D-Secure Authentication Required |
Response.GatewayStatusCode | 8005 |
Response.GatewayName | TestGateway |
Response.Amount | 2000 |
Response.CurrencyISOCode | 840 |
Response.MerchantID | STSPayOneM |
Response.PaymentMethod | 1 |
Response.AuthenticationURL | https://dropit.3dsecure.net |
Response.PaReq | eJxVUttu4jAQ/ZWqH4AvJCxBgyVIkJo |
Parameters Order | |
Response.Amount, Response.AuthenticationURL, Response.CurrencyISOCode, Response.GatewayName, Response.GatewayStatusCode, Response.MerchantID, Note: The parameters are ordered alphabetically in the secure hash. | |
The input to the Secure Hash generation routine | |
Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy2000https://dropit.3dsecure.net840TestGateway 8005STSPayOneM8eJxVUttu4jAQ/ZWqH4AvJCxBgyVIkJo1200013D- | |
Output | |
9af4f51d3ba17fdc1658350ff9782167e8c6fcac3619e88c5d2d9a1ce0bd6f63 |
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", "8");
parameters.put("Quantity", "1");
parameters.put("Channel", "0");
parameters.put("PaymentMethod", "1");
parameters.put("ClientIPaddress", "127.0.0.1");
//for Card Payment (conditional;paymentMethod=1)
parameters.put("CardNumber", "4012001045873335");
parameters.put("ExpiryDateYear", "01");
parameters.put("ExpiryDateMonth", "19");
parameters.put("SecurityCode", "123");
parameters.put("CardHolderName", "1");
//for Sadad Payment (conditional;paymentMethod=2)
//parameters.put("SadadOlpId", "testSadad");
//parameters.put("mfu","https://MerchantSite/RedirectPaymentRequestPage");
//fill some optional parameters
parameters.put("Language", "en");
parameters.put("ThemeID", "1000000001");
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 SortedDoctionary to have the parameters to have
them sorted alphabetically.
3. SortedDictionary<string, string> parameters = new SortedDictionary<String, S
tring>(StringComparer.Ordinal);
4.
5. long
transactionId = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond); //getting time
in milliseconds
6.
7. // fill required parameters
8. parameters.Add("TransactionID", transactionId.ToString());
9. parameters.Add("MerchantID", "ANBRedirectM");
10. parameters.Add("Amount", "2000");
11. parameters.Add("CurrencyISOCode", "840");
12. parameters.Add("MessageID", "9");
13. parameters.Add("Quantity", "1");
14. parameters.Add("Channel", "0");
15. parameters.Add("PaymentMethod", "1");
16. parameters.Add("ClientIPaddress", "127.0.0.1");
17. //for Card Payment (conditional;paymentMethod=1)
18. parameters.Add("CardNumber", "4012001045873335");
19. parameters.Add("ExpiryDateYear", "01");
20. parameters.Add("ExpiryDateMonth", "19");
21. parameters.Add("SecurityCode", "123");
22. parameters.Add("CardHolderName", "1");
23. //for Sadad Payment (conditional;paymentMethod=2)
24. //parameters.Add("SadadOlpId", "testSadad");
25. //parameters.Add("mfu","https://MerchantSite/RedirectPaymentRequestPag
e");
26. //fill some optional parameters
27. parameters.Add("Language", "en");
28. parameters.Add("ThemeID", "1000000001");
29. parameters.Add("Version", "1.0");
30. //Create an Ordered String of The Parameters dictionary with Secret
Key
31. StringBuilder orderedString = new StringBuilder();
32. orderedString.Append(SECRET_KEY);
33. foreach (KeyValuePair<string, string> kv in parameters)
34. {
35. orderedString.Append(kv.Value);
36. }
37. Console.WriteLine("orderdString " + orderedString);
38.
39. // Generate SecureHash with SHA256
40. SHA256 sha256;
41. byte[] bytes, hash;
42. string secureHash = string.Empty;
43.
44. bytes = Encoding.UTF8.GetBytes(orderedString.ToString().ToString());
45. sha256 = SHA256Managed.Create();
46. hash = sha256.ComputeHash(bytes);
47. foreach (byte x in hash)
48. {
49. secureHash += String.Format("{0:x2}", x);
50. }
51.
52. Console.WriteLine("Secure Hash: " + secureHash.ToString());
Sample Code (PHP)
1. //Step 1: Generate Secure Hash
2. $SECRET_KEY = "Y2FkMTdlOWZiMzJjMzY4ZGFkMzhkMWIz"; // Use Yours, Please Store
Your Secret Key in safe Place(e.g. database)
3. // put the parameters in a array to have the parameters to have them sorted
alphabetically via ksort.
4. $parameters = [];
5. $transactionId = (int)microtime(true)*1000; //output to be like: 1495004320389
6. // fill required parameters
7. $parameters["TransactionID"] = $transactionId;
8. $parameters["MerchantID"] = "ANBRedirectM";
9. $parameters["Amount"] = "2000";
10. $parameters["CurrencyISOCode"] = "840";
11. $parameters["MessageID"] = "9";
12. $parameters["Quantity"] = "1";
13. $parameters["Channel"] = "0";
14. $parameters["PaymentMethod"] = "1";
15. $parameters["ClientIPaddress"] = "127.0.0.1";
16. //for Card Payment (conditional;paymentMethod=1)
17. $parameters["CardNumber"] = "4012001045873335";
18. $parameters["ExpiryDateYear"] = "01";
19. $parameters["ExpiryDateMonth"] = "19";
20. $parameters["SecurityCode"] = "123";
21. $parameters["CardHolderName"] = "1";
22. //for Sadad Payment (conditional;paymentMethod=2)
23. //$parameters["SadadOlpId"] = "testSadad";
24. //$parameters["mfu"] = "https://MerchantSite/RedirectPaymentRequestPage";
25.
26. //fill some optional parameters
27. $parameters["Language"] = "en";
28. $parameters["ThemeID"] = "1000000001";
29. $parameters["Version"] = "1.0";
30. //Create an Ordered String of The Parameters Map with Secret Key
31.
32. ksort($parameters);
33. $orderedString = $SECRET_KEY;
34. foreach($parameters as $param){
35. $orderedString .= $param;
36. }
37. echo ("orderdString ". $orderedString);
38. // Generate SecureHash with SHA256
39. // Using DigestUtils from appache.commons.codes.jar Library
40. $secureHash = hash('sha256', $orderedString, false);
41.