Skip to main content
Available in🇮🇳 India
The <razorpay-checkout> web component offers you the option to embed an Apple Pay button directly on your checkout page with minimal JavaScript. The component renders its own button, checks Apple Pay eligibility automatically and reports results via DOM events. Know more about Apple Pay.
Integrating Apple Pay using the web component offers you the following advantages:
  • Minimal code: Drop in the HTML tag and wire up event listeners. No JavaScript setup needed for button rendering.
  • Customisable appearance: Configure the button theme, label, width and height using component attributes.
  • Device-aware rendering: The component automatically checks device eligibility and only renders the button when Apple Pay is supported.
  • Seamless event handling: Built-in events for payment success, failure and component errors integrate directly with your existing checkout logic.
  • No extra script for existing merchants: The component ships with the Custom Checkout script you already use.

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. This script registers the <razorpay-checkout> web component and makes it available for use in your HTML.
HTML
Handy TipLoad this script on every page where you intend to render the Apple Pay button. The script must be loaded before the <razorpay-checkout> component is placed in the DOM. Existing Custom Checkout merchants already load this script and do not need to add a new one.
If the same page also uses Razorpay Standard Checkout, load razorpay.js before checkout.js.
HTML
The <razorpay-checkout> web component is self-contained — it does not read from or write to window.Razorpay. So once checkout.js finishes loading and sets up window.Razorpay for Standard Checkout, no restore step is needed on your end; both integrations continue to work independently on the same page.
You must create a Razorpay order on your server before rendering the Apple Pay button. The order_id returned from this call is passed directly to the web component.
Request
The response includes an id field (for example, order_XXXXXXXXXX). Pass this value to your frontend to use as the order-id attribute on the component.The parameter descriptions and errors are present in the Create an Order API.
Place the <razorpay-checkout> component in your HTML at the exact location where you want the Apple Pay button to render. The button loads inline at the position of this component.
HTML
To customise the button appearance, add the optional design attributes:
HTML
The component fetches order details as soon as it is attached, checks Apple Pay eligibility and renders the button automatically once ready. No JavaScript setup is needed for that part.
Handy TipThe component checks device eligibility on mount and renders the Apple Pay button only if the customer’s device supports it. If Apple Pay is not available, nothing is rendered — no additional conditional logic is needed on your end.
Attach event listeners to the component to handle the payment outcome.
JavaScript
That is the whole integration.
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.

Component Reference

Events

Fired when the payment completes successfully. The event detail contains:
JavaScript
Use these three values to verify the payment on your server before fulfilling the order.
Fired when the payment fails or the customer cancels the payment sheet.
JavaScript
Fired if the component fails to initialise — for example, due to an invalid attribute or Apple Pay not being enabled for your business account.
JavaScript
Check that key, order-id, method and app-name are all correctly set if you receive this event on load.

Error Handling Reference

Every failure — from payment.failure or the error event — carries the same shape:
JavaScript

Quick Checklist

  • Load https://checkout.razorpay.com/v1/razorpay.js
  • Create the order on your server before rendering the tag
  • Add <razorpay-checkout> with required attributes
  • Wire up payment.success / payment.failure / error listeners
  • Verify the payment signature on your server before fulfilling the order