Skip to main content
Available in🇮🇳 India
Follow these steps to add Embedded Quick Buy to your Flutter app. The integration builds on the Flutter Custom UI SDK. You render your own payment UI, and Razorpay processes the payment.
Already on the Flutter 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 Flutter integration.
1.1 Install the SDK. 1.2 Add ProGuard Rules. 1.3 Create a Customer. New for Quick Buy. 1.4 Fetch Recommended Instruments. New for Quick Buy. 1.5 Create an Order in Server. 1.6 Import the Razorpay Module. 1.7 Submit Payment. 1.8 Store Fields in Your Server. 1.9 Verify Payment Signature. 1.10 Verify Payment Status.

1.1 Install the SDK

Add the Razorpay Flutter Custom UI SDK to the dependencies in your app’s pubspec.yaml file:
pubspec.yaml
Run this command in your app’s root directory to install the package:
Terminal

Minimum Requirements

1.2 Add ProGuard Rules

If you use ProGuard on Android, add these rules so that the SDK classes are not obfuscated:
proguard-rules.pro

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 the customer_id returned in the response to fetch recommended instruments in step 1.4.
Call getRecommendedInstruments() 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. If no UPI app is installed and there is no other recommendation, items is empty. Open your regular checkout in that case.
  • The response includes the logos you need to render the Quick Buy button.
  • Pass the order_id so that all instrument types are eligible. Without an order_id, the response is limited to UPI intent apps.
  • Pass the customer’s contact number in customer.contact. It is mandatory by default, although this depends on your account configuration.
Dart
Watch Out!
  • Always show a Change payment method option next to the Quick Buy button. It should open the full Razorpay Checkout of your existing integration, Custom or Standard. Know more about the Flutter Standard integration.
  • If items is empty, or the call fails, show your regular checkout instead of the Quick Buy button.

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 the order_id in step 1.4.
Watch Out!Create an order for every payment, server-side, using your API Key ID and secret. Payments made without an order_id cannot be captured and are automatically refunded.
Request

1.6 Import the Razorpay Module

Import the Razorpay Custom UI module into your widget, create an instance and register the payment event listeners:
Dart

1.7 Submit Payment

When the customer taps the Quick Buy button, call submit() with the payment options for the recommended instrument. For a recommended UPI app, pass method: 'upi', _[flow]: 'intent' and the app’s package name in upi_app_package_name:
Dart
For other payment methods, see the Flutter Custom UI payment methods.

1.8 Store Fields in Your Server

A successful payment returns these fields to your _onPaymentSuccess handler. 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.
  1. Use the order_id stored on your server. Do not use the razorpay_order_id returned to the app.
  2. Create an HMAC-SHA256 hex digest of order_id + "|" + razorpay_payment_id using your API key secret.
  3. If the digest matches razorpay_signature, the payment is authentic.
Pseudocode
Watch Out!Always verify the signature on your server, never in the Flutter app. Never ship your API key secret in the app bundle.
Java (server-side)

1.10 Verify Payment Status

Confirm that the payment status is captured. 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.
  • Set up webhooks for real-time payment events.
  • Replace your test API keys with live keys when you are ready to go live.