Payment Methods

Integrate different payment methods in Razorpay Android Custom SDK Checkout.


The Razorpay Android Custom SDK lets you integrate the supported payment methods on your Android app's Checkout form.

Use the

to fetch the payment methods available for your account.

Below are the sample payloads for each payment method.

This payment method allows you to display your Customer Identifier details on checkout. Your customers can make online bank transfers to this account.

Feature Request

  • This is an on-demand feature. Please raise a request with our to get this feature activated on your Razorpay account.
  • Watch this video to know how to raise a feature enablement request on the Razorpay Dashboard.
Feature Request GIF

There are no specific request parameters to be passed. Instead, you must pass the fetchVirtualAccount method for your Customer Identifier to get created and the details to appear on the checkout. Know more about

.

For Card payments, method should be specified as card. Other required fields:

  • card[name]
  • card[number]
  • card[cvv]
  • card[expiry_month]
  • card[expiry_year]

The sample code shown below allows the checkout to accept a card payment of ₹299.35.

JSONObject data = new JSONObject();
data.put("amount", 29935);
data.put("currency", "INR");
data.put("order_id", "order_DgZ26rHjbzLLY2");//sample order_id. Generate orders using Orders API
data.put("email", "gaurav.kumar@example.com");
data.put("contact", "9000090000");
data.put("method", "card");
data.put("card[name]", "Gaurav Kumar");
data.put("card[number]", "4111111111111111");
data.put("card[expiry_month]", "12");
data.put("card[expiry_year]", "30");
data.put("card[cvv]", "100");

Check the

.

If you want to securely store customer's card details as network tokens, know about

.

For EMI, method should be specified as emi. Add an additional field, emi_duration, corresponding to the number of months for EMI. After a customer selects the desired plan, pass the corresponding value in the emi_duration field.

The sample code below allows checkout to accept a card payment of ₹3999.35:

JSONObject data = new JSONObject();
data.put("amount", 399935);
data.put("order_id", "order_DgZ26rHjbzLLY2");//sample order_id. Generate orders using Orders API
data.put("email", "gaurav.kumar@example.com");
data.put("contact", "9000090000");
data.put("method", "emi");
data.put("emi_duration", 2); //defines the number of months for the EMI.
data.put("card[name]", "Gaurav Kumar");
data.put("card[number]", "5241810000000000");
data.put("card[expiry_month]", "12");
data.put("card[expiry_year]", "30");
data.put("card[cvv]", "100");

Check the list of supported

and EMI providers.

Cardless EMI is a payment method that allows customers to convert their payment amount to EMIs. The customer does not require a debit or credit card. They can make payments via credits approved by the supported Cardless EMI payment provider. For Cardless EMI, method should be specified as cardless_emi and an additional field provider must specify the provider with its respective provider code.

Feature Request

  • This is an on-demand feature. Please raise a request with our to get this feature activated on your Razorpay account.
  • Watch this video to know how to raise a feature enablement request on the Razorpay Dashboard.
Feature Request GIF

Watch Out!

The customer should be registered with the cardless EMI payment provider before making the payment.

The sample code below allows checkout to accept a card payment of ₹5999.35:

JSONObject payload = new JSONObject("{\"currency\":\"INR\"}");
payload.put("amount", 599935);
payload.put("contact", "9000090000");
payload.put("order_id", "order_9A33XWu170gUtm");
payload.put("email", "gaurav.kumar@example.com");
payload.put("method", "cardless_emi");
payload.put("provider", "walnut369");

Check the

.

For Netbanking, method should be specified as netbanking and an additional field bank must specify the bank with its respective bank code.

The sample code shown below allows the checkout to perform a netbanking transaction for a payment of ₹299.35:

JSONObject data = new JSONObject();
data.put("amount", 29935);
data.put("order_id", "order_DgZ26rHjbzLLY2");//sample order_id. Generate orders using Orders API
data.put("email", "gaurav.kumar@example.com");
data.put("contact", "9000090000");
data.put("method", "netbanking");
data.put("bank", "SBIN");

Check the

.

You can enable your customers to make payments using the Pay Later service offered by various third-party providers. For pay later, method should be specified as paylater and an additional field provider must specify the provider with its respective provider code.

Use the sample code given below:

