paytmPayment JS API
Use Case
This method can be used to invoke paytm payment option, user will be able to see all the available payment options, after successful transaction client side will receive the callback.
Request Attributes
Content Format : JSON
PARAMETER | DESCRIPTION | REQUIRED | EXAMPLE VALUE |
---|---|---|---|
amount | Amount to be paid by customer in INR | Yes | 1.00 |
orderId | Unique reference ID for a transaction which is generated by merchant and sent in the request | yes | 0071490615 |
txnToken | It is the security token generated by Initiate Transaction API for a transaction. It is valid for 15 minutes. | Yes | fe795335ed3049c78a57271075f2199e1526969112097 |
mid | This is a unique identifier provided to every merchant by Paytm | Yes | ABCdj00008000000 |
Response Attributes
Once the payment is done, the response callback is received, which can be in either of the two formats:
- {"data": false} if no response string was generated by the internal payment mechanism, due to an unknown reason.
- {"data": ""} if some unknown error occured.
- {"data": <RESULT_STRING>} if a response string was successfully generated
Note: If the value against "data" key is a string, it should be parsed into a json to obtain the response attributes detailed below. In this case, the json thus parsed contains fields indicating whether the payment succeeded or failed (along with the reason for failure).
Success:
PARAMETER | DESCRIPTION | EXAMPLE VALUE |
---|---|---|
ORDERID | Unique reference ID for a transaction which is generated by merchant and sent in the request | 0071490615 |
MID | This is a unique identifier provided to every merchant by Paytm | ABCdj00008000000 |
TXNID | This is a unique Paytm transaction ID that is issued by Paytm for each transaction | 20191001111212800110168390621570 |
TXNAMOUNT | Order value of the transaction in INR. Merchant should validate this amount against that send in transaction request payload. In case the amount does not match, merchant should not provide the services to customer. This is needed to avoid request and response tampering possible at the time of transaction. | 1.00 |
PAYMENTMODE | The payment mode used by customer for transaction Credit card – CC Debit card - DC Net banking - NB UPI - UPI Paytm wallet – PPI Postpaid - PAYTMCC | UPI |
TXNDATE | Date and Time of transaction in the format "yyyy-MM-dd HH:mm:ss.S"Example: "2015-11- 02 11:40:46.0" | 2019-10-01 11:44:57.0 |
STATUS | This contains the transaction status and has only three values: TXN_SUCCESS, TXN_FAILURE and PENDING | TXN_SUCCESS |
RESPCODE | Codes refer to a particular reason of payment failure/success. | 01 |
RESPMSG | Description message is linked with each respcode | Txn Success |
GATEWAYNAME | Gateway used by Paytm to process the transactions. By paymodes, the details are provided below Credit, Debit cards, UPI - Gateway used to process the transaction. For example, if HDFC gateway has been used to process SBI credit card transactions, the value will be HDFC Net banking - Netbanking transactions are not routed via gateway. Hence issuing bank name is passed in this field Paytm Wallet - The value will be 'WALLET' Paytm Postpaid - The value will be 'PAYTMCC' | HDFC |
BANKNAME | Name of issuing bank of the payment instrument used by customer. For Credit Cards, Debit Cards, Netbanking - Name of the issuing bank. Example in case customer uses SBI's credit card, the value will be "SBI”.For Paytm Wallet, value will be Wallet. In case of UPI, this parameter will not be present in the response. | HDFC |
BANKTXNID | The transaction ID sent by the bank. In case of Paytm proprietary instruments too, there is unique reference number generated by Paytm's system. In case the transaction does not reach the bank, this will be NULL or empty string. Primary reason for this is user dropping out of the payment flow before the transaction reaches to bank servers | 5583250 |
TXNTYPE | The value of this parameter is "SALE" for the payment. | SALE |
REFUNDAMT | Total cumulative refund amount against this transaction. For example for a transaction. with order value as INR 100, there has been two refunds of INR 20 & INR 30 historically, then REFUNDAMT will be INR 50. | 0.00 |
CHECKSUMHASH | Security parameter to avoid tampering. Verified using server side checksum utility provided by Paytm. Utilities to generate checksumhash is available here | 68mwQa9x8uRPPCIDyH |
Error Responses:
PARAMETER | DESCRIPTION | EXAMPLE VALUE |
---|---|---|
error.code | Error code | 2 |
error.message | Error message | Failed to login |
Error Codes
RESPCODE | STATUS | RESPMSG |
---|---|---|
01 | TXN_SUCCESS | Txn Success |
-2 | FAILURE | Failed to login! |
2 | FAILURE | Insufficient parameters |
227 | TXN_FAILURE | Your payment has been declined by your bank. Please contact your bank for any queries. If money has been deducted from your account, your bank will inform us within 48 hrs and we will refund the same. |
235 | TXN_FAILURE | Wallet balance Insufficient, bankName=WALLET |
295 | TXN_FAILURE | Your payment failed as the UPI ID entered is incorrect. Please try again by entering a valid VPA or use a different method to complete the payment. |
334 | TXN_FAILURE | Invalid Order ID |
400 | PENDING | Transaction status not confirmed yet. |
401 | TXN_FAILURE | Your payment has been declined by your bank. Please contact your bank for any queries. If money has been deducted from your account, your bank will inform us within 48 hrs and we will refund the same. |
402 | PENDING | Looks like the payment is not complete. Please wait while we confirm the status with your bank. |
810 | TXN_FAILURE | Txn Failed |
REQUEST CODERESPONSE CODE
JAVASCRIPT
const requestObject={
"amount": "1.00",
"orderId": "0071490615",
"txnToken":
"fe795335ed3049c78a57271075f2199e152696911
2097",
"mid": "ABCdj00008000000",
}
function ready (callback) {
// call if jsbridge is injected
if(window.JSBridge) {
callback && callback();
} else{
// listen to jsbridge ready event
document.addEventListener('JSBridgeReady'
, callback, false);
}}
ready(function () {
JSBridge.call('paytmPayment',requestObject,
function(result) {
console.log(JSON.stringify(result))
});
});