Skip to main content
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.
  1. Create Apple Pay Merchant ID — In the Apple Developer Portal, go to Identifiers → + → Merchant IDs. Use the format merchant.com.yourcompany.app and register.
  2. Share Merchant ID with Razorpay — Send your Merchant ID to your Razorpay point of contact. The team will share a CSR file with you.
  3. 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 the apple_pay.cer.
Watch Out!Certificates expire after 25 months. Set a reminder to renew before expiry.
  1. Share Certificate with Razorpay — Send the apple_pay.cer file back to your Razorpay point of contact for configuration.
  1. Open your .xcodeproj.
  2. Select your app target → Signing & Capabilities.
  3. Click + Capability → Apple Pay.
  4. Tick the Merchant ID created above.
This generates a .entitlements file. Sample output:
Entitlements

Integration Steps

Step 1 — Install via Swift Package Manager

The SDK is distributed as a Swift package at https://github.com/razorpay/razorpay-customui-pod.
  1. In Xcode, select File → Add Package Dependencies…
  2. Paste the package URL: https://github.com/razorpay/razorpay-customui-pod
  3. Under Dependency Rule, choose Exact Version and enter 2.2.0.
  4. Click Add Package.
  5. On the product selection screen, add the RazorpayApplePay library 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

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 the order_id to your iOS app.
Request
The response returns an order_id such as order_CuEzONfnOI86Ab. Pass this to your iOS app.

Step 6 — Load the Payment Button

Apple’s Human Interface Guidelines require the use of PKPaymentButton (or a visually compliant variant). Custom buttons will lead to App Store rejection.
Swift
Button constraints:
  • Use PKPaymentButton, not a generic UIButton with an Apple Pay icon.
  • Do not place text or icons inside it.
  • Respect Apple’s minimum height requirement.
  • Use .automatic style 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 existing razorpay.authorize(options) API with an Apple Pay payload.
Swift

Step 8 — Handle the Payment Result

Swift
Success response keys (in andData):
Response
Failure response keys (in andData):
Response

Step 9 — Verify Payment Signature on Your Server

Always verify the signature on your server before fulfilling the order. Send razorpay_payment_id, razorpay_order_id, and razorpay_signature to your backend for HMAC verification.
Watch Out!Never fulfil an order based solely on the client-side result. Always verify the payment signature server-side.
See the signature verification guide for Node.js and other language samples.

Error Codes

On failure, read the error code as a String 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

Swift

Frequently Asked Questions

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
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.
  • Merchant ID alignment — Does the Merchant ID you passed in options["app"]["apple_pay"]["merchant_identifier"] match the one in your .entitlements and 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?
If all four are correct, check the response in onPaymentError’s andData for the specific failure reason from the backend.