- Print
- DarkLight
- PDF
This message is used by the merchant to inquire about the status of a specific transaction. The Inquiry message is based on the API communication model described in the Communication Model section.
Request Parameters
Parameter | Description |
---|---|
MessageID required | An alphanumeric value that represents the action for defined unique numbers as mentioned below:
|
MerchantID required | An alphanumeric value that represents the unique Merchant ID at SmartRoute. The Payment Gateway operation team provides this value based on the merchant enrollment.
|
OriginalTransactionID required | The transaction ID belongs to the original transaction, which should be inquired.
|
SecureHash required | An alphanumeric value that represents the generated hex-encoded hash using hashing algorithm SHA-2 (256) by concatenating parameters as a single string starting with the merchant’s Merchant Authentication Token. Then all parameters (required parameters and optional parameters - if available) are ordered alphabetically. By parameter’s name should be part of the secure hash, with no separators and no terminating character. Appendix B: Secure Hash – Transaction Inquiry; for more information, see secure hash generation.
|
Version required | A numeric value with (.) separator represents the command's version to be used. If this value is not provided, SmartRoute will consider its default value which is 1.0
|
IncludeRefundIds Optional | The IncludeRefundIds is an optional parameter in the request It accepts the values “Yes” and “No”. If the parameter is being provided with a "Yes" value then the merchant will receive within the inquiry response refund status along with refund transaction ids if any.
|
Sample Request Code (Java)
StringBuffer requestQuery = new StringBuffer();
requestQuery
.append("OriginalTransactionID").append("=").append(1440954863817).append("&")
.append("MerchantID").append("=").append("ANBRedirectM").append("&")
.append("MessageID").append("=").append("2").append("&")
.append("Version").append("=").append("1.0").append("&")
.append("SecureHash").append("=").append(secureHash).append("&");
//Send the request
URL url = new URL("https://SR_URL");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
//write parameters
writer.write(requestQuery.toString());
writer.flush();
Response Parameters
Parameter | Description |
---|---|
Response.MessageStatus required | An alphanumeric value that represents the response code that covers the errors generated by SmartRoute. Appendix A: Transaction Inquiry Response Codes for more information; see Response Codes.
|
Response.StatusCode required | An alphanumeric value that represents the original transaction status that needs to be inquired.
|
Response.Amount required | A numeric value that contains the purchase amount of the item.
|
Response.CurrencyISOCode required | The numeric value is in ISO format for the currency. The value should be neither character value nor decimal point. For example, 840 for US Dollar, 400 for JOD.
|
Response.MerchantID required | An alphanumeric value that represents the unique ID of the merchant at SmartRoute. The SmartRoute operation team provides this value upon merchant enrollment.
|
Response.TransactionID required | The merchant generates the Transaction ID. It represents a unique identifier of the original transaction. The transaction to be inquired about it.
Note: Transection id must not include special characters or spaces. |
Response.MessageID required | An alphanumeric value that represents the action for defined unique numbers as mentioned below:
|
Response.ReversalStatus required | The Reversal Status of the transaction has the below mentioned possible values which are needed to be inquired about:
|
Response.SecureHash required | An alphanumeric value that represents the generated hex-encoded hash using hashing algorithm SHA-2 (256) by concatenating parameters as a single string starting with the merchant’s Merchant Authentication Token. Then all response parameters appended in alphabetical order based on the parameter’s name, with no separators and no terminating character. Appendix B: Secure Hash – Transaction Inquiry; for more information, see secure hash generation.
|
Response.PaymentMethod required | An Alphanumeric value indicates the payment method. Supported values depend on the requested version as follows: If Version is 1.0 :
Note: SmartRoute operation team, upon merchant enrollment, provides possible Card Names. |
Response.AuthorizedAmount Conditional | A numeric value that contains the ISO Formatted total transaction authorized amount with no decimal point. For example, 100 for 1.00 USD.
Condition: This parameter will be provided back to the merchant if the MCP is enabled for this merchant. |
Response.AuthorizedCurrencyISOCode conditional | Authorized Currency uses the numeric ISO Code for the payment and not the character value. For example, 840 for the US Dollar.
Condition: This parameter will be provided back to the merchant if the MCP is enabled for this merchant. |
Response.GatewayStatusCode optional | An alphanumeric value that represents the gateway status of the original transection .This code covers errors generated by the chosen gateway. the transaction to be inquired about it.
|
Response.GatewayStatusDescription optional | An alphanumeric value that represents a message describing the response status received from the chosen gateway using the language specified in the request. This value is for the original transaction which needed to be inquired. After completing the execution process, this parameter is filled in. This value should be UTF-8 encoded when it is entered into the secure hash generation process.
|
Response.GatewayName optional | This value represents the gateway name that processed the transaction. It can be alphanumeric with special characters like space, ‘@’ and ‘_’.
|
Response.RRN optional | An alphanumeric value that represents a Receipt Reference Number for the current payment transaction. This value is returned if the value is provided from the gateway.
|
Response.ApprovalCode optional | Approval Code received from Payment Processor such as Visa. The values are returned in the following cases:
|
Response.CardExpiryDate optional | The customer’s card expiry date (year) digits are used in the payment. The format of this parameter should be in the form (YY).
|
Response.CardHolderName optional | The customer’s card number is used in the payment.
|
Response.CardNumber optional | The customer’s card number is used in the payment.
|
Response.RefundStatus Conditional | Transaction Refund status. This applies only to refund-eligible transaction types.
Condition: This parameter will be provided back to the merchant if the IncludeRefundIds parameter is "Yes". For example, Pre-Authorization cannot be refunded. |
Response.RefundIds Conditional | Related refunded transactions Ids. This applies only to refund-eligible transaction types.
Condition: This parameter will be provided back to the merchant if the IncludeRefundIds parameter is "Yes". For example, Pre-Authorization cannot be refunded. |
Response.IssuerName Conditional | An Alphanumeric value indicates the Issuer Name.
Condition: This parameter will be provided back to the merchant if the provided version in the request is 3.1 |
Sample Response Code (Java)
// Get the response
StringBuffer output = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
output.append(line);
}
writer.close();
reader.close();
//Output the response
System.out.println(output.toString());
// this string is formatted as a "Query String" - name=value&name2=value2.......
String outputString=output.toString();
// To read the output string you might want to split it
// on '&' to get pairs then on '=' to get name and value
// and for a better and ease on verifying secure hash you should put them in a TreeMap
String [] pairs=outputString.split("&");
Map<String,String> result=new TreeMap<String,String>();
// now we have separated the pairs from each other {"name1=value1","name2=value2",....}
for(String pair:pairs){
// now we have separated the pair to {"name","value"}
String[] nameValue=pair.split("=");
String name=nameValue[0];//first element is the name
String value=nameValue[1];//second element is the value
// put the pair in the result map
result.put(name,value);
}
// Now that we have the map, order it to generate secure hash and compare it with the received one
StringBuilder responseOrderdString = new StringBuilder();
responseOrderdString.append(AUTHENTICATION_TOKEN);
for (String treeMapKey : result.keySet()) {
responseOrderdString.append(result.get(treeMapKey));
}
System.out.println("Response Orderd String is " + responseOrderdString.toString());
// Generate SecureHash with SHA256
// Using DigestUtils from appache.commons.codes.jar Library
String generatedsecureHash = new String(DigestUtils.sha256Hex(responseOrderdString.toString()).getBytes());
// get the received secure hash from result map
String receivedSecurehash=result.get("Response.SecureHash");
if(!receivedSecurehash.equals(generatedsecureHash)){
//IF they are not equal then the response shall not be accepted
System.out.println("Received Secure Hash does not Equal generated Secure hash");
}
else{
// Complete the Action get other parameters from result map and do your processes
// Please refer to The Integration Manual to See The List of The Received Parameters
String status=result.get("Response.Status");
System.out.println("Status is :"+ status);
}
Other Sample Request Code (.Net /PHP)
Sample Request Code (.Net)
1. StringBuilder requestQuery = new StringBuilder();
2. requestQuery
3. .Append("OriginalTransactionID").Append("=").Append(1440954863817).Append("&
")
4. .Append("MerchantID").Append("=").Append("ANBRedirectM").Append("&")
5. .Append("MessageID").Append("=").Append("2").Append("&")
6. .Append("Version").Append("=").Append("1.0").Append("&")
7. .Append("SecureHash").Append("=").Append(secureHash).Append("&");
8.
9. //Send the request
10. string data = requestQuery.ToString().ToString();
11. byte[] dataStream = Encoding.UTF8.GetBytes(data);
12. string urlPath = "https://SR_URL";
13. string request = urlPath;
14. WebRequest webRequest = WebRequest.Create(request);
15. webRequest.Method = "POST";
16. webRequest.ContentType = "application/x-www-form-urlencoded";
17. webRequest.ContentLength = dataStream.Length;
18. Stream newStream = webRequest.GetRequestStream();
19. // Send the data.
20. newStream.Write(dataStream, 0, dataStream.Length);
21. newStream.Close();
22. WebResponse webResponse = webRequest.GetResponse();
23. String output = null;
24.
25. using (Stream stream = webResponse.GetResponseStream())
26. {
27. StreamReader reader = new StreamReader(stream, Encoding.UTF8);
28. output = reader.ReadToEnd();
29. }
30.
Sample Request Code (PHP)
1. $requestQueryArr = [
2. "OriginalTransactionID" => 1440954863817,
3. "MerchantID" => "ANBRedirectM",
4. "MessageID" => "2",
5. "Version" => "1.0",
6. "SecureHash" => $secureHash,
7. ];
8. //generate query string
9. $newRequestQuery = http_build_query($requestQueryArr);
10.
11. //Send the request
12. $ch = curl_init("https://SR_URL");
13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
14.
15. //write parameters
16. curl_setopt($ch,CURLOPT_POST, true);
17. curl_setopt($ch,CURLOPT_POSTFIELDS, $newRequestQuery);
18.
Other Sample Response Code (.Net /PHP)
Sample Response Code (.Net)
31. //Output the response
32. Console.WriteLine(output);
33. // this string is formatted as a "Query String" - name=value&name2=value2.......
34. String outputString = output.ToString();
35.
36. // To read the output string you might want to split it
37. // on '&' to get pairs then on '=' to get name and value
38. // and for a better and ease on verifying secure hash you should put them in a SortedDictionary
39. SortedDictionary<string, string> result = new SortedDictionary<String, String>(StringComparer.Ordinal);
40. NameValueCollection qscoll = HttpUtility.ParseQueryString(output);
41. foreach (String kv in qscoll.AllKeys)
42. {
43. result.Add(kv, qscoll[kv]);
44. }
45.
46. // Now that we have the sorted dictionary, order it to generate secure hash and compare it with the received one
47. StringBuilder responseOrderdString = new StringBuilder();
48. responseOrderdString.Append(AUTHENTICATION_TOKEN);
49. foreach (KeyValuePair<string, string> kv in result)
50. {
51. if(!"Response.SecureHash".Equals(kv.Key))
52. {
53.
54. if("Response.StatusDescription".Equals(kv.Key) || "Response.GatewayStatusDescription".Equals(kv.Key))
55. {
56. responseOrderdString.Append(HttpUtility.UrlEncode(kv.Value, System.Text.Encoding.UTF8));
57. }
58. else
59. {
60. responseOrderdString.Append(kv.Value);
61. }
62. }
63. }
64. Console.WriteLine("Response Orderd String is " + responseOrderdString.ToString());
65.
66. // Generate SecureHash with SHA256
67. SHA256 sha256Generated;
68. byte[] bytesGenerated, hashGenerated;
69.
70. bytesGenerated = Encoding.UTF8.GetBytes(responseOrderdString.ToString().ToString());
71.
72. sha256Generated = SHA256Managed.Create();
73. hashGenerated = sha256.ComputeHash(bytesGenerated);
74. String generatedsecureHash = String.Empty;
75. foreach (byte x in hashGenerated)
76. {
77. generatedsecureHash += String.Format("{0:x2}", x);
78. }
79.
80. // get the received secure hash from result SortedDictionary
81. String receivedSecurehash = result["Response.SecureHash"];
82. if (generatedsecureHash.ToString() != receivedSecurehash)
83. {
84. //IF they are not equal then the response shall not be accepted
85. Console.WriteLine("Received Secure Hash does not Equal generated Secure hash");
86. }
87. else
88. {
89. // Complete the Action get other parameters from result dictionary and do your processes
90. // Please refer to The Integration Manual to See The List of The Received Parameters
91. String status = result["Response.Status"];
92. Console.WriteLine("Status is :" + status);
93. }
Sample Response Code (PHP)
19. // Get the response
20. $output = curl_exec($ch);
21.
22. // To read the output string you might want to split it
23. // on '&' to get pairs then on '=' to get name and value
24. // and for a better and ease on verifying secure hash using parse_str
25. $result = parse_url($output);
26. //sort result alphabatically
27. ksort($result);
28.
29. // Now that we have the map, order it to generate secure hash and compare it with the received one
30. $responseOrderdString = $AUTHENTICATION_TOKEN;
31. foreach($result as $result_v){
32. $responseOrderdString .= $result_v;
33. }
34.
35. echo "Response Orderd String is " . $responseOrderdString;
36.
37. $generatedsecureHash = hash('sha256',$responseOrderdString);
38.
39. $receivedSecurehash = $result['Response.SecureHash'];
40.
41. if($receivedSecurehash != $generatedsecureHash){
42. echo "Received Secure Hash does not Equal generated Secure hash";
43. }else{
44. $status = $result["Response.Status"];
45. echo "Status is :". $status;
46. }