JSONObject payload = new JSONObject("{\"currency\":\"INR\"}");
payload.put("amount",5000);
payload.put("contact","9000090000");
payload.put("order_id","order_9A33XWu170gUtm");
payload.put("email", "gaurav.kumar@example.com");
payload.put("method", "paylater");
payload.put("provider", "lazypay");

Check the

.

For Wallet payments, method should be specified as wallet.

The sample code shown below allows the checkout to perform a wallet transaction for a payment of ₹299.35 :

JSONObject data = new JSONObject();
data.put("amount", 29935);
data.put("order_id", "order_DgZ26rHjbzLLY2");//sample order_id. Generate orders using Orders API
data.put("email", "gaurav.kumar@example.com");
data.put("contact", "9000090000");
data.put("method", "wallet");
data.put("wallet", "mobikwik");

Check the list

.

For UPI payments, method should be specified as upi. The SDK supports two flows:

  1. Collect
  2. Intent

Customers enter their vpa or

on your UI and complete the payments on their respective UPI apps in collect flow.

You can now pass the vpa parameter in the upi array as shown below.

The sample code below sends a collect request to gaurav.kumar@exampleupi handle.

JSONObject data = new JSONObject();
data.put("amount", 29935);
data.put("order_id", "order_DgZ26rHjbzLLY2");//sample order_id. Generate orders using Orders API
data.put("email", "gaurav.kumar@example.com");
data.put("contact", "9000090000");
data.put("method", "upi");
data.put("vpa", "gaurav.kumar@exampleupi");

UPI Payments Using Phone Number

You can accept UPI payments using phone number for the collect flow. Follow the steps given below:

  1. You must collect the customer's phone number from your end.
  2. Check if any vpa is associated with the given number and get the vpa_token for that number using the sample code given below:
    razorpay.isValidVpa("9000090000", new ValidateVpaCallback() {
    @Override
    public void onResponse(JSONObject response) {
    if (response.has("error")) {
    // Error: no VPA associated with the given number
    } else if (response.has("success")) {
    // VPA Validation Successful
    // Get and store response.vpa_token for initiating payment
    // You will get response.masked_vpa in this response which you can show to the end user
    }
    }
    @Override
    public void onFailure() {
    // Called in cases where the number is empty or when the device is not connected to data to make the validation
    }
    });
  3. Pass the vpa_token parameter in the upi array as shown below:
    JSONObject data = new JSONObject();
    data.put("amount", 29935);
    data.put("order_id", "order_DgZ26rHjbzXXXX");//sample order_id. Generate orders using Orders API
    data.put("email", "gaurav.kumar@example.com");
    data.put("contact", "9000090000");
    data.put("method", "upi");
    data.put("vpa_token", "f731951149df8903d374b117f921ab41");

Handy Tips

If your application targetSdkVersion is 30 or above, add the following code in your app's manifest file to support the UPI Intent flow.

<queries>
<!-- List of apps which you want to support for Intent pay -->
<package android:name="com.google.android.apps.nbu.paisa.user" />
<package android:name="com.phonepe.app"/>
<!--
Specific intents you query for,
eg: for a custom share UI
-->
<intent>
<action android:name="android.intent.action.SEND" />
</intent>
</queries>

In Intent Flow, the SDK invokes a UPI intent, which is handled by the UPI apps installed on the Android device.

