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.
Advantages
Advantages
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.Step 1: Domain Verification
Step 1: Domain Verification
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.Dashboard Configuration and Verification
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.
-
Log in to the Dashboard and navigate to Account & Settings → International payments (under Payment methods). Click 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.
Step 2: Load the Script
Step 2: Load the Script
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.Running Alongside Standard Checkout
Running Alongside Standard Checkout
If the same page also uses Razorpay Standard Checkout, load The
razorpay.js before checkout.js.HTML
<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.Step 3: Create an Order on Your Server
Step 3: Create an Order on Your Server
You must create a Razorpay order on your server before rendering the Apple Pay button. The The response includes an
order_id returned from this call is passed directly to the web component.Request
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.Step 4: Drop in the Component Tag
Step 4: Drop in the Component Tag
Place the To customise the button appearance, add the optional design attributes: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.
<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
HTML
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.
Step 5: Listen for the Result
Step 5: Listen for the Result
Attach event listeners to the component to handle the payment outcome.That is the whole integration.
JavaScript
Step 6: Verify the Payment Signature on Your Server
Step 6: Verify the Payment Signature on Your Server
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_idrazorpay_order_idrazorpay_signature
Component Reference
Attributes
Attributes
Events
payment.success
payment.success
Fired when the payment completes successfully. The event detail contains:Use these three values to verify the payment on your server before fulfilling the order.
JavaScript
payment.failure
payment.failure
Fired when the payment fails or the customer cancels the payment sheet.
JavaScript
error
error
Fired if the component fails to initialise — for example, due to an invalid attribute or Apple Pay not being enabled for your business account.Check that
JavaScript
key, order-id, method and app-name are all correctly set if you receive this event on load.Error Handling Reference
Every failure — frompayment.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/errorlisteners - Verify the payment signature on your server before fulfilling the order