Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Overview
About Stripe payments
Upgrade your integration
Payments analytics
Online payments
OverviewFind your use caseManaged Payments
Use Payment Links
Build a checkout page
Build an advanced integration
Build an in-app integration
Payment methods
Add payment methods
    Overview
    Payment method integration options
    Manage default payment methods in the Dashboard
    Payment method types
    Cards
    Bank debits
    Bank redirects
    Bank transfers
    Credit transfers (Sources)
    Buy now, pay later
    Real-time payments
    Vouchers
    Wallets
      Alipay
      Amazon Pay
      Apple Pay
        Best practices
        Cartes Bancaires with Apple Pay
        Apple Pay recurring transactions
        Apple Pay merchant tokens
        Apple Pay liability shift, disputes, and refunds
      Cash App Pay
      Google Pay
      GrabPay
      Link
      MB WAY
      MobilePay
      PayPal
      PayPay
      Revolut Pay
      Satispay
      Secure Remote Commerce
      Vipps
      WeChat Pay
    Enable local payment methods by country
    Custom payment methods
Manage payment methods
Faster checkout with Link
Payment interfaces
Payment Links
Checkout
Web Elements
In-app Elements
Payment scenarios
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Other Stripe products
Financial Connections
Crypto
Climate
HomePaymentsAdd payment methodsWallets

Apple Pay

Allow customers to securely make payments using Apple Pay on their iPhone, iPad, or Apple Watch.

Copy page

Supported devices

Refer to Apple’s compatibility documentation to learn which devices support Apple Pay.

Apple Pay is compatible with most Stripe products and features. Stripe users can accept Apple Pay in iOS applications in iOS 9 and above, and on the web in Safari starting with iOS 10 or macOS Sierra. There are no additional fees to process Apple Pay payments, and pricing is the same as for other card transactions.

Apple Pay is available to cardholders at participating banks in supported countries. For more information, refer to Apple’s participating banks documentation.

  • Customer locations

    Worldwide except India

  • Presentment currency

    See supported presentment currencies

  • Payment confirmation

    Customer-initiated

  • Payment method family

    Wallet

  • Recurring payments

    Yes (except Mexico)

  • Payout timing

    Standard payout timing applies

  • Connect support

    Yes

  • Dispute support

    Yes

  • Manual capture support

    Yes

  • Refunds / Partial refunds

    Yes / Yes

Payment flow

Below is a demonstration of the Apple Pay payment flow from your checkout page:

Apple pay payment flow animation showing the Stripe checkout page, the Apple Pay button, and the confirmation dialog while testing.

Using Stripe and Apple Pay versus in-app purchases

For sales of physical goods, services, and certain other things, your app can accept Apple Pay or any other Stripe-supported payment method. Those payments are processed through Stripe, and you only need to pay Stripe’s processing fees. However, sales of digital products, content, and certain other things must use Apple’s in-app purchases. Those payments are processed by Apple and are subject to their transaction fees.

For more information about which sales must use in-app purchases, see the Apple App Store Review Guidelines.

Accept Apple Pay

Stripe offers a variety of methods to add Apple Pay as a payment method. For integration details, select the method you prefer:

With the Stripe iOS SDK, you can accept both Apple Pay and traditional credit card payments. Before starting, you need to be enrolled in the Apple Developer Program. Next, follow these steps:

  1. Set up Stripe
  2. Register for an Apple Merchant ID
  3. Create a new Apple Pay certificate
  4. Integrate with Xcode
  5. Check if Apple Pay is supported
  6. Create the payment request
  7. Present the payment sheet
  8. Submit the payment to Stripe

Set up Stripe
Server-side
Client-side

First, you need a Stripe account. Register now.

Server-side

This integration requires endpoints on your server that talk to the Stripe API. Use the official libraries for access to the Stripe API from your server:

Command Line
Ruby
# Available as a gem sudo gem install stripe
Gemfile
Ruby
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

Client-side

The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above.

To install the SDK, follow these steps:

  1. In Xcode, select File > Add Package Dependencies… and enter https://github.com/stripe/stripe-ios-spm as the repository URL.
  2. Select the latest version number from our releases page.
  3. Add the StripeApplePay product to the target of your app.

Note

For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.

Configure the SDK with your Stripe publishable key on app start. This enables your app to make requests to the Stripe API.

