-
Obtain the following
- PGSDK provided in the Android plugin.
- Client side certificate (Optional: Refer “Client Certificate and Encrypted password” section given below).
- Password for the Client side certificate. (Optional: Refer “Client Certificate and Encrypted password” section given below).
-
Add Client side certificate file inside raw folder. If raw folder is not available, then create a raw folder within “res” folder.
-
Add the INTERNET and ACCESS_NETWORK_STATE permissions to your AndroidManifest.xml. These two permissions are required for PGSDK Service to function.
-
AndroidManifest.xml
-
-
Add the Declaration of PaytmPGActivity in your AndroidManifest.xml. This activity is available in the PGSDK. Make sure that the manifest file also specifies this activity element.
-
AndroidManifest.xml
-
-
For going Live, please add the following to the ProGuard file:
-
AndroidManifest.xml
}
-
Once you have completed the above configuration setup, then you can start using PG Service APIs.
-
-
Obtain the PaytmPGService instance. You can call either the Staging service or the Production service depending on your requirement. PaytmPGService.getStagingService() will return the Service Object pointing to Staging Environment. PaytmPGService.getProductionService() will return the Service Object pointing to Production Environment.
-
Create a HASHMAP Object that includes the order details. Syntax for creating PaytmOrder Object is as follows:
-
ANDROID
paramMap.put( "CALLBACK_URL" , "https://securegw.paytm.in/theia/paytmCallback");
paramMap.put( "EMAIL" , "abc@gmail.com");
paramMap.put( "CHECKSUMHASH" , "w2QDRMgp1234567JEAPCIOmNgQvsi+BhpqijfM9KvFfRiPmGSt3Ddzw+oTaGCLneJwxFFq5mqTMwJXdQE2EzK4px2xruDqKZjHupz9yXev4=")
- where, paramMap is the map containing request parameter names and their respective values.
- (Optional) Create PaytmClientCertificate object that contains the certificate information. Syntax for creating PaytmClientCertificate object is as follows
-
ANDROID
PaytmClientCertificate Certificate = new PaytmClientCertificate(String inPassword, String inFileName);
- inPassword is the client side certificate password
- inFileName is the client side certificate file name. This file must be present in “raw” folder.
- Create Paytm Order Object
-
ANDROID
- Call the initialize() method to set PaytmOrder and PaytmClientCertificate Objects. Method Signature is as follows:
-
ANDROID
void com.paytm.pgsdk.PaytmPGService.initialize(PaytmOrder inOrder, PaytmClientCertificate inCertificate);
- where,
*inOrder is the object which contains order details.
- inCertificate is the object which has certificate information. Pass this as null if no client certificate is used by the merchant (as given above in the Prerequisites section) or null
- where,
*inOrder is the object which contains order details.
- Call startPaymentTransaction() method to start the Payment Transaction. Method Signature is as follows:
-
ANDROID
void com.paytm.pgsdk.PaytmPGService.startPaymentTransaction(Context inCtxt, boolean inbHideHeader, boolean inbSendAllChecksumResponseParametersToPGServer, PaytmPaymentTransactionCallback inPaymentTransactionCallback);
- where,
- inCtxt is the activity context in which this method is called.
- inbHideHeader is a boolean variable used 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.
- where,
-
Implement the callback methods to handle the response upon payment completion Callback methods are under PaytmPaymentTransactionCallback ANDROID
public void onTransactionResponse(Bundle inResponse) { /once transaction is completed on paytm you get complete response in json format/ }
public void networkNotAvailable() { /* If network is not available, then this method gets called. */ }
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. Error
public void onTransactionCancel(String inErrorMessage, Bundle inResponse) {/*on transaction cancelled this callback got triggered */ }
-
Following is a sample implementation of the APIs.
-
Android
//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.
paramMap.put( "CALLBACK_URL" , "https://securegw.paytm.in/theia/paytmCallback");
paramMap.put( "EMAIL" , "abc@gmail.com");
paramMap.put( "CHECKSUMHASH" , "w2QDRMgp1234567JEAPCIOmNgQvsi+BhpqijfM9KvFfRiPmGSt3Ddzw+oTaGCLneJwxFFq5mqTMwJXdQE2EzK4px2xruDqKZjHupz9yXev4=");
//Create Client Certificate object holding the information related to Client Certificate. Filename must be without .p12 extension.
//Set PaytmOrder and PaytmClientCertificate Object. Call this method and set both objects before starting transaction.
//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) { Log.d("LOG", "UI Error Occur."); Toast.makeText(getApplicationContext(), " UI Error Occur. ", Toast.LENGTH_LONG).show(); } @Override public void onTransactionResponse(Bundle inResponse) { Log.d("LOG", "Payment Transaction : " + inResponse); Toast.makeText(getApplicationContext(), "Payment Transaction response "+inResponse.toString(), Toast.LENGTH_LONG).show(); } @Override public void networkNotAvailable() { Log.d("LOG", "UI Error Occur."); Toast.makeText(getApplicationContext(), " UI Error Occur. ", Toast.LENGTH_LONG).show(); } @Override public void clientAuthenticationFailed(String inErrorMessage) { Log.d("LOG", "UI Error Occur."); Toast.makeText(getApplicationContext(), " Severside Error "+ inErrorMessage, Toast.LENGTH_LONG).show(); } @Override public void onErrorLoadingWebPage(int iniErrorCode, String inErrorMessage, String inFailingUrl) { } @Override public void onBackPressedCancelTransaction() { // TODO Auto-generated method stub } @Override public void onTransactionCancel(String inErrorMessage, Bundle inResponse) { Log.d("LOG", "Payment Transaction Failed " + inErrorMessage); Toast.makeText(getBaseContext(), "Payment Transaction Failed ", Toast.LENGTH_LONG).show(); }
});
-
http://paywithpaytm.com/developer/paytm_sdk_doc/
http://paywithpaytm.com/developer/paytm_sdk_doc?target=how-paytm-sdk-works
http://paywithpaytm.com/developer/paytm_sdk_doc?target=android-configurations
https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_PHP
https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_JAVA
https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_Python
https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_Ruby
https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_NodeJs
https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_DotNet
http://paywithpaytm.com/developer/paytm_api_doc?target=txn-status-api
Important Note :
We are not supporting PgSdk jar from now onwards. Kindly use the below mentioned Gradle dependency for the same.
Gradle Dependency:
Command : compile 'com.paytm:pgplussdk:1.1.5'
Note:
-
If you have the Jar file please Remove the jar file and jar dependency from the project.
-
Kindly change the import statements accordingly.