Direct Pay (S2S)
The S2S (Server-to-Server) integration allows merchants to process transactions programmatically on the backend. Iframe integration remains a key component for secure data handling.
Steps to Implement
1. Initiate Transaction
- Initiate this request with user details as mentioned in request params to get a TXN_ID for S2S transaction initiated us which can be further used to complete the payment flow.
Endpoint URL
baseUrl = https://sandbox.reddragonpay.com
{baseUrl}/pgui/services/paymentServices/initiate/payment
Parameter | Data Type | Mandatory |
---|---|---|
APP_ID | Numeric | Yes |
ORDER_ID | Alphanumeric | Yes |
TXNTYPE | Alphabet | Yes |
CUST_NAME | Alphabet | CM |
CUST_FIRST_NAME | Alphabet | Yes |
CUST_LAST_NAME | Alphabet | Yes |
CUST_STREET_ADDRESS1 | Alphanumeric | CM |
CUST_CITY | Alphabet | Yes |
CUST_STATE | Alphabet | Yes |
CUST_COUNTRY | Alphabet | Yes |
CUST_ZIP | Numeric | Yes |
CUST_PHONE | Numeric | Yes |
CUST_EMAIL | Alphanumeric | Yes |
PRODUCT_DESC | Alphanumeric | No |
AMOUNT | Numeric | Yes |
CURRENCY_CODE | Numeric | Yes |
PAYMENT_TYPE | Alphabet | Yes |
CARD_NUMBER | Numeric | Yes |
CARD_EXP_DT | Numeric | Yes |
CVV | Numeric | Yes |
RETURN_URL | URL | Yes |
HASH | Alphanumeric | Yes |
BROWSER_USER_AGENT | Alphanumeric | CM |
BROWSER_LANGUAGE | Alphanumeric | CM |
BROWSER_JAVA_ENABLED | Alpha | CM |
BROWSER_COLOR_DEPTH | Numeric | CM |
BROWSER_SCREEN_HEIGHT | Numeric | CM |
BROWSER_SCREEN_WIDTH | Numeric | CM |
BROWSER_TZ | Numeric | CM |
BROWSER_ACCEPT_HEADER | Alphanumeric | CM |
CUST_SHIP_FIRST_NAME | Alphabet | No |
CUST_SHIP_LAST_NAME | Alphabet | No |
CUST_SHIP_EMAIL | Alphanumeric | No |
CUST_SHIP_STREET_ADDRESS1 | Alphanumeric | No |
CUST_SHIP_STREET_ADDRESS2 | Alphanumeric | No |
CUST_SHIP_CITY | Alphabet | No |
CUST_SHIP_STATE | Alphabet | No |
CUST_SHIP_COUNTRY | Alphabet | No |
CUST_SHIP_ZIP | Numeric | No |
CUST_SHIP_PHONE | Numeric | No |
caution
- CM = Conditional Mandatory
- Request must be as JSON Based REST API (HTTP POST)
- HASH generation mechanism explained in Appendix section below.
- ORDER_ID must be the one Merchant used while initiating the transaction
- CURRENCY_CODE must be the one Merchant used while initiating the transaction
- TXNTYPE must be SALE
- PAYMENT_TYPE can be CC for credit card, DC for debit card
- AMOUNT must not be in decimal i.e. USD 1.20 should always be mentioned as 120.
- All API requests expect amounts to be provided in a currency’s smallest unit (Minor Units). For example, to charge 10 USD, provide an amount value of 1000 (that is, 1000 cents).
- CARD_EXP_DT must in format of MMYYYY example 052027
info
PLEASE DO NOT RELY ON ANY OTHER RESPONSE THAN RESPONSE_CODE + STATUS. ALL OTHER MESSAGES MAY CHANGE. ONLY RESPONSE_CODE = 000 + STATUS = ‘Captured’ = SUCCESSFUL TRANSACTION. REST ANY OF THE COMBINATIONS LIKE RESPONSE_CODE =000 + STATUS = Enrolled/PENDING DOES NOT MEAN ITS SUCCESS.
ITS MANDATORY TO IMPLEMENT STATUS ENQUIRY BECAUSE IN CASES WHEN THERE IS NO RESPONSE THROUGH CALLBACK OR RETURN URL DUE TO ANY EXCEPTIONS OR NETWORK ERROR STATUS API CAN HELP GET THE FINAL STATUS OF THE TRANSACTION.
Request Sample
Example
{
"APP_ID": "1000221129001154",
"ORDER_ID": "7773428492547592",
"TXNTYPE": "SALE",
"CUST_NAME": "John Snow",
"CUST_FIRST_NAME": "John",
"CUST_LAST_NAME": "Snow",
"CUST_STREET_ADDRESS1": "House No 123 Street No42",
"CUST_CITY": "Las Vegas",
"CUST_STATE": "Nevada",
"CUST_COUNTRY": "US",
"CUST_ZIP": "88901",
"CUST_PHONE": "9454243567",
"CUST_EMAIL": "johnsnow@test.com",
"PRODUCT_DESC": "Iphone 14 Pro Max 256 GB",
"AMOUNT": "119900",
"CURRENCY_CODE": "840",
"PAYMENT_TYPE": "CC",
"CARD_NUMBER": "4111110000000211",
"CARD_EXP_DT": "122030",
"CVV": "123",
"RETURN_URL": "https://www.merchant.com/response.jsp",
"HASH": "8B39ECAEEF6008954C2FFBB163DD2E7132E5625D37409D0B6A6C5A51DCA580DE8B39ECAEEF6008954C2FFBB163DD2E7132E5625D37409D0B6A6C5A51DCA580DE "
"BROWSER_USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"BROWSER_LANGUAGE": "en-US",
"BROWSER_JAVA_ENABLED": "true",
"BROWSER_COLOR_DEPTH": "24",
"BROWSER_SCREEN_HEIGHT": "714",
"BROWSER_SCREEN_WIDTH": "796",
"BROWSER_TZ": "0",
"BROWSER_ACCEPT_HEADER": " text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 ",
}
Response Sample
3DS Response
{
"RESPONSE_DATE_TIME": "2023-06-06 15:46:19",
"APP_ID": "1000230420105434",
"RESPONSE_CODE": "000",
"PG_TXN_MESSAGE": "ThreeD Authentication Pending",
"AUTH_CODE": "205643",
"STATUS": "Enrolled",
"TXN_ID": "1038230606154618",
"IS_CHALANGE_REQUIRED": "Yes",
"RESPONSE_MESSAGE": "SUCCESS",
"RRN": "205643",
"HASH": "AF19E150F2B14A73A1290CF92C85F7B3E78EE114A74EDD21E2900D4B0D3439B1 AF19E150F2B14A73A1290CF92C85F7B3E78EE114A74EDD21E2900D4B0D3439B1"
}
2DS Response
{
"RESPONSE_DATE_TIME": "2023-06-06 15:37:38",
"APP_ID": "1000230420105434",
"RESPONSE_CODE": "000",
"PG_TXN_MESSAGE": "Transaction Succeeded-Approved or completed successfully",
"AUTH_CODE": "205641",
"STATUS": "Captured",
"TXN_ID": "1036230606153737",
"IS_CHALANGE_REQUIRED": "No",
"PG_DESCRIPTOR": "Test_PG_Display",
"RESPONSE_MESSAGE": "SUCCESS",
"RRN": "205641",
"HASH": "7D021F16E40C7BA724017D62F621F81FF519FA65AE602722EB3A352C56A1DFF47D021F16E40C7BA724017D62F621F81FF519FA65AE602722EB3A352C56A1DFF4"
}
caution
- It is recommended to check the combination of status and response code received in response.
- Response Code: (000) + Status: (Captured) = Successfully Captured
- If RESPONSE_CODE = 000 and STATUS = Captured and IS_CHALANGE_REQUIRED: No, then transaction is 2D and successfully captured. (Please ask the support to switch to non-3DS in order to test)
- If RESPONSE_CODE is other than 000, then transaction is not completed, it’s failed, rejected or some exception, check your request and send all required data.
- If RESPONSE_CODE = 000 and there IS_CHALANGE_REQUIRED = Yes, then transaction is 3DS and follow the step-2 as below to complete the 3DS Flow.
Error Response
In case of Hash validation failure:
{
"RESPONSE_CODE": "323",
"RESPONSE_MESSAGE": "Invalid Hash"
}
In case of any mandatory field missing:
"RESPONSE_CODE": "326",
"STATUS": "Invalid value",
"RESPONSE_MESSAGE": "ORDER_ID is missing"
In case of any other failure:
"RESPONSE_CODE": "344",
"RESPONSE_MESSAGE": "Something went wrong."
2. Transaction Capture Request
- Initiate this request to redirect user to 3DS page for OTP/Password verification to complete the payment flow.
Endpoint
{baseUrl}/pgui/jsp/capturePayment
Parameter | Data Type | Mandatory |
---|---|---|
APP_ID | Numeric | Yes |
TXN_ID | Numeric | Yes |
HASH | AlphaNumeric | Yes |
caution
- Request must be as form-data (Form POST).
- APP_ID Unique ID provided by to merchant.
- TXN_ID must be the one Merchant received in response after invoking transaction initiation API.
- Sample HTML code is shared below. Click here
Response
- After invoking Finalization API merchant will be redirected to 3DS page of Issuer bank for OTP/Password verification, in case if OTP/Password verification is not supported by the end user’s card than merchant will be directly receiving response on its Return URL (RETURN_URL) instead of redirection to Issuer Bank, which is passed during the invocation of Transaction Initiation API.
- All response codes that merchant would be receiving in response is mentioned in separate section called appendix below.
Embed Iframe
- Create an order similar to checkout API mentioned above with following changes:
Add 2 libraries in head tag
<link rel="stylesheet" href="{baseUrl}/pgui/checkoutlibrary/checkout.min.css">
<script src="{baseUrl}/pgui/checkoutlibrary/checkout.min.js"></script>
Add 2 attributes in form that will be submitted
onsubmit="return checkoutSubmitHandler(this);" target="checkout-iframe"
Sample html for 3DS
- A sample html is provided below for the same. Kindly add/change a couple of details as follows:
- URL
- APP_ID
- Mandatory fields
- Generate a valid hash accordingly
3DS HTML Sample Code with Iframe
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="{baseUrl}/pgui/checkoutlibrary/checkout.min.css">
<script src="{baseUrl}/pgui/checkoutlibrary/checkout.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>S2S Finalize</title>
<script>function autoPop(){document.getElementById("ORDER_ID").value="SIGN"+String((new Date).getTime());var t=new Date,e=String(t.getFullYear()).concat("-").concat(String(t.getMonth()+1)).concat("-").concat(String(t.getDate()));document.getElementById("txnDate").value=e}function submitForm(){var t=document.forms[0];t.action="{baseUrl}/pgui/jsp/capturePayment",t.submit()}</script>
<style type="text/css">body{width:100%;margin:0 auto;background-color:#f7f9fd}.demo-page_wrapper{display:flex;align-items:center;justify-content:center;width:100%;height:100%;position:fixed;top:0;left:0;font-family:'Titillium Web',sans-serif}.demo-page_container{width:100%;max-width:767px;background-color:#fff;box-shadow:0 0 20px rgba(0,0,0,.1);border-radius:10px}.dm-container{padding:0 15px}.demo-page_header{text-align:center;position:relative}.demo-page_header h4{margin:0;padding-top:20px;margin-bottom:20px;font-size:20px;display:inline-block;background-color:#fff;padding-left:20px;padding-right:20px;position:relative;z-index:999}.demo-page_header:after{content:"";width:100%;height:2px;position:absolute;top:30px;left:0;background-color:#00589f}.dm-row{margin:0 -15px;display:flex;flex-wrap:wrap}.dm-input_group{width:100%;max-width:33.33%;padding:0 15px;box-sizing:border-box;margin-bottom:20px}.dm-input_group label{font-size:12px;margin-bottom:5px;display:block}.dm-input_group .dm-input_control{width:100%;height:30px;border:1px solid #ddd;text-indent:10px;border-radius:5px}.dm-button-wrapper{text-align:center;width:100%;margin-bottom:20px}.dm-button-wrapper .dm-button{background-color:#00589f;color:#fff;padding:7px 15px;display:inline-block;border:none;border-radius:5px;cursor:pointer}
</style>
</head>
<body onload="autoPop()">
<div class="demo-page_wrapper">
<div class="demo-page_container">
<div class="demo-page_header">
<h4>Demo Checkout Page</h4></div>
<form action="{baseUrl}/pgui/jsp/capturePayment" method="post" onsubmit="return submitHandler(this)" target="checkout-iframe">
<div class="demo-page_formElement">
<div class="dm-container">
<div class="dm-row">
<div class="dm-input_group">
<label for="">APP_ID:</label>
<input type="text" name="APP_ID" class="dm-input_control" value="1234567890123456" autocomplete="off"></div>
<div class="dm-input_group">
<label for="">TXN_ID:</label><input type="text" id="TXN_ID" name="TXN_ID" class="dm-input_control" value="" autocomplete="off" placeholder="">
</div>
<div class="dm-input_group"><label for="">HASH:</label><input type="text" id="HASH" name="HASH" class="dm-input_control" value="3323C83D4EDD3EA9CB9F503A16BDB3047DC2AAB29F7BDB0304DDB67AABD2AD4A3323C83D4EDD3EA9CB9F503A16BDB3047DC2AAB29F7BDB0304DDB67AABD2AD4A" autocomplete="off">
</div>
<div class="dm-button-wrapper"><input type="submit" name="button" id="button" class="dm-button" value="Pay Now"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
3DS HTML Sample Code without Iframe
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>S2S Form POST - Sample</title><script>function autoPop(){document.getElementById("ORDER_ID").value="SIGN"+String((new Date).getTime());var t=new Date,e=String(t.getFullYear()).concat("-").concat(String(t.getMonth()+1)).concat("-").concat(String(t.getDate()));document.getElementById("txnDate").value=e}function submitForm(){var t=document.forms[0];t.action="{baseUrl}/pgui/jsp/capturePayment",t.submit()}</script><style type="text/css">body{width:100%;margin:0 auto;background-color:#f7f9fd}.demo-page_wrapper{display:flex;align-items:center;justify-content:center;width:100%;height:100%;position:fixed;top:0;left:0;font-family:'Titillium Web',sans-serif}.demo-page_container{width:100%;max-width:767px;background-color:#fff;box-shadow:0 0 20px rgba(0,0,0,.1);border-radius:10px}.dm-container{padding:0 15px}.demo-page_header{text-align:center;position:relative}.demo-page_header h4{margin:0;padding-top:20px;margin-bottom:20px;font-size:20px;display:inline-block;background-color:#fff;padding-left:20px;padding-right:20px;position:relative;z-index:999}.demo-page_header:after{content:"";width:100%;height:2px;position:absolute;top:30px;left:0;background-color:#00589f}.dm-row{margin:0 -15px;display:flex;flex-wrap:wrap}.dm-input_group{width:100%;max-width:33.33%;padding:0 15px;box-sizing:border-box;margin-bottom:20px}.dm-input_group label{font-size:12px;margin-bottom:5px;display:block}.dm-input_group .dm-input_control{width:100%;height:30px;border:1px solid #ddd;text-indent:10px;border-radius:5px}.dm-button-wrapper{text-align:center;width:100%;margin-bottom:20px}.dm-button-wrapper .dm-button{background-color:#00589f;color:#fff;padding:7px 15px;display:inline-block;border:none;border-radius:5px;cursor:pointer}</style></head><body onload="autoPop()"><div class="demo-page_wrapper"><div class="demo-page_container"><div class="demo-page_header"><h4>Demo Checkout Page</h4></div><form action="{baseUrl} /pgui/jsp/capturePayment" method="post"><div class="demo-page_formElement"><div class="dm-container"><div class="dm-row"><div class="dm-input_group"><label for="">APP_ID:</label><input type="text" name="APP_ID" class="dm-input_control" value="1010221102114535" autocomplete="off"></div><div class="dm-input_group"><label for="">TXN_ID:</label><input type="text" id="TXN_ID" name="TXN_ID" class="dm-input_control" value="" autocomplete="off" placeholder="Enter TXN_ID of transaction"></div><div class="dm-input_group"><label for="">HASH:</label><input type="text" id="HASH" name="HASH" class="dm-input_control" value="3323C83D4EDD3EA9CB9F503A16BDB3047DC2AAB29F7BDB0304DDB67AABD2AD4A" autocomplete="off"></div><div class="dm-button-wrapper"><input type="submit" name="button" id="button" class="dm-button" value="Pay Now" onclick="submitForm()"></div></div></div></div></form></div></div></body></html>