Available in🇮🇳 India
Use Razorpay Apple Pay to add Apple Pay to your iOS app. Razorpay handles payment processing; you build your own UI around the Apple Pay button.
SDK VersionThe Apple Pay feature is available in SDK version
2.2.0 and later. As this is a pre-release build, you must pin the exact beta version in Swift Package Manager (SPM’s “Up to Next Major Version” rule does not resolve pre-release tags).Prerequisites
One-Time Setup (Before Code)
Complete this setup once before writing any integration code.Apple Developer Portal Steps
Apple Developer Portal Steps
- Create Apple Pay Merchant ID — In the Apple Developer Portal, go to Identifiers → + → Merchant IDs. Use the format
merchant.com.yourcompany.appand register. - Share Merchant ID with Razorpay — Send your Merchant ID to your Razorpay point of contact. The team will share a CSR file with you.
- Generate Certificate on Apple — In the Apple Developer Portal, open your Merchant ID → Create Certificate under Apple Pay Payment Processing. Upload the
.csr, then download theapple_pay.cer.
- Share Certificate with Razorpay — Send the
apple_pay.cerfile back to your Razorpay point of contact for configuration.
Xcode Steps
Xcode Steps
- Open your
.xcodeproj. - Select your app target → Signing & Capabilities.
- Click + Capability → Apple Pay.
- Tick the Merchant ID created above.
.entitlements file. Sample output:Entitlements
Integration Steps
Step 1 — Install via Swift Package Manager
The SDK is distributed as a Swift package athttps://github.com/razorpay/razorpay-customui-pod.
- In Xcode, select File → Add Package Dependencies…
- Paste the package URL:
https://github.com/razorpay/razorpay-customui-pod - Under Dependency Rule, choose Exact Version and enter
2.2.0. - Click Add Package.
- On the product selection screen, add the
RazorpayApplePaylibrary to your app target, then click Add Package.
RazorpayApplePay automatically pulls in its dependencies (RazorpayCustom, RazorpayCore) — you do not need to add those separately.
Step 2 — Import and Conform to the Payment Completion Protocol
In your checkout view controller:Swift
Step 3 — Initialise the SDK with the Apple Pay Plugin
Swift
Initialisation Parameters
Initialisation Parameters
Step 4 — Check if the Customer Can Pay
Call this before showing your Apple Pay button. It checks whether the user can pay via Apple Pay on their device.Swift
Step 5 — Create an Order on Your Server
Create a Razorpay order via the Orders API on your backend and send theorder_id to your iOS app.
Request
order_id such as order_CuEzONfnOI86Ab. Pass this to your iOS app.
Order Parameters
Order Parameters
Step 6 — Load the Payment Button
Apple’s Human Interface Guidelines require the use ofPKPaymentButton (or a visually compliant variant). Custom buttons will lead to App Store rejection.
Swift
- Use
PKPaymentButton, not a genericUIButtonwith an Apple Pay icon. - Do not place text or icons inside it.
- Respect Apple’s minimum height requirement.
- Use
.automaticstyle on iOS 14+ for automatic light/dark mode adaptation.
Test on a Real DeviceRun on a physical iOS device — transactions cannot complete on the simulator. Tap your Apple Pay button, authenticate with Face ID or Touch ID, then confirm the payment record appears in the Razorpay Dashboard.
Step 7 — Trigger the Payment on User Tap
This call must be made in response to a user gesture (such as a button tap). Use the existingrazorpay.authorize(options) API with an Apple Pay payload.
Swift
Payment Parameters
Payment Parameters
Step 8 — Handle the Payment Result
Swift
andData):
Response
andData):
Response
Step 9 — Verify Payment Signature on Your Server
Always verify the signature on your server before fulfilling the order. Sendrazorpay_payment_id, razorpay_order_id, and razorpay_signature to your backend for HMAC verification.
See the signature verification guide for Node.js and other language samples.
Error Codes
On failure, read the error code as aString from response["error"]["code"] inside the andData dictionary passed to onPaymentError.
Handy TipsThe
code: Int32 parameter of onPaymentError is always 0 for Apple Pay — the actionable code is the String inside andData.Complete Working Example
- UIKit
- SwiftUI
Swift
Frequently Asked Questions
I use a table view or collection view where payment methods expand on selection. How does the plugin fit?
I use a table view or collection view where payment methods expand on selection. How does the plugin fit?
The plugin separates detection from payment. Use
canMakePayment to decide whether to include the Apple Pay row at all. When the user selects that row, show the Apple Pay button. When they tap your CTA, call razorpay.authorize(options) with the Apple Pay payload.Swift
Do I need to import PassKit?
Do I need to import PassKit?
Yes. PassKit provides Apple’s
PKPaymentButton for the button UI. It is part of iOS, so it adds no dependency weight. You will also need to import WebKit since Custom Checkout init requires a WKWebView instance.The Apple Pay sheet appears but the transaction always fails. What should I check?
The Apple Pay sheet appears but the transaction always fails. What should I check?
- Merchant ID alignment — Does the Merchant ID you passed in
options["app"]["apple_pay"]["merchant_identifier"]match the one in your.entitlementsand the one uploaded to the Razorpay Dashboard? - Certificate uploaded — Is the CSR-signed certificate for that Merchant ID present in the Razorpay Dashboard?
- Network match — Are you testing with a card whose network is enabled for your Razorpay account?
- Backend support — Is Apple Pay enabled for your account in the Razorpay Dashboard?
onPaymentError’s andData for the specific failure reason from the backend.