AppDelegate.swift
Swift
import UIKit import StripeApplePay @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { StripeAPI.defaultPublishableKey =
"pk_test_TYooMQauvdEDq54NiTphI7jx"
// do any other necessary launch configuration return true } }

Note

Use your test keys while you test and develop, and your live mode keys when you publish your app.

Register for an Apple Merchant ID

Obtain an Apple Merchant ID by registering for a new identifier on the Apple Developer website.

Fill out the form with a description and identifier. Your description is for your own records and you can modify it in the future. Stripe recommends using the name of your app as the identifier (for example, merchant.com.{{YOUR_APP_NAME}}).

Create a new Apple Pay certificate

Create a certificate for your app to encrypt payment data.

Go to the iOS Certificate Settings in the Dashboard, click Add new application, and follow the guide.

Download a Certificate Signing Request (CSR) file to get a secure certificate from Apple that allows you to use Apple Pay.

One CSR file must be used to issue exactly one certificate. If you switch your Apple Merchant ID, you must go to the iOS Certificate Settings in the Dashboard to obtain a new CSR and certificate.

Integrate with Xcode

Add the Apple Pay capability to your app. In Xcode, open your project settings, click the Signing & Capabilities tab, and add the Apple Pay capability. You might be prompted to log in to your developer account at this point. Select the merchant ID you created earlier, and your app is ready to accept Apple Pay.

Enable the Apple Pay capability in Xcode

Check if Apple Pay is supported

Note

If you’re using PaymentSheet, that class handles the rest for you.

Before displaying Apple Pay as a payment option in your app, determine if the user’s device supports Apple Pay and that they have a card added to their wallet:

CheckoutViewController.swift
Swift
import StripeApplePay import PassKit class CheckoutViewController: UIViewController, ApplePayContextDelegate { let applePayButton: PKPaymentButton = PKPaymentButton(paymentButtonType: .plain, paymentButtonStyle: .black) override func viewDidLoad() { super.viewDidLoad() // Only offer Apple Pay if the customer can pay with it applePayButton.isHidden = !StripeAPI.deviceSupportsApplePay() applePayButton.addTarget(self, action: #selector(handleApplePayButtonTapped), for: .touchUpInside) } // ...continued in next step }

Create the payment request

When the user taps the Apple Pay button, call StripeAPI paymentRequestWithMerchantIdentifier:country:currency: to create a PKPaymentRequest.

Then, configure the PKPaymentRequest to display your business name and the total. You can also collect information like billing details or shipping information.

See Apple’s documentation for full guidance on how to customize the payment request.

CheckoutViewController.swift
Swift
func handleApplePayButtonTapped() { let merchantIdentifier = "merchant.com.your_app_name" let paymentRequest = StripeAPI.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: "US", currency: "USD") // Configure the line items on the payment request paymentRequest.paymentSummaryItems = [ // The final line should represent your company; // it'll be prepended with the word "Pay" (that is, "Pay iHats, Inc $50") PKPaymentSummaryItem(label: "iHats, Inc", amount: 50.00), ] // ...continued in next step }

Present the payment sheet

Create an STPApplePayContext instance with the PKPaymentRequest and use it to present the Apple Pay sheet:

CheckoutViewController.swift
Swift
func handleApplePayButtonTapped() { // ...continued from previous step // Initialize an STPApplePayContext instance if let applePayContext = STPApplePayContext(paymentRequest: paymentRequest, delegate: self) { // Present Apple Pay payment sheet applePayContext.presentApplePay(on: self) } else { // There is a problem with your Apple Pay configuration } }

Apple requires that user gestures trigger the Apple Pay modal (for example, clicking a button or interacting with the form). Make sure your code adheres to the following:

  • Invoke the payment sheet directly with a user activation event.
  • Add the code for the payment sheet at or near the top of your user gesture event handler, before any asynchronous or long-running code.
  • Set a reasonable time limit to call confirmPayment after the user gesture.

Submit the payment to Stripe

Server-side

Make an endpoint that creates a PaymentIntent with an amount and currency. Always decide how much to charge on the server side, a trusted environment, as opposed to the client side. This prevents malicious customers from choosing their own prices.

Command Line
curl
curl https://api.stripe.com/v1/payment_intents \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d "amount"=1099 \ -d "currency"="usd"

Client-side

Implement applePayContext(_:didCreatePaymentMethod:completion:) to call the completion block with the PaymentIntent client secret retrieved from the endpoint above.

After you call the completion block, STPApplePayContext completes the payment, dismisses the Apple Pay sheet, and calls applePayContext(_:didCompleteWithStatus:error:) with the status of the payment. Implement this method to show a receipt to your customer.

CheckoutViewController.swift
Swift
extension CheckoutViewController { func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: StripeAPI.PaymentMethod, paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock) { let clientSecret = ... // Retrieve the PaymentIntent client secret from your backend (see Server-side step above) // Call the completion block with the client secret or an error completion(clientSecret, error) } func applePayContext(_ context: STPApplePayContext, didCompleteWith status: STPApplePayContext.PaymentStatus, error: Error?) { switch status { case .success: // Payment succeeded, show a receipt view break case .error: // Payment failed, show the error break case .userCancellation: // User canceled the payment break @unknown default: fatalError() } } }

Finally, handle post-payment events to do things like sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.

Troubleshooting

If you’re seeing errors from the Stripe API when attempting to create tokens, you most likely have a problem with your Apple Pay Certificate. You’ll need to generate a new certificate and upload it to Stripe, as described on this page. Make sure you use a CSR obtained from your Dashboard and not one you generated yourself. Xcode often incorrectly caches old certificates, so in addition to generating a new certificate, Stripe recommends creating a new Apple Merchant ID as well.

If you receive the error:

You haven’t added your Apple merchant account to Stripe

it’s likely your app is sending data encrypted with a previous (non-Stripe) CSR/Certificate. Make sure any certificates generated by non-Stripe CSRs are revoked under your Apple Merchant ID. If this doesn’t resolve the issue, delete the merchant ID in your Apple account and re-create it. Then, create a new certificate based on the same (Stripe-provided) CSR that was previously used. You don’t need to upload this new certificate to Stripe. When finished, toggle the Apple Pay Credentials off and on in your app to ensure they refresh properly.

App Clips

The StripeApplePay module is a lightweight Stripe SDK optimized for use in an App Clip. Follow the above steps to add the StripeApplePay module to your App Clip’s target.

Note

The StripeApplePay module is only supported in Swift. Objective-C users must import STPApplePayContext from the Stripe module.

Migrating from STPApplePayContext

If you’re an existing user of STPApplePayContext and wish to switch to the lightweight Apple Pay SDK, follow these steps:

  1. In your App Clip target’s dependencies, replace the Stripe module with the StripeApplePay module.
  2. In your code, replace import Stripe with import StripeApplePay.
  3. Replace your usage of STPApplePayContextDelegate with the new ApplePayContextDelegate protocol.
  4. Change your implementation of applePayContext(_:didCreatePaymentMethod:completion:) to accept a StripeAPI.PaymentMethod.
  5. Change your implementation of applePayContext(_:didCompleteWith:error:) to accept an STPApplePayContext.PaymentStatus.
Before
After
import Stripe class CheckoutViewController: UIViewController, STPApplePayContextDelegate { func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: STPPaymentMethod, paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock) { // ... } func applePayContext(_ context: STPApplePayContext, didCompleteWith status: STPPaymentStatus, error: Error?) { // ... } }
import StripeApplePay class CheckoutViewController: UIViewController, ApplePayContextDelegate { func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: StripeAPI.PaymentMethod, paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock) { // ... } func applePayContext(_ context: STPApplePayContext, didCompleteWith status: STPApplePayContext.PaymentStatus, error: Error?) { // ... } }

Recurring payments

In iOS 16 or later, you can adopt merchant tokens by setting the recurringPaymentRequest or automaticReloadPaymentRequest properties on PKPaymentRequest.

CheckoutViewController.swift
Swift
extension CheckoutViewController { func handleApplePayButtonTapped() { let request = StripeAPI.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: "US", currency: "USD") let billing = PKRecurringPaymentSummaryItem(label: "My Subscription", amount: NSDecimalNumber(string: "59.99")) billing.startDate = Date() billing.endDate = Date().addingTimeInterval(60 * 60 * 24 * 365) billing.intervalUnit = .month request.recurringPaymentRequest = PKRecurringPaymentRequest(paymentDescription: "Recurring", regularBilling: billing, managementURL: URL(string: "https://my-backend.example.com/customer-portal")!) request.recurringPaymentRequest?.billingAgreement = "You'll be billed $59.99 every month for the next 12 months. To cancel at any time, go to Account and click 'Cancel Membership.'" request.paymentSummaryItems = [billing] } }

To learn more about how to use recurring payments with Apple Pay, see Apple’s PassKit documentation.

Order tracking

To adopt order tracking in iOS 16 or later, implement the applePayContext(context:willCompleteWithResult:handler:) function in your ApplePayContextDelegate. Stripe calls your implementation after the payment is complete, but before iOS dismisses the Apple Pay sheet.

In your implementation:

  1. Fetch the order details from your server for the completed order.
  2. Add these details to the provided PKPaymentAuthorizationResult.
  3. Call the provided completion handler on the main queue.

To learn more about order tracking, see Apple’s Wallet Orders documentation.

CheckoutViewController.swift
Swift
extension CheckoutViewController { func applePayContext(_ context: STPApplePayContext, willCompleteWithResult authorizationResult: PKPaymentAuthorizationResult, handler: @escaping (PKPaymentAuthorizationResult) -> Void) { // Fetch the order details from your service MyAPIClient.shared.fetchOrderDetails(orderID: myOrderID) { myOrderDetails authorizationResult.orderDetails = PKPaymentOrderDetails( orderTypeIdentifier: myOrderDetails.orderTypeIdentifier, // "com.myapp.order" orderIdentifier: myOrderDetails.orderIdentifier, // "ABC123-AAAA-1111" webServiceURL: myOrderDetails.webServiceURL, // "https://my-backend.example.com/apple-order-tracking-backend" authenticationToken: myOrderDetails.authenticationToken) // "abc123" // Call the handler block on the main queue with your modified PKPaymentAuthorizationResult handler(authorizationResult) } } }

Test Apple Pay

To test Apple Pay, you must use a real credit card number and your test API keys. Stripe recognizes that you’re testing and returns a successful test card token for you to use, so you can make test payments on a live card without charging it.

You can’t save Stripe test cards or Apple Pay test cards to Apple Pay wallets to test Apple Pay.

See also

  • iOS Integration
  • Apple Pay on the Web
  • Apple Pay Best Practices
Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access program.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc