Updated 24 September 2023
Paytm Payment Gateway flow and how it work :-
Add Client-side certificate file inside the raw folder. If the raw folder is not there then create the raw folder within the “res” folder.
1 2 |
<usespermission android:name = "android.permission.INTERNET"/> <usespermission android:name = "android.permission.ACCESS_NETWORK_STATE"/> |
1 2 |
<activity android:name="com.paytm.pgsdk.PaytmPGActiviy" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation|keyboard"/> |
1 2 3 |
-keepclassmembers class com.paytm.pgsdk.PaytmWebView$PaytmJavaScriptInterface { public *; } |
Once you have completed the above configuration setup, then you can start using PG Service API’s.
Payment Transaction
Java
1 |
PaytmOrder Order = new PaytmOrder(Map <String, String> paramMap); |
Where,
paramMap is the map containing request parameter names and their respective values. Please refer Example given in the next subsection.
Java
1 |
PaytmMerchant Merchant = new PaytmMerchant( "http://hostname/<checksum-gerneration-URL>", " http://hostname/<checksum-verification-URL>") |
4. Create PaytmClient Object holding the Merchant Configuration. The syntax for creating PaytmMerchant Object is as follows:
Java
1 |
PaytmClientCertificate Certificate = new PaytmClientCertificate(String, String inFileName); |
where,
inPassword is the Client side certificate password
inFileName is the Client side certificate file name. This file must be present inside “raw” folder.
Java
1 |
void com.paytm.pgsdk.PaytmPGService.initialize(PaytmOrder inOrder, PaytmMerchant inMerchant, PaytmClientCertificate inCertificate); |
Where,
inOrder is the Object which is holding Order Information.
inMerchant is the Object which is holding Merchant Configuration.
inCertificate is the Object which is holding Certificate Information. Pass this as null if no client certificate is used by the merchant (as given above in the Prerequisites section)
Java
1 |
void com.paytm.pgsdk.PaytmPGService.startPaymentTransaction(Context inCtxt, boolean inbHideHeader, boolean inbSendAllChecksumResponseParametersToPGServer, PaytmPaymentTransactionCallback inPaymentTransactionCallback); |
Where,
inCtxt is the Activity Context in which you are calling this method.
inbHideHeader is a boolean variable to hide or show Header Bar.
inbSendAllChecksumResponseParametersToPGServer is a boolean variable to determine whether to send all checksum response parameters to PG Server or not.
inPaymentTransactionCallback is a PaytmPaymentTransactionCallback instance to send callback messages back to merchant application.
Once Payment Transaction is done or some error occurs then the callback methods of
PaytmPaymentTransactionCallback will be called with a successful response or an error message.
Following is a sample implementation of the APIs.
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
//Getting the Service Instance. PaytmPGService.getStagingService() will return the Service pointing to Staging Environment and PaytmPGService.getProductionService() will return the Service pointing to Production Environment. PaytmPGService Service = null; Service = PaytmPGService.getStagingService(); //or Service = PaytmPGService.getProductionService(); //Create new order Object having all order information. Map<String, String> paramMap = new HashMap<String, String>(); paramMap.put("REQUEST_TYPE", "DEFAULT"); paramMap.put("ORDER_ID", ‘ORDER12345’) paramMap.put("MID", "klbGlV59135347348753"); paramMap.put("CUST_ID”,’CUST110’) paramMap.put("CHANNEL_ID", "WAP"); paramMap.put("INDUSTRY_TYPE_ID", "Retail"); paramMap.put("WEBSITE", "paytm"); paramMap.put("TXN_AMOUNT", "1.0"); paramMap.put("THEME ", "merchant"); PaytmOrder Order = new PaytmOrder(paramMap); //Create new Merchant Object having all merchant configuration. PaytmMerchant Merchant = new PaytmMerchant( "http://hostname/<checksum-gerneration-URL>", " http://hostname/<checksum-verification-URL>"); //Set PaytmOrder and PaytmMerchant objects. Call this method and set both objects before starting transaction. Service.initialize(Order, Merchant, null); //Start the Payment Transaction. Before starting the transaction ensure that initialize method is called. Service.startPaymentTransaction(this, true, true, new PaytmPaymentTransactionCallback() { @Override public void someUIErrorOccurred(String inErrorMessage) { // Some UI Error Occurred in Payment Gateway Activity. // This may be due to initialization of views in Payment Gateway Activity or may be due to initialization of webview. // Error Message details the error occurred. } @Override public void onTransactionSuccess(Bundle inResponse) { // After successful transaction this method gets called. // Response bundle contains the merchant response parameters. } @Override public void onTransactionFailure(String inErrorMessage, Bundle inResponse) { // This method gets called if transaction failed. // Here in this case transaction is completed, but with a failure. // Error Message describes the reason for failure. // Response bundle contains the merchant response parameters. } @Override public void networkNotAvailable() { // If network is not available, then this method gets called. } @Override public void clientAuthenticationFailed(String inErrorMessage) { // This method gets called if client authentication failed. // Failure may be due to following reasons // 1. Server error or downtime. // 2. Server unable to generate checksum or checksum response is // not in proper format. // 3. Server failed to authenticate that client. That is value of // payt_STATUS is 2. // Error Message describes the reason for failure. } @Override public void onErrorLoadingWebPage(int iniErrorCode, String inErrorMessage, String inFailingURL) { // This page gets called if some error occurred while loading some URL in Webview. // Error Code and Error Message describes the error. // Failing URL is the URL that failed to load. } }); |
Sources http://paywithpaytm.com/developer/paytm_sdk_doc?target=android-configurations
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
What is “Client Certificate and Encrypted password” ?
Where I can obtain these certificate and details:
PaytmClientCertificate Certificate = new PaytmClientCertificate(String, String inFileName);