Available in🇮🇳 India🇲🇾 Malaysia
The headless JS integration gives you full control over the Apple Pay button and payment flow. You initialise the Razorpay JS object with the amount and currency at start, then check eligibility and trigger the payment yourself. Know more about Apple Pay.
Availability in MalaysiaApple Pay on Custom Checkout is available on the web, on Safari (iPhone, iPad and Mac) and Chrome (Mac). It is not yet available for native mobile app integrations, such as the iOS Custom SDK or React Native. Apple Pay does not support recurring payments, and there is no Test Mode — your first Apple Pay payment is a live one.
Advantages
Advantages
Integrating Apple Pay using the headless JS SDK offers you the following advantages:
- Full control: Render your own button or let Razorpay render one for you using
mount(). - Flexible initialisation: Pass amount and currency at init time when the cart total is known upfront.
- Device-aware eligibility: Use
canMakePayment()to check Apple Pay support before showing the button. - Event-driven results: Handle payment success, failure and errors through event listeners.
- No extra script for existing merchants: The SDK ships with the Custom Checkout script you already use.
Prerequisites
Before starting the integration, ensure you have the following:- Apple Pay enabled on your account, along with every domain your customers see at checkout. Contact the Support team to enable it.
- An existing Razorpay Curlec Custom Checkout integration.
- Cards enabled on your Razorpay Curlec account in Live Mode. Apple Pay is processed as a card payment.
- 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 Curlec Orders API.
Integration Steps
Follow the steps given below.Step 1: Register Your Domains
Step 1: Register Your Domains
Apple Pay appears only on domains we have added for your account. Before you go live, send our Support team every domain your customers see in the address bar at checkout, one per line. For example,
payment.store.com and checkout.store.com are two separate domains.You do not need to host a verification file or verify domains on the Dashboard. We register your domains with Apple and confirm once Apple Pay is live.Handy TipsA missing domain is the most common reason the Apple Pay button does not appear. When you add a new website, send us its address — Apple Pay will not appear on it until we add it.
Step 2: Load the Script
Step 2: Load the Script
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.
Running Alongside Standard Checkout
Running Alongside Standard Checkout
Both 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:Use
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
JavaScript
window.__rzpApplePay (instead of window.Razorpay) to instantiate the headless Apple Pay object in Step 3, and leave window.Razorpay untouched for your existing Standard Checkout code.JavaScript
Step 3: Initialise with Amount and Currency
Step 3: Initialise with Amount and Currency
Pass the amount and currency when you initialise Razorpay. Use the
on_payment_initiate_create_order callback to create the order on your server right before the payment sheet opens.JavaScript
Step 4: Listen for the Result
Step 4: Listen for the Result
Register event listeners for payment success and failure.
JavaScript
Step 5: Check Availability and Trigger the Payment
Step 5: Check Availability and Trigger the Payment
Check whether the customer’s device supports Apple Pay using
canMakePayment(), then trigger the payment using one of the following options.- Option 1: mount() (Recommended)
Use
mount() to have Razorpay render an Apple Pay button into a container element you provide. This is the recommended default — it needs the least code, and the SDK starts the Apple Pay session on click and handles the payment for you.JavaScript
mount() creates the button, appends it to the container and wires up the click to payment lifecycle for you. The result still comes via the payment.success / payment.failure events from Step 3.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
Error Handling Reference
Every failure — frompayment.failure events or a caught exception — carries the same shape:
JavaScript
Quick Checklist
- Load
https://checkout.razorpay.com/v1/razorpay.js - Initialise
new Razorpay({ amount, currency, ... }) - Implement order creation inside
on_payment_initiate_create_order - Wire up
payment.success/payment.failurehandling - Test
canMakePayment()handling for devices/browsers where Apple Pay is not available - Verify the payment signature on your server before fulfilling the order