Available in🇮🇳 India
Apple Pay Component integration lets you embed the Apple Pay button directly on your checkout page using the <razorpay-checkout> web component. This gives you full control over button placement and styling while Razorpay handles the underlying payment flow. The component is part of Razorpay Custom Checkout, so existing Custom Checkout merchants do not need to load any additional script. Know more about Apple Pay.
Advantages
Advantages
Integrating Apple Pay using the Component method offers you the following advantages:
- Customisable appearance: Configure the button theme, label, width and height to match your brand using the component attributes.
- Reduced friction: Eliminate manual card entry with biometric authentication (Face ID/Touch ID).
- Enhanced security: Benefit from Apple’s tokenisation and Razorpay signature verification.
- Device-aware rendering: The component automatically checks device eligibility and only renders the button when Apple Pay is supported — no additional logic required on your end.
- 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.
- Log in to the Razorpay Dashboard.
- Navigate to Account & Settings → Payment Methods → Apple Pay.
- 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.
- A compatible device or browser for testing: Safari on iOS 10+ / macOS Sierra+ or Chrome/Edge with Apple Pay configured in Wallet.
- Apple Pay domain verification completed for your checkout domain (covered in Step 1 below).
Integrate Apple Pay via Component
Follow the steps given below.Step 1: Domain Verification
Step 1: Domain Verification
Before Apple Pay can render on your domain, you must host a domain association file and register the domain with Razorpay.Domain Verification ProcessFor example, if your domain is For example, Express (Node.js):
-
Download the domain association file.
- Log in to the Razorpay Dashboard.
- Navigate to Account & Settings → Payment Methods → Apple Pay.
- Download the
apple-developer-merchantid-domain-associationfile.
- Host the file on your server at the exact path below:
https://www.yourstorename.com, the file must be accessible at:-
Ensure correct server configuration:
- The file must return HTTP 200 — no 301, 302 or any other 3xx redirects.
- The URL must not contain a trailing slash.
- Serve the file with
Content-Type: text/plainorapplication/octet-stream. - The file must not be behind authentication or a proxy.
Bash
JavaScript
- Verify the file is accessible. Visit the URL in your browser and confirm you see the file content (a hex string). If you see a 404, redirect or login page, fix the hosting configuration before proceeding.
-
Register the domain in the Razorpay Dashboard.
- Go to Account & Settings → Payment Methods → Apple Pay.
- Enter your domain (for example,
merchant-website.com). - Click Verify. Razorpay will confirm the file is accessible at the expected URL.
- Domain status changes to Verified once the file is correctly configured.
Step 2: Add the Razorpay Script
Step 2: Add the Razorpay Script
Include the Razorpay Custom Checkout script in your page’s
<head> tag. This is the same script used for Custom Checkout; it 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.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: Render the Component and Handle Events
Step 4: Render the Component and Handle Events
Place the To customise the button appearance, add the optional design attributes:Attach event listeners to the component:React 19 ExampleReact 19 has native custom element support, so event handlers work directly on 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. Attach event listeners to handle the payment outcome.HTML
HTML
JavaScript
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.
<razorpay-checkout> component.React 19 Implementation
React 19 Implementation
JavaScript
Step 5: Verify the Payment Signature on Your Server
Step 5: 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
NoteAttributes use kebab-case to match common HTML/CSS conventions and to avoid clashes with JavaScript objects.
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.Testing
Testing on Real Apple Devices
Testing on Real Apple Devices
To test the full payment flow on Apple hardware:
- Use your
rzp_test_*key. Test payments will not charge real money. - Use a real Apple device (iPhone, iPad or Mac) with Apple Pay configured in the Wallet app.
- Add a sandbox Apple Pay card via the Wallet app using an Apple sandbox tester account.
- Supported test card numbers are listed in Apple’s sandbox testing documentation.
Go-live Checklist
Go-live Checklist
Before launching Apple Pay on your live site, confirm the following:
- The Apple Pay button appears correctly on supported devices.
- The button does not appear on unsupported devices or browsers.
- Clicking the button opens the Apple Pay payment sheet as expected.
- Completing a payment fires
payment.successwith validrazorpay_payment_id,razorpay_order_idandrazorpay_signature. - Cancelling the payment sheet fires
payment.failurewith codePAYMENT_CANCELLED. - Server-side signature verification succeeds for completed payments.
- The
errorevent does not fire on component load in your production environment.
Best Practice: Apple Pay with iFramesAs a best practice, if you want to show Apple Pay in an iframe element when the shopper is using Safari as their browser:
- For shoppers on Safari 17 and later: add the
allowattribute to the iframe to let the iframe communicate correctly with Apple Pay APIs:<iframe allow="payment"></iframe> - Safari 17 is available on iOS 17 and later and macOS 12 and later.
- For shoppers on Safari 16 or earlier: match the iframe origin and your top-level origin. The protocols, hosts (full domain name) and ports, when specified, must be the same for both pages.
Frequently Asked Questions
Why is my Apple Pay domain verification failing in the Dashboard?
Why is my Apple Pay domain verification failing in the Dashboard?
- The verification file is not returning HTTP 200 — check for 301 or 302 redirects.
- The file path is not exactly
/.well-known/apple-developer-merchantid-domain-association(case-sensitive). - The file is not accessible over HTTPS.
- A CDN is serving a cached or incorrect version — purge your CDN cache and retry.
- The file requires authentication or is behind a proxy.
Is it safe to create the Razorpay order on the client side?
Is it safe to create the Razorpay order on the client side?
No. Orders must always be created server-side using your secret API key. Never expose your secret key in client-side code. Only the
order_id (not the secret key) should be passed to the frontend and used as the order-id attribute on the component.