Available in🇮🇳 India
Follow these steps to add Embedded Quick Buy to your mobile website. The integration builds on Razorpay Custom Checkout and shows a customer’s recommended saved card or UPI app on your product or cart page, before the full checkout opens.
Already on Custom Checkout?If you have already integrated Razorpay Custom Checkout on your mobile website, the only new step is 1.5 Fetch Recommended Instruments. Make sure you also create customers (step 1.2), as Quick Buy needs them. All other steps stay the same.
1.1 Include razorpay.js in Your Webpage
Add therazorpay.js script to the <head> section of every page where the Quick Buy button appears:
HTML
Handy TipsAlways load the script directly from
https://checkout.razorpay.com/v1/razorpay.js. Do not host it yourself. This way your integration automatically receives the latest updates and bug fixes.1.2 Create a Customer
Create a customer on your server with the Customers API. You can do this asynchronously, for example when the customer registers or starts checkout. Use thecustomer_id returned in the response to fetch recommended instruments in step 1.5.
1.3 Create an Order in Server
Create an order on your server using the Orders API. Create the order before you fetch recommended instruments, so that all instrument types are eligible.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.2.
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.
1.4 Instantiate Custom Checkout
Create a Razorpay instance with your API Key ID. Know more about instantiating Custom Checkout.JavaScript
1.5 Fetch Recommended Instruments
CallRazorpay.getRecommendedInstruments() to get the customer’s recommended payment instruments. On mobile web, this is a JavaScript function in razorpay.js.
- 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 response includes the logos you need to render the Quick Buy button.
- Pass the
order_idfrom step 1.3. If you do not, the response is limited to UPI intent apps andamountandcurrencybecome mandatory. - Pass the
customer_id. If you do not have one, pass the customer’s contact number incustomer.contact.
JavaScript
Sample Response
Response
Response Parameters
1.6 Submit Payment
When the customer taps the Quick Buy button, callrazorpay.createPayment() inside the click event listener. Pass the fields for the recommended instrument’s method, for example the saved card token or the UPI app. Use the same createPayment() payloads as your existing Custom Checkout integration. Know more about submitting payment details.
1.7 Store Fields in Your Server
A successful payment returnsrazorpay_payment_id, razorpay_order_id and razorpay_signature. Store these on your server. Know more about storing fields in your server.
1.8 Verify Payment Signature
Verify the signature on your server to confirm the payment is authentic. This step is mandatory. Know more about verifying the payment signature.1.9 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.
- Set up the full checkout as the fallback for customers who tap Change payment method.
- Replace your test API keys with live keys when you are ready to go live.