API Payment
  • 20 Jan 2022
  • 3 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

API Payment

  • Dark
    Light
  • PDF

Article summary

Request message 

Input request parameterDescription
Merchant Authentication Token Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy
MessageID8
TransactionID12345678901234567890
MerchantIDSTSPayOneM
Amount2000
PaymentMethod1
CurrencyISOCode840
CardNumber4111111111111111
ExpiryDateYear 22
ExpiryDateMonth01
SecurityCode 854
PaymentDescriptionSample Payment
ClientIPaddress188.888.50.125
Parameters Order
Amount, CardNumber, ClientIPaddress, CurrencyISOCode, ExpiryDateMonth, 

ExpiryDateYear,MerchantID, MessageID, PaymentDescription, PaymentMethod,
SecurityCode, TransactionID 

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

Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy20004111111111111111188.888.50.1258400122ST
SPayOneM8Sample+Payment185412345678901234567890

Output
b6e4b31d5581d91d3b1022b3efb33ccfbbe5b7e7bd17dccaa9aa6beceb42b444

Request message- request includes the Agreement ID and Agreement Type

Input request parameterDescription
Merchant Authentication TokenYTIzYzBhZmU5OTI2MTU3ZGM5ZjgzYmI5
AgreementID  7879
AgreementTyperecurring
Amount2000
ApplePayToken

%7B%22paymentData%22%3A%7B%22version%22%3A%2
2EC_v1%22%2C%22data%22%3A%22ffgg5Yp2OwEYFli3
fGJy%2FICzlRKotN7YvLls2%2FqdsI0j2NqveguPAE3X
gNY%2FGyTleoF%2BNI5rreuYv0%2FrA2MW20lWnT3RBd
1uH%2Fc18JIDyA9hE%2FJX0aPhtnNxfzDDDYoOroUpTz
1CYpQmQ5Acjthe3XlXDjL2Hw0QRHeQTcooVzJlEhO%2F
4fVS9WsIpUOsuffTefXFuSjgWJ7pVekvMXDanmGxitNZ
eyq5Vl4hb9gp7Faux0Sbmg6xCSrKD1443ZUv5kq6A0NJ
9CKKmYIGOsg%2Fwly96tTdP5o%2FhAKfr%2FXphIDrgE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JArqe9
rN5LyPnmaFVNUAAAAAAAA%3D%22%2C%22header%22%3
A%7B%22ephemeralPublicKey%22%3A%22MFkwEwYHKo
ZIzj0CAQYIKoZIzj0DAQcDQgAEYEwFIeAIoRobAGazkW
gMi6vhKV4MFPo%2FDErVs8N5B8N7%2B96igxFXu1rpKY
%2BpDv6kxlPUxec8dAz%2BbDjlQZWmnQ%3D%3D%22%2C
%22publicKeyHash%22%3A%22lwAHhqlgHKmag%2F%2F
nye2Aax9TX7RHWZywn5SGzqk1W18%3D%22%2C%22tran
sactionId%22%3A%22b57ae128d808ca62a36344d643
6297be78f395e62b8fec3f6859cc9ed28714a8%22%7D
%7D%2C%22paymentMethod%22%3A%7B%22displayNam
e%22%3A%22MasterCard+1489%22%2C%22network%22
%3A%22MasterCard%22%2C%22type%22%3A%22credit
%22%7D%2C%22transactionIdentifier%22%3A%22B5
7AE1D808CA62A36344D6436297BE78F395E62B8FEC3F
6859CC9ED28714A8%22%7D

Channel0
ClientIPaddress1.2.3.4
CurrencyISOCode840
MerchantIDANBMPGSMerchant
MessageID 8
PaymentDescriptionSample Payment
PaymentMethod 3
Quantity1
TransactionID 1615377297480
Version1.0
Parameters Order
AgreementID , AgreementType, Amount, ApplePayToken , Channel, ClientIPaddress ,  

CurrencyISOCode , MerchantID, MessageID, PaymentDescription, PaymentMethod ,
Quantity, TransactionID, Version 

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

YTIzYzBhZmU5OTI2MTU3ZGM5ZjgzYmI57879recurring2000%7B
%22paymentData%22%3A%7B%22version%22%3A%22EC_v1%22%2
C%22data%22%3A%22ffgg5Yp2OwEYFli3fGJy%2FICzlRKotN7Yv
Lls2%2FqdsI0j2NqveguPAE3XgNY%2FGyTleoF%2BNI5rreuYv0%
2FrA2MW20lWnT3RBd1uH%2Fc18JIDyA9hE%2FJX0aPhtnNxfzDDD
YoOroUpTz1CYpQmQ5Acjthe3XlXDjL2Hw0QRHeQTcooVzJlEhO%2
F4f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AiEA5qBPlyP4%2Bw93%2Bv8OiepxqYr6JArqe9rN
5LyPnmaFVNUAAAAAAAA%3D%22%2C%22header%22%3A%7B%22eph
emeralPublicKey%22%3A%22MFkwEwYHKoZIzj0CAQYIKoZIzj0D
AQcDQgAEYEwFIeAIoRobAGazkWgMi6vhKV4MFPo%2FDErVs8N5B8
N7%2B96igxFXu1rpKY%2BpDv6kxlPUxec8dAz%2BbDjlQZWmnQ%3
D%3D%22%2C%22publicKeyHash%22%3A%22lwAHhqlgHKmag%2F%
2Fnye2Aax9TX7RHWZywn5SGzqk1W18%3D%22%2C%22transactio
nId%22%3A%22b57ae128d808ca62a36344d6436297be78f395e6
2b8fec3f6859cc9ed28714a8%22%7D%7D%2C%22paymentMethod
%22%3A%7B%22displayName%22%3A%22MasterCard+1489%22%2
C%22network%22%3A%22MasterCard%22%2C%22type%22%3A%22
credit%22%7D%2C%22transactionIdentifier%22%3A%22B57A
E128D808CA62A36344D6436297BE78F395E62B8FEC3F6859CC9E
D28714A8%22%7D01.2.3.4840ANBMPGSMerchant8Sample+Paym
ent3116153772974801.0

Output
59a3c9e8935e08c804bba446455344928ff279082db475aad7b33817bdeab40d

Response message 

Input response parameterDescription
Merchant Authentication TokenY2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy
Response.MessageID 8
Response.TransactionID12345678901234567890
Response.StatusCode20001
Response.StatusDescription3D-Secure Authentication Required
Response.GatewayStatusCode8005
Response.GatewayNameTestGateway
Response.Amount2000
Response.CurrencyISOCode840
Response.MerchantID STSPayOneM
Response.PaymentMethod1
Response.AuthenticationURL https://dropit.3dsecure.net
Response.PaReqeJxVUttu4jAQ/ZWqH4AvJCxBgyVIkJo
Parameters Order
Response.Amount, Response.AuthenticationURL, Response.CurrencyISOCode, 

Response.GatewayName, Response.GatewayStatusCode, Response.MerchantID,
Response.MessageID, Response.PaReq, Response.PaymentMethod, Response.StatusCode,
Response.StatusDescription, Response.TransactionID 

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

Y2ExNzE2NDBlZjEyNmZhZjRmMmRmY2Iy2000https://dropit.3dsecure.net840TestGateway 8005STSPayOneM8eJxVUttu4jAQ/ZWqH4AvJCxBgyVIkJo1200013D-
Secure+Authentication+Required12345678901234567890

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.    

What's Next