To implement this flow:

  1. Fetch a list of apps on the customer's device that support UPI payments and AutoPay using the sample codes given below:

    • Fetch list of UPI Supported Apps

      Razorpay.getAppsWhichSupportUpi(this, new RzpUpiSupportedAppsCallback() {
      @Override
      public void onReceiveUpiSupportedApps(List<ApplicationDetails> list) {
      // List of upi supported app
      }
      });
    • Fetch list of UPI AutoPay Supported Apps

      Razorpay.getAppsWhichSupportAutoPayIntent(this, new RzpUpiSupportedAppsCallback() {
      @Override
      public void onReceiveUpiSupportedApps(List<ApplicationDetails> applicationDetailsList) {
      }
      });
  2. Override the onActivityResult() of your activity and pass the same to our SDK:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data){
    super.onActivityResult(requestCode, resultCode, data);
    if(razorpay!=null){
    razorpay.onActivityResult(requestCode,resultCode,data);
    }
    }
  3. Invoke the UPI and UPI AutoPay Intent with the sample codes given below. This will enable the customer to select the desired application.

    • Invoke UPI Intent

      JSONObject data = new JSONObject();
      data.put("amount", 29935);
      data.put("order_id", "order_DgZ26rHjbzLLY2");//sample order_id. Generate orders using Orders API
      data.put("email", "gaurav.kumar@example.com");
      data.put("contact", "9000090000");
      data.put("method", "upi");
      data.put("_[flow]", "intent");
      data.put("upi_app_package_name", "in.org.npci.upiapp"); //For BHIM app
    • Invoke UPI AutoPay Intent (Default)

      JSONObject data = new JSONObject("{currency: 'INR'}");
      data.put("amount", "10000");
      data.put("contact", "9000090000");
      data.put("email", "gaurav.kumar@example.com");
      data.put("order_id", "order_DgZ26rHjbzLLY2");// mandatory for UPI AutoPay payments
      data.put("customer_id", "cust_805c8oBQdBGPwS");// mandatory for UPI AutoPay payments
      data.put("recurring", "1");
      data.put("description","Credits towards consultation");
      data.put("method", "upi");
      data.put("_[flow]", "intent");
      data.put("upi_app_package_name","com.google.android.apps.nbu.paisa.user"); // pass package name that is returned in getAppsWhichSupportUpi and/or getAppsWhichSupportUpiAutoPay
    • Preferred Payload for Recurring: In the sample code below, recurring is passed as preferred. It initiates a flow in SDK where, if a selected app supports AutoPay payments, the payment passes via the AutoPay payment route. If it does not, then it passes via the one-time payment route.

      JSONObject data = new JSONObject("{currency: 'INR'}");
      data.put("amount", "10000");
      data.put("contact", "9000090000");
      data.put("email", "gaurav.kumar@example.com");
      data.put("order_id", "order_DgZ26rHjbzLLY2");// mandatory for UPI AutoPay payments
      data.put("customer_id", "cust_805c8oBQdBGPwS");// mandatory for UPI AutoPay payments
      data.put("recurring", "preferred");
      data.put("description","Credits towards consultation");
      data.put("method", "upi");
      data.put("_[flow]", "intent");
      data.put("upi_app_package_name","com.google.android.apps.nbu.paisa.user"); // pass package name that is returned in getAppsWhichSupportUpi and/or getAppsWhichSupportUpiAutoPay

Check the complete list of

.

In the Intent Flow, you can customise the order in which UPI apps appear at the Checkout. There are two sections within the app: Preferred Apps and Other Apps.

To define the order in which apps appear under these sections of the app chooser, two lists that contain the application package names must be passed to the SDK within options.

  1. Preferred apps list
  2. Other apps list

PREFERRED APPS Section

This section displays the list of applications specified using the key preferred_apps_order within options. If no application exists for this key, this section is not displayed.

OTHER APPS Section

The list of applications specified using the key other_apps_order within options is displayed under this section. Any unspecified app (which supports UPI intent) appears subsequent to the list passed in the options.

In the sample code below, BHIM (in.org.npci.upiapp) is passed in the preferred apps list and Google Pay(com.google.android.apps.nbu.paisa.user) in other apps list. As a result, BHIM is shown in the PREFERRED APPS SECTION. Google Pay is shown at the top in the OTHER APPS SECTION followed by other apps present in the device:

JSONArray prefAppsJArray = new JSONArray();
prefAppsJArray.put("in.org.npci.upiapp");
JSONArray otherAppsJArray = new JSONArray();
otherAppsJArray.put("com.google.android.apps.nbu.paisa.user");
payload.put("method", "upi");
payload.put("_[flow]", "intent");
payload.put("preferred_apps_order", prefAppsJArray);
payload.put("other_apps_order", jArray);

Make UPI payments a faster, 2-step experience for your customers with Razorpay's Turbo UPI SDK.

Know more about the

.

Customers can make payments on your Android app using their CRED Coins as well as the credit cards saved on CRED. The SDK supports two flows:

Handy Tips

Ensure you have integrated with Razorpay Android SDK version 3.9.0 or higher.

For both collect and intent flow, you need to pass the app_offer parameter in the Orders API.

