Available in🇮🇳 India
Follow these steps to add Embedded Quick Buy to your Android app. The integration builds on the Android Custom UI SDK. You render your own payment screen, and Razorpay processes the payment.
Already on the Android Custom UI SDK?The steps specific to Quick Buy are 1.3 Create a Customer and 1.4 Fetch Recommended Instruments. All other steps follow the standard Custom UI SDK integration.
1.1 Add the SDK Dependency
Add the Custom UI SDK to your app-levelbuild.gradle file:
build.gradle
minSdkVersion 19 and above.
1.2 Configure the SDK
Add Your API Key and Permissions
Add your API Key ID and the internet permission toAndroidManifest.xml. The <queries> block lets the SDK detect installed UPI apps on Android 11 (API level 30) and above.
AndroidManifest.xml
Add ProGuard Rules
proguard-rules.pro
Add a WebView
The SDK uses a WebView to complete flows such as card 3DS and bank OTP pages. Add a hidden WebView to your payment Activity’s layout and register it with the SDK. Make it visible only while the payment is being submitted.Java
Handy TipsMake sure the device supports TLS v1.1 or v1.2 for PCI compliance. Never log or store card details on the device.
1.3 Create a Customer
Create a customer on your server with the Customers API. You can do this asynchronously, for example when you collect the customer’s details. Use thecustomer_id returned in the response to fetch recommended instruments in step 1.4.
1.4 Fetch Recommended Instruments
CallgetRecommendedInstruments() to get the customer’s recommended payment instruments.
- The response contains up to 3 instruments, ranked by how likely the customer is to complete the payment.
items[0]is the strongest recommendation. - The SDK checks which UPI apps are installed on the device and returns only those.
- The response includes the logos you need to render the Quick Buy button:
app_logo,network_logo_urlandissuer_logo_url. - Create an order first and pass its
order_id, so that all instrument types are eligible. Without anorder_id, the response is limited to UPI intent apps andamountandcurrencybecome mandatory.
Java
Sample Response
Response
Response Parameters
1.5 Create an Order in Server
Create an order on your server using the Orders API when the customer taps the Quick Buy button, or earlier if you pass theorder_id in step 1.4.
Request Parameters
amount mandatory
: integer Payment amount in the smallest currency sub-unit. For example, pass 50000 for ₹500.
currency mandatory
: string The 3-letter ISO currency code. For example, INR.
customer_id mandatory
: string The customer ID returned in step 1.3.
receipt optional
: string Your receipt number for the order. Maximum 40 characters.
notes optional
: object Key-value pairs for additional information. Maximum 15 pairs of 256 characters each.
partial_payment optional
: boolean Set to true to accept partial payments. Defaults to false.
first_payment_min_amount optional
: integer Minimum amount for the first partial payment. Use only when partial_payment is true.
1.6 Initialise Razorpay in Your Activity
Create the SDK instance in your payment Activity. The SDK reads the key from the manifest (step 1.2), or you can pass it in code.Java
1.7 Submit Payment
When the customer taps the Quick Buy button, build the payment data as aJSONObject and pass it to razorpay.submit(). The result is returned to PaymentResultWithDataListener:
onPaymentSuccessfor a successful payment.onPaymentErrorfor a failed payment.
Common Parameters
order_id mandatory
: string The order ID created in step 1.5.
amount mandatory
: integer Payment amount in the smallest currency sub-unit.
currency mandatory
: string The 3-letter ISO currency code. For example, INR.
email mandatory
: string Customer’s email address.
contact mandatory
: string Customer’s phone number.
method mandatory
: string Payment method. Possible values: upi, card, netbanking, wallet or emi.
notes optional
: object Key-value pairs for additional information. Maximum 15 pairs of 256 characters each.
- UPI Intent
- Saved Card
- Netbanking
- Wallet
Pass the
upi_app_package_name returned by getRecommendedInstruments() in step 1.4.Java
Handle the Result
Java
1.8 Store Fields in Your Server
A successful payment returns these fields throughPaymentData. Store them on your server and verify the signature in the next step.
Success Response
razorpay_payment_id
: string Unique identifier of the payment. Returned only for successful payments.
razorpay_order_id
: string Unique identifier of the order.
razorpay_signature
: string Signature used to verify that the payment is authentic.
1.9 Verify Payment Signature
Verify the signature on your server to confirm the payment is authentic. This step is mandatory. Never verify the signature in the app.- Use the
order_idstored on your server. Do not use therazorpay_order_idreturned to the app. - Create an HMAC-SHA256 hex digest of
order_id + "|" + razorpay_payment_idusing your API key secret. - If the digest matches
razorpay_signature, the payment is authentic.
Pseudocode
Java (server-side)
1.10 Verify Payment Status
Confirm that the payment status iscaptured. You can track it in 3 ways:
- Dashboard: Log in to the Dashboard and go to Transactions → Payments. A successful payment has a payment ID and the status Captured.
- Webhooks: Subscribe to payment webhook events for real-time updates.
- API: Poll the Fetch a Payment API with the
razorpay_payment_id.
Handy TipsUse Payment Capture Settings to capture payments automatically.
Next Steps
- Test your integration in Test Mode.
- Complete the go-live checklist.
- Replace your test API keys with live keys when you are ready to go live.