How to make a new apple pay

Set up your payment method.


Make sure you're running the latest version of iOS.

Step 1

In iPhone, go to Settings. Tap on your Apple ID and select Payment & Shipping. You might be asked to sign in.1

Step 2

Tap Add Payment Method.

Step 3

Select your preferred payment method. Easily add, update, reorder or remove it at any time.

Discover ways to get more from your device.

App Store. Transform the way you do anything with apps that help you create, learn, play games or just
get more done.

Learn more

Apple Music. Discover new tracks and curated playlists, listen to your existing music library and follow along to lyrics while you listen. All ad‑free. Online or off.

Learn more

Apple TV+. Watch critically acclaimed Apple Original shows and movies from the most creative minds in TV and film.

Learn more

Apple Arcade. Get unlimited access to ad‑free games from all your favorite genres, with no in‑app purchases.

Learn more

iCloud+. Get plenty of space for the things that matter. Store your photos, videos, files and more across all your devices.

Learn more

Apple One. The easiest way to get all your favorite Apple services at one incredible price.

Learn more

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 the pricing is the same as other card transactions.

Apple Pay is compatible with most Stripe products and features (for example, subscriptions). Use it to accept payments for physical or digital goods, donations, subscriptions, and more (you can’t use Apple Pay instead of in-app purchases though).

Apple Pay is available to cardholders at participating banks in supported countries. Refer to Apple’s participating banks documentation to learn which banks and countries are supported.

Apple Pay doesn’t replace Apple’s In-App Purchase API. You can use any of Stripe’s supported payment methods and Apple Pay in your iOS app to sell physical goods (for example, groceries and clothing) or for services your business provides (for example, club memberships and hotel reservations). These payments are processed through Stripe and you only need to pay Stripe’s processing fee.

Apple’s developer terms require their In-App Purchase API be used for digital “content, functionality, or services,” such as premium content for your app or subscriptions for digital content. Payments made using the In-App Purchase API are processed by Apple and subject to their transaction fees.

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

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:

Client-side

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

To install the SDK, follow these steps:

  1. In Xcode, select File > Swift Packages > Add Package Dependency 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.

When your app starts, configure the SDK with your Stripe publishable key so that it can make requests to the Stripe API.

import UIKit import Stripe @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { StripeAPI.defaultPublishableKey =

"pk_test_51BTUDGJAJfZb9HEBwD...idTHE67IM007EwQ4uN3""pk_test_51BTUDGJAJfZb9HEBwDg86TN1KNprHjkfipXmEDMb0gSCassK5T3ZfxsAbcgKVmAIXF7oZ6ItlZZbXO6idTHE67IM007EwQ4uN3"

// do any other necessary launch configuration return true } }

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

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 certificate for your app to encrypt payment data.

In the Dashboard’s Apple Pay Settings, click Add new application and follow the guide there.

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.

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

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 }

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

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 }

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

CheckoutViewController.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 } }

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.

curl https://api.stripe.com/v1/payment_intents \ -u

sk_test_tR3PYbcVNZZ796tH88S4VQ2u

: \ -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

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: STPPaymentStatus, 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.

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.

import Stripe class CheckoutViewController: UIViewController, STPApplePayContextDelegate { func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: STPPaymentMethod, paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock) { // ... }

import StripeApplePay class CheckoutViewController: UIViewController, ApplePayContextDelegate { func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: StripeAPI.PaymentMethod, paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock) { // ... }

Recurring payments

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

CheckoutViewController.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

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) } } }

Stripe test card information can’t be saved to Wallet in iOS. Instead, Stripe recognizes when you’re using your test API keys and returns a successful test card token for you to use. This allows you to make test payments using a live card without it being charged.

How do I reset Apple Pay?

iPhone: Go to Settings > Wallet & Apple Pay > scroll down to Transaction Defaults and update your shipping address, email, and phone number. Apple Watch: In the Apple Watch app on your iPhone, tap Wallet & Apple Pay > scroll down to Transaction Defaults and update your shipping address, email, and phone number.

How do I add new Apple Pay?

Set up.
iPhone. Open the Wallet app. and tap to add a card..
iPad. Go to Settings. Wallet & Apple Pay. and tap Add Card..
Mac. On models with Touch ID, go to System Preferences. Wallet & Apple Pay and. tap Add Card..

Can I have 2 Apple Pay cards?

Yes, up to eight cards can be added to Apple Pay on a single device. The first card added to the device will become the default card, but you can change the default card.