Skip to main content
Available in🇮🇳 India
Internal Use OnlyThis flow (setting amount/currency after the button click) is meant for businesses where the cart amount is not known at init time. For example, dynamic pricing resolved at click time or deferred shipping/tax calculation. Businesses must refer to the Web JS Integration by default.
The headless JS integration with amount after click is for checkouts where the cart total is only known or finalised at the moment the customer clicks pay. You initialise the Razorpay JS object without amount or currency, then set them right before the payment starts. Know more about Apple Pay.
Use this integration only when your checkout cannot know the cart total at initialisation time. Common scenarios include:
  • Dynamic pricing: The final price is resolved at click time based on real-time inventory, demand or promotions.
  • Deferred shipping/tax calculation: Shipping costs and taxes are calculated after the customer selects their address.
  • Multi-step checkout: The cart total changes based on selections made late in the checkout flow.
For most merchants, the Web JS Integration is simpler and recommended.

Prerequisites

Before starting the integration, ensure you have the following:
  • A Razorpay account with Apple Pay enabled.
  • An existing Razorpay Custom Checkout integration.
  • International Payments enabled on your Razorpay account.
  • Your API Key Id available. Know how to generate API Keys from the Dashboard.
  • An HTTPS-enabled domain (TLS 1.2 or higher). Apple Pay requires a secure context and will not function over HTTP.
  • Server-side capability to create orders via the Razorpay Orders API.
  • Domains verified in the Dashboard for Apple Pay.

Integration Steps

Follow the steps given below.
Verify your checkout domain(s) for Apple Pay before you go live. To find the list of these domains, please log in to the dashboard.
Handy TipOnly domains whitelisted with the accounts service will be visible here. Similar domains are visible as well. Please contact our Support team if you cannot find your Apple Pay showing domain here. You need to whitelist your URL.
Dashboard Configuration and Verification
  • Log in to the Dashboard and navigate to Account & SettingsInternational payments (under Payment methods). Click Apple Pay. Click Apple Pay on the Dashboard
    ImportantThis will only be visible if the business has International payments activated. If you do not have international payments active, you will not see Apple Pay.
  • You will see a list of domains associated with your business account:
    • Verified domains: Ready for Apple Pay.
    • Unverified domains: Need to be verified.
  • Click Verify domains for any unverified domains.
Include the Razorpay Custom Checkout script in your page’s <head> tag.
HTML
Handy TipLoad this script on every page where you intend to use the Apple Pay integration. Existing Custom Checkout merchants already load this script.
Both razorpay.js (headless Apple Pay) and checkout.js (Standard Checkout) register their constructor on the same window.Razorpay global. If your page uses both, whichever script loads last overwrites the other’s constructor on window.Razorpay. Capture the headless constructor as soon as razorpay.js loads, and let checkout.js load after it so window.Razorpay is restored to Standard Checkout’s constructor for the rest of your page.
HTML
If you cannot guarantee this load order (for example, scripts injected dynamically or loaded in parallel), queue the captures instead and resolve them once both scripts have loaded:
JavaScript
Use window.__rzpApplePay (instead of window.Razorpay) to initialise the headless Apple Pay object in Step 3, and leave window.Razorpay untouched for your existing Standard Checkout code.
JavaScript
Initialise Razorpay without passing amount or currency. Use the on_payment_initiate_create_order callback to create the order on your server right before the payment sheet opens.
JavaScript
Watch Out!on_payment_initiate_create_order is where you create the Razorpay order. You must call razorpay.set('order_id', ...) inside it before it resolves — the payment cannot be authorised without an order id.
Register event listeners for payment success and failure.
JavaScript
Check whether the customer’s device supports Apple Pay using canMakePayment(), then set the amount and currency right before triggering the payment using one of the following options.
After a successful payment (the payment.success event fires), verify the payment signature on your server before fulfilling the order.Send the following fields to your backend:
  • razorpay_payment_id
  • razorpay_order_id
  • razorpay_signature
Verify them using the standard Razorpay signature verification process.
Watch Out!Never fulfil an order based solely on the client-side payment.success event. Signature verification ensures the payment was genuinely processed by Razorpay and has not been tampered with.

Error Handling Reference

Every failure — from payment.failure events or a caught exception — carries the same shape:
JavaScript

Quick Checklist

  • Load https://checkout.razorpay.com/v1/razorpay.js
  • Initialise new Razorpay({ ... }) without amount/currency
  • Implement order creation inside on_payment_initiate_create_order
  • Call razorpay.set('amount', ...) / razorpay.set('currency', ...) right before payment starts (click handler or mount()’s onClick)
  • Wire up payment.success / payment.failure handling
  • Test canMakePayment() handling for devices/browsers where Apple Pay is not available
  • Verify the payment signature on your server before fulfilling the order