Feature RequestThis is an on-demand feature. Please fill out the form to get this feature activated on your account. to get this feature activated on your account.
Advantages
Integrating Apple Pay using the Web Component Integration method offers you the following advantages:- Customisable Appearance: Configure button colour scheme, type, width and height to match your brand.
- 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 allow straightforward integration with your existing checkout logic.
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.
- Ensure you have your API
Key idandKey Secretreadily 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 Web Component
Follow the steps given below: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.Step 2: Add the Razorpay Script
Include the Razorpay script in your page’s “ tag. This registers the ```` 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 ```` component is placed in the DOM.
Step 3: Create an Order on Your Server
You must create a Razorpay order on your server before rendering the Apple Pay button. Theorder_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 Web Component and Handle Events
Place the “ 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
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.React 19 ExampleReact 19 has native custom element support, so event handlers work directly on the “ component.React 19 Implementation
JavaScript
Step 5: Verify the Payment Signature on Your Server
After a successful payment (thepaymentsuccess event fires), you must 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
Attribute | Required | Default | Description
rzp-key | Yes | — | Your Razorpay key id (rzp_test_* or rzp_live_*).
order-id | Yes | — | Razorpay order id created server-side (for example, order_XXXXXXXXXX).
method | Yes | — | Must be set to apple_pay.
customer-contact-number | Yes | — | Customer’s phone number in E.164 format (for example, +919876543210).
brand-color | No | — | Hex colour for theming (for example, #528FF0).
button-width | No | 100px | Button width — any valid CSS value (for example, 300px).
button-height | No | 32px | Button height — any valid CSS value (for example, 44px).
button-color-scheme | No | dark | Button background. dark for dark background with light text, light for light background with dark text.
button-type | No | pay | Button label. pay for “Pay with Apple Pay”, buy for “Buy with Apple Pay”, plain for logo only or checkout for “Check out with Apple Pay”.
Events
paymentsuccess
Fired when the payment completes successfully. The event detail contains the following fields:JavaScript
paymentfailure
Fired when the payment fails or the customer cancels the payment sheet.JavaScript
Code | When
PAYMENT_CANCELLED | Customer dismissed the Apple Pay payment sheet
PAYMENT_FAILED | Payment could not be completed
INTERNAL_ERROR | An unexpected error occurred
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.JavaScript
rzp-key, order-id and method are all correctly set if you receive this event on load.
Testing
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
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
paymentsuccessevent with validrazorpay_payment_id,razorpay_order_idandrazorpay_signature. - Cancelling the payment sheet fires
paymentfailureevent with codePAYMENT_CANCELLED. - Server-side signature verification succeeds for completed payments.
- The
errorevent does not fire on component load in your production environment.
Frequently Asked Questions
1. Why is the Apple Pay button not appearing on my checkout page?
If the Apple Pay button is not appearing, check for the following common issues:- Domain verification has not been completed or the association file is no longer accessible.
- The customer’s device or browser does not support Apple Pay.
- Apple Pay is not enabled on your Razorpay account.
- The
rzp-key,order-idormethodattribute on the component is missing or invalid, check for theerrorevent firing on load.
2. Why is my Apple Pay domain verification failing in the Dashboard?
Domain verification failures typically occur due to the following reasons:- 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.
3. The Apple Pay button appears but the payment sheet does not open. What should I do?
This typically indicates that domain verification has expired or the association file has been removed from your server. Verify that the file is still accessible at the exact URL and re-verify the domain in the Razorpay Dashboard if necessary.4. 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 theorder_id (not the secret key) should be passed to the frontend and used as the order-id attribute on the component.