Saturday , October 23 2021

Paytm Integration in Android Example – Android Coding by DMTechnolab

The package Simplified coding.The trap.paytmpaymentsample;

Import Android.Support.v7.App.AppCompatActivity;

Import Android.The.Bundle;

Import Android.Opinion.Opinion;

Import Android.Widget.text view;

Import Android.Widget.Toast;

Import With.Paytm.Pgsdk.PaytmOrder;

Import With.Paytm.Pgsdk.PaytmPGService;

Import With.Paytm.Pgsdk.PaytmPaymentTransactionCallback;

Import Java.Useful.hash map;

Import Java.Useful.Map;

Import Retrofit 2.Call out;

Import Retrofit 2.call back;

Import Retrofit 2.Feedback;

Import Retrofit 2.move back;

Import Retrofit 2.Converter.the resurrection.GsonConverterFactory;

// Implementing PaytmPaymentTransactionCallback to track payment result.

public class Main activity Is spread AppCompatActivity come into force PaytmPaymentTransactionCallback {{

// Textview in interface where we have price

text view textViewPrice;

@ Override

Protected Zero Go ahead()Bundle saveInstanceState) {{

Super.Go ahead()saveInstanceState);

setContentView()R.Layout.activity_main);

// Getting a textview

textViewPrice = findViewById()R.Id.textViewPrice);

// Attach one click listener to buy button

findViewById()R.Id.switch).setOnClickListener()New Opinion.OnClickListener()) {{

@ Override

public Zero on click()Opinion Opinion) {{

// calling methodCheckSum () calling which will generate Paytm checksum for payment

Generate());

}

});

}

Private Zero Generate()) {{

// Getting tax amount first.

String txnAmount = textViewPrice.Gettext()).Wire()).Trim());

// Creating a retrofit object.

move back move back = New move back.Builder())

.Basic()Your.BASE_URL)

.addConverterFactory()GsonConverterFactory.To create()))

.Construction());

// Creating retrofit app service

Your Episeva = move back.To create()Your.class);

// create paytm object

// containing all the values ​​required

The last Paytm Paytm = New Paytm()

continuously.M_ID,

continuously.Channel ID,

txnAmount,

continuously.Website,

continuously.CALLBACK_URL,

continuously.Type of industry_Id

);

// Create a call object from ApiService

Call out call = Episeva.getChecksum()

Paytm.getmId()),

Paytm.getOrderId()),

Paytm.getCustId()),

Paytm.getChannelId()),

Paytm.getTxnAmount()),

Paytm.getWebsite()),

Paytm.getCallBackUrl()),

Paytm.getIndustryTypeId())

);

// call to generate checksum

call.Begrudge()New call back()) {{

@ Override

public Zero Treason()Call out call, Feedback Feedback) {{

// We will start the payment after receiving the checksum.

// method taking Paytm object as checksum and parameter we get

initializePaytmPayment()Feedback.Body()).getChecksumHash()), Paytm);

}

@ Override

public Zero Failure()Call out call, Throwable T) {{

}

});

}

Private Zero initializePaytmPayment()String Checksum, Paytm Paytm) {{

// Get Paytm service

PaytmPGService Service = PaytmPGService.getStagingService());

// Use this when using for production

// PaytmPGService Service = PaytmPGService.getProductService ();

// to create a hashmap and add all the required values

Map<String, String> paramMap = New hash map());

paramMap.Branch()“MID”, continuously.M_ID);

paramMap.Branch()“Order ID”, Paytm.getOrderId()));

paramMap.Branch()“CUST_ID”, Paytm.getCustId()));

paramMap.Branch()“Channel ID”, Paytm.getChannelId()));

paramMap.Branch()“TXN_AMOUNT”, Paytm.getTxnAmount()));

paramMap.Branch()“Website”, Paytm.getWebsite()));

paramMap.Branch()“CALLBACK_URL”, Paytm.getCallBackUrl()));

paramMap.Branch()“Checksum”, Checksum);

paramMap.Branch()“INDUSTRY_TYPE_ID”, Paytm.getIndustryTypeId()));

// Creating a paytm order object using hashmap

PaytmOrder count = New PaytmOrder()paramMap);

// Introducing paytm service

Service.Get started()count, Invalid);

// Finally start payment transaction

Service.startPaymentTransaction()this, True, True, this);

}

// All these override method is to find the payment result accordingly.

@ Override

public Zero onTransactionResponse()Bundle Bundle) {{

Toast.Makeup()this, Bundle.Wire()), Toast.LENGTH_LONG).Display());

}

@ Override

public Zero Network not available()) {{

Toast.Makeup()this, “network error”, Toast.LENGTH_LONG).Display());

}

@ Override

public Zero clientAuthenticationFailed()String s) {{

Toast.Makeup()this, s, Toast.LENGTH_LONG).Display());

}

@ Override

public Zero someUIErrorOccined()String s) {{

Toast.Makeup()this, s, Toast.LENGTH_LONG).Display());

}

@ Override

public Zero onErrorLoadingWebPage()int I am, String s, String s1) {{

Toast.Makeup()this, s, Toast.LENGTH_LONG).Display());

}

@ Override

public Zero onBackPressedCancelTransaction()) {{

Toast.Makeup()this, “Back press”, Toast.LENGTH_LONG).Display());

}

@ Override

public Zero onTransactionCancel()String s, Bundle Bundle) {{

Toast.Makeup()this, s + Bundle.Wire()), Toast.LENGTH_LONG).Display());

}

}

window.fbAsyncInitPredefined = window.fbAsyncInit;
window.fbAsyncInit = function() {
window.FB.init({
appId: 373107186226096,
status: true,
cookie: true,
xfbml: true,
version: ‘v2.10’
});
window.FB.init = function(){};
window.fbAsyncInitPredefined && window.fbAsyncInitPredefined();
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “https://connect.facebook.net/en_US/sdk.js?”;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));


Source link

About dmtechnolab

Check Also

Simplified Coding

Android Espresso Tutorial – Testing Fragment in Isolation – Android Coding by DMTechnolab

Welcome to another tutorial in the Android test series. And this post is called Android …

One comment

  1. NYC NY Moving companies

    Your fashion is de facto unique in comparison to other people I’ve examine stuff from. A lot of many thanks for posting when you have The chance, Guess I’ll just reserve mark this web site.

Leave a Reply

Your email address will not be published. Required fields are marked *