Android developmentAndroid tutorial

Razorpay payment gateway integration

Razorpay payment gateway integration

Hi, Android developer in this article we learn about Razorpay payment gateway integration in android. And Also we learn what is a payment gateway how it’s working. To get more details about to Difference Payment Gateway vs Payment Processor

Table of Content:

  • What is the payment gateway?
  • Difference Payment Gateway vs Payment Processor
  • Razorpay payment gateway integration in android
  • Android SDK Integration – Razorpay Standard Checkout
  • How To Integrate Razorpay In Android
  • Its payment success response in Android
  • Razorpay payment gateway integration in Java
  • Android payment gateway integration
  • Razorpay payment success response in Android


What is Payment Gateway?

Payment gateways are online payment services that, when connected to an E-commerce platform, serve as a channel for making and taking payments.

The process for receiving payments requires the client to provide certain information including credit/debit card information the expiry date, as well as CVV.

Following this, the client is able to pay and the money is transferred from the account of the buyer onto the seller’s (merchant’s) bank account.

What is Payment Gateway and is Role

The primary function of an internet-based payment processor is to authorize the process of transactions between the customers and merchants.

It plays an essential role in the process of online transactions and allows transactions between customers and merchants.

It allows the e-commerce platform to enhance its standing by providing a variety of payment options to its customers.

In addition, it leads to the e-commerce platform developing a reputation for bringing not just quick and secure transactions but also ease of use and success each time.

The payment gateway service could be offered by banks directly or a third-party payment service provider that is authorized by banks.

Difference Payment Gateway vs Payment Processor.

Once we have mastered the basics, let’s proceed to more specific. This is a quick overview of the differences between payment gateways and payment processors.

Payment processors facilitate transactions between two parties feasible.

But, a payment gateway (PG) captures the details of the payment made by the customer and sends this information back to the processor. Thereafter, the PG transmits the status of the transaction between the buyer and the seller. (the merchant)

Which one do I require Payment gateway vs. processor?

After we’ve gone over the basics of PG and PP, let’s go more deeply.

Do you need a PG and a permanent PP?

Razorpay payment gateway integration In Android :

  • This article will discuss the payment gateways that we can use for Android, IOS, and Web.
  • Here we make an example Razorpay Payment Gateway in Android.
  • Razorpay SDK Integration.


dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation ''
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


Then, open AndroidManifest.xml and then add this singleton class into the tag by using the android: name property. It will start the class at the moment the app is launched. Make sure to add the INTERNET permission since we will be making network calls.

<uses-permission android:name="android.permission.INTERNET" />
     android:value="rzp_test_0Q9QUVz0kaWmK3" />

And follow the below steps for Razorpay payment gateway integration in your android app. Let’s make  Ui and for payment screen and implication in java class.

Razorpay payment gateway integration  UI Screen Source code activity_payment.xml 

you can use the below code for making UI for your payment screen you can customize it according to your requirements. In this UI we used an input layout edit text for input amount and pay now button.


<LinearLayout xmlns:android=""



                android:textSize="25sp" />

                android:text="Payment what you are paying?" />


            android:text="Pay Now"
            android:visibility="visible" />


Payment Activity Java Source Code 

public class MainActivity extends AppCompatActivity implements PaymentResultListener {
    private Button buttonConfirmOrder;
    private EditText editTextPayment;

    protected void onCreate(Bundle savedInstanceState) {
    public void findViews() {
        buttonConfirmOrder = (Button) findViewById(;
        editTextPayment = (EditText) findViewById(;
    public void listeners() {
        buttonConfirmOrder.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                    Toast.makeText(MainActivity.this, "Please fill payment", Toast.LENGTH_LONG).show();
    public void startPayment() {
        final Activity activity = this;
        final Checkout co = new Checkout();
        try {
            JSONObject options = new JSONObject();
            options.put("name", "Name");
            options.put("description", "Description");
            //You can omit the image option to fetch the image from dashboard
            options.put("image", "");
            options.put("currency", "INR");
            String payment = editTextPayment.getText().toString();
            double total = Double.parseDouble(payment);
            total = total * 100;
            options.put("amount", total);
            JSONObject preFill = new JSONObject();
            preFill.put("email", "");
            preFill.put("contact", "");
            options.put("prefill", preFill);
  , options);
        } catch (Exception e) {
            Toast.makeText(activity, "Error in payment: " + e.getMessage(), Toast.LENGTH_SHORT).show();
    public void onPaymentSuccess(String razorpayPaymentID) {
        Toast.makeText(this, "Payment successfully done! " + razorpayPaymentID, Toast.LENGTH_SHORT).show();
    public void onPaymentError(int code, String response) {
        try {
            Toast.makeText(this, "Payment error please try again", Toast.LENGTH_SHORT).show();
        } catch (Exception e) {
            Log.e("OnPaymentError", "Exception in onPaymentError", e);

Done you can test your app. if you have any issue with live integration contact to Razorpay customer care number and also Connect with the Razorpay dashboard.

Razorpay customer care number and Razorpay dashboard Support.

For assistance to the Razorpay support team

  1. Log in to your Razorpay dashboard.
  2. Click the headphone icon in order to start the Help and Support pop-up.
  3. There are a few more options available:
    • Have a query?
      It is possible to check the status of your existing support tickets or open a new support ticket on the Razorpay Dashboard for any issue.
    • Contact us to chat
      Live chat with us today to have your questions answered promptly or to learn about the features more clearly.
    • Dashboard Guide
      Discover the many features that are available on the Dashboard through this Razorpay Dashboard Guide.
  4. It is also possible to refer to these Razorpay Documents regarding the various Razorpay products, integrations and APIs. 



Have a query?

You can look up existing questions or create a support ticket via Razorpay’s Dashboard. Razorpay Dashboard.

Raise a New Ticket

  1. To raise a new ticket:

    1. Log in to your Razorpay Accounts.
    2. Click on the headphone icon to start the Help and Support pop-up.
    3. Click Have a query?
    4. Select the purpose of the request.
    5. Select the subcategory under which you want to raise tickets.
    6. Read the FAQs before submitting a ticket. If your issue isn’t resolved, then you need to explain the concern and attach the relevant documents or photos If you can and click submit.


Chat with us

This feature is accessible to exclusive users. If it’s available for your account, then you can talk to a representative from our Support Team using the Chat with us option (between 10 a.m. between 10 and 10 p.m. during every working day) to communicate instantly.

To begin chat live with us:

  1. Log in to your Razorpay dashboard.
  2. Click the headphone icon in order to start the Help and Support pop-up.
  3. Click to for a chat. Chat to us.
  4. On the pop-up, you can select the subject of your question and begin talking to our support staff.