POST
/orders
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X POST https://api.razorpay.com/v1/orders \
-H "content-type: application/json" \
-d '{
"amount": 1000,
"currency": "INR",
"receipt": "receipt#1",
"app_offer": true
}'

amount

mandatory

integer The transaction amount, expressed in the currency subunit, such as paise (in case of INR). For example, for an actual amount of ₹299.35, the value of this field should be 29935.

currency

mandatory

string The currency in which the transaction should be made. See the

. Default is INR.

app_offer

optional

boolean Allow/do not allow customers to use CRED coins to make payments. This is used to prevent double discounting scenarios where customers have already availed discounts using voucher/coupon, and you do not want them to redeem Coins as well. Possible values:

  • true: Customer not allowed to use CRED coins to make payment.
  • false (default): Customer can use CRED coins to make payment.

receipt

optional

string Your receipt id for this order should be passed here. Maximum length is 40 characters.

notes

optional

object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.

The Android SDK performs the following functions to invoke the intent on the Android device:

  • Handles the intent response from CRED
  • Opens the CRED app
  • Process the payment
  • Send success or failure response back to your app

To use this flow:

  1. .
  2. .
  3. .

Use the below code to check if the CRED app is present in the customer's Android device. Razorpay.isCredAppInstalled(activity) returns a boolean value, disclosing whether the app is present on the device or not.

if (Razorpay.isCredAppInstalled(PaymentOptions.this)) {
payWithCredBtn.setText("CRED Pay (Intent Flow)");
} else {
payWithCredBtn.setText("CRED Pay (Collect Flow)");
}

After you receive the customer's app information, send it to the Razorpay API to complete the creation step of the payment flow. Below is the payload(JSON Object) to be sent:

razorpay.submit(payload,activityObject)
JSONObject data = new JSONObject("{currency:'INR'}");
data.put("amount", 29935);
data.put("order_id", "order_DgZ26rHjbzLLY2");
data.put("email", "gaurav.kumar@example.com");
data.put("contact", "9000090000");
data.put("method", "app");
data.put("provider", "cred");
data.put("app_present", true);

method

mandatory

string The method used to make the payment. Here, it must be app.

provider

mandatory if method=app

string Name of the PSP app. Here, it must be cred.

app_present

mandatory if app=cred

boolean Based upon response from the app present function, pass the value in this field. Possible values:

  • true: Opens the CRED app on customer's device.
  • false (default): Sends a push notification to customer's device.

The PaymentResultListener or PaymentResultWithDataListener methods can be implemented the way shown in the above function or directly globally to the activity class. The functions will be implemented based on the method chosen.

Below are the sample codes for PaymentResultListener method.

razorpay.submit(data, new PaymentResultListener() {
@Override
public void onPaymentSuccess(String razorpayPaymentId) {
// Razorpay payment ID is passed here after a successful payment
}
@Override
public void onPaymentError(int code, String description) {
// Error code and description is passed here
}
});
} catch (Exception e) {
Log.e(TAG, "Error in submitting payment details", e);
}

Below are the sample codes for PaymentResultWithDataListener method.

razorpay.submit(data, new PaymentResultWithDataListener() {
@Override
public void onPaymentSuccess(String razorpayPaymentId, PaymentData paymentData) {
// razorpay payment ID and PaymentData passed here after a successful payment
}
@Override
public void onPaymentError(int code, String description) {
// Error code and description is passed here
}
});
} catch (Exception e) {
Log.e(TAG, "Error in submitting payment details", e);
}

In Collect Flow, the SDK sends a push notification to the contact number passed in the create request. Pass the following parameters to initiate a collect payment.

JSONObject data = new JSONObject();
data.put("amount", 29935);
data.put("order_id", "order_DgZ26rHjbzLLY2");
data.put("email", "gaurav.kumar@example.com");
data.put("contact", "9000090000");
data.put("method", "app");
data.put("provider", "cred ");
data.put("app_present", "false")

method

mandatory

string The method used to make the payment. Here, it must be app.

provider

mandatory if method=app

string Name of the PSP app. Here, it must be cred.

app_present

mandatory if app=cred

boolean Sets the payment flow as collect. Possible values:

  • true: Opens the Cred app on customer's device.
  • false (default): Sends a push notification to customer's device.


Is this integration guide useful?