简体   繁体   中英

How to add Paytm WebView based payment gateway in android?

I want to integrate Paytm payments gateway into my app. I want to use Paytm payment links for this as for using official sdk for android requires merchant keys and that's very pathetic to take. So I want to know If I add Paytm payment link to my android app in webview then how will I confirm the payment success and failures for generating a certain response based on payment status.

If above is wrong way then please suggest a proper way. Any help is highly appreciated!! Thanks

you need to use paytm all-in-one SDk to get payment done via webview(if customer not having paytm app installed on his phone). You need to generate transaction token from your server and then start payment process.

Paytm result will goes into onActivityResult(). There you can check the status is successful or failed. Please check this code

  @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.e(TAG ," result code "+resultCode);
        // -1 means successful  // 0 means failed
        // one error is - nativeSdkForMerchantMessage : networkError
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == ActivityRequestCode && data != null) {
            Bundle bundle = data.getExtras();
            if (bundle != null) {
                for (String key : bundle.keySet()) {
                    Log.e(TAG, key + " : " + (bundle.get(key) != null ? bundle.get(key) : "NULL"));
                }
            }
             Log.e(TAG, " data "+  data.getStringExtra("nativeSdkForMerchantMessage"));
             Log.e(TAG, " data response - "+data.getStringExtra("response"));
/*
 data response - {"BANKNAME":"WALLET","BANKTXNID":"1395841115",


    "CHECKSUMHASH":"7jRCFIk6mrep+IhnmQrlrL43KSCSXrmM+VHP5pH0hekXaaxjt3MEgd1N9mLtWyu4VwpWexHOILCTAhybOo5EVDmAEV33rg2VAS/p0PXdk\u003d",
     "CURRENCY":"INR","GATEWAYNAME":"WALLET","MID":"EAc0553138556","ORDERID":"100620202152",
     "PAYMENTMODE":"PPI","RESPCODE":"01","RESPMSG":"Txn Success","STATUS":"TXN_SUCCESS",
     "TXNAMOUNT":"2.00","TXNDATE":"2020-06-10 16:57:45.0","TXNID":"20200610111212800110168328631290118"}
      */
                Toast.makeText(this, data.getStringExtra("nativeSdkForMerchantMessage")
                        + data.getStringExtra("response"), Toast.LENGTH_SHORT).show();
            }else{
                Log.e(TAG, " payment failed");
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM