Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate paytm wallet in android application? [closed]

Tags:

java

android

I want to integrate paytm wallet in my android application. I found lots of suggestions and documentation on Google but nothing worked. If there is any documentation, code samples or useful suggestions that you know please let me know. Thanks in advance.

like image 458
Ajinkya Patil Avatar asked May 06 '15 06:05

Ajinkya Patil


People also ask

Can we use Paytm wallet as a payment method in Android?

Paytm wallet can be used by all Paytm users to make transactions at any time and from any location.


1 Answers

Note: Below is for version 1.0, now paytm updated their sdk, so you need to change that accordingly.
Go to link :

http://paywithpaytm.com/developer/

and download Android+SDK

put below code in your function or where you want to start paytm stuff.

    private int randomInt = 0;
    private PaytmPGService Service = null;

    Random randomGenerator = new Random();
    randomInt = randomGenerator.nextInt(1000);
    //for testing environment   
    Service = PaytmPGService.getStagingService();
    //for production environment 
    /*Service = PaytmPGService.getProductionService();*/ 

    /*PaytmMerchant constructor takes two parameters
    1) Checksum generation url
    2) Checksum verification url
    Merchant should replace the below values with his values*/


PaytmMerchant Merchant = new PaytmMerchant("https://pguat.paytm.com/merchant-chksum/ChecksumGenerator","https://pguat.paytm.com/merchant-chksum/ValidateChksum");

    //below parameter map is required to construct PaytmOrder object, Merchant should replace below map values with his own values

    Map<String, String> paramMap = new HashMap<String, String>();
        
        //these are mandatory parameters
        paramMap.put("REQUEST_TYPE", "DEFAULT");
        paramMap.put("ORDER_ID", String.valueOf(randomInt));
        //MID provided by paytm
        paramMap.put("MID", "id provided by paytm");
        paramMap.put("CUST_ID", "CUST123");
        paramMap.put("CHANNEL_ID", "WAP");
        paramMap.put("INDUSTRY_TYPE_ID", "Retail");
        paramMap.put("WEBSITE", "paytm");
        paramMap.put("TXN_AMOUNT", "1");
        paramMap.put("THEME", "merchant");          
                                    
        PaytmOrder Order = new PaytmOrder(paramMap);


Service.initialize(Order, Merchant,null);
        Service.startPaymentTransaction(activity, false, false, new PaytmPaymentTransactionCallback() {
        @Override
        public void onTransactionSuccess(Bundle bundle) {
            app.getLogger().error("Transaction Success :" + bundle);
        }

        @Override
        public void onTransactionFailure(String s, Bundle bundle) {
            app.getLogger().error("Transaction Failure :" + s + "\n" + bundle);
        }

        @Override
        public void networkNotAvailable() {
            app.getLogger().error("network unavailable :");
        }

        @Override
        public void clientAuthenticationFailed(String s) {
            app.getLogger().error("clientAuthenticationFailed :" + s);
        }

        @Override
        public void someUIErrorOccurred(String s) {
            app.getLogger().error("someUIErrorOccurred :" + s);
        }

        @Override
        public void onErrorLoadingWebPage(int i, String s, String s2) {
            app.getLogger().error("errorLoadingWebPage :" + i + "\n" + s + "\n" + s2);
        }
    });
    }

Also another thing is you need to declare one activity in AndroidManifest.xml file:

<activity
            android:name="com.paytm.pgsdk.PaytmPGActivity"
            android:theme="@style/AppTheme"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden"/>

Hope above code sample will help u lot. Also another thing is when you download Android+SDK you will get one jar file pgsdk.jar file that you need to add in your project and MainActivity.java class file for our reference. Enjoy!!!

Note: ChecksumGenerator and ValidateChksum urls are for just testing purpose which is provided by paytm development support team. You need to generate it on your own server for redirecting respective url.

like image 180
Ganesh Katikar Avatar answered Sep 23 '22 23:09

Ganesh Katikar