How to use apple pay on safari iphone

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.

How to use apple pay on safari iphone

Using Stripe and Apple Pay versus in-app purchases

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.

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:

Native iOS

React Native iOS

Web

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 StripeServer-sideClient-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:

Ruby

Python

PHP

Java

Node

Go

.NET

Command Line

# For detailed setup, see our quickstarts at https://stripe.com/docs/development/quickstart bundle add stripe

Client-side

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

Swift Package Manager

CocoaPods

Carthage

Manual Framework

To install the SDK, follow these steps:

  1. In Xcode, select File > Add Packages… and enter

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

    "pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

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

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.

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

Swift

Objective-C

AppDelegate.swift

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

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,

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

2).

Create a new Apple Pay certificate

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.

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

Note that one CSR file mist be used to issue exactly one certificate. If you switch your Apple Merchant ID, you must go to the Dashboard’s Apple Pay Settings 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.

How to use apple pay on safari iphone

Enable the Apple Pay capability in Xcode

Check if Apple Pay is supported

If you’re using

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

3 or

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

4, 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:

Swift

Objective C

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 }

Create the payment request

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

Then, configure the

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

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

Swift

Objective C

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 }

Present the payment sheet

Create an STPApplePayContext instance with the

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

5 and use it to present the Apple Pay sheet:

Swift

Objective C

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

Ruby

Python

PHP

Java

Node

Go

.NET

Command Line

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

sk_test_Ou1w6LVt3zmVipDVJsvMeQsc

: \ -d "amount"=1099 \ -d "currency"="usd"

Client-side

Payment Intents API

Payment Intents API (Server-side confirmation)

Implement

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

7 to call the completion block with the PaymentIntent client secret retrieved from the endpoint above.

After you call the completion block,

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

8 completes the payment, dismisses the Apple Pay sheet, and calls

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

9 with the status of the payment. Implement this method to show a receipt to your customer.

Swift

Objective C

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

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 }

0 module is a lightweight Stripe SDK optimized for use in an App Clip. Follow the above steps to add the

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 }

0 module to your App Clip’s target.

The

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 }

0 module is only supported in Swift. Objective-C users must import

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

8 from the

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 }

4 module.

Migrating from STPApplePayContext

If you’re an existing user of

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

8 and wish to switch to the lightweight Apple Pay SDK, follow these steps:

  1. In your App Clip target’s dependencies, replace the

    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 }

    4 module with the

    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 }

    0 module.
  2. In your code, replace

    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 }

    8 with

    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 }

    9.
  3. Replace your usage of

    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 }

    0 with the new

    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 }

    1 protocol.
  4. Change your implementation of

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

    "pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

    7 to accept a

    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 }

    3.
  5. Change your implementation of

    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 }

    4 to accept an

    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 }

    5.

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

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 }

6 or

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 }

7 properties on

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

5.

Swift

Objective C

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

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 }

9 function in your

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 }

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

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

    1.
  3. Call the provided completion handler on the main queue.

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

Swift

Objective C

CheckoutViewController.swift

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

"pk_test_GvF3BSyx8RSXMK5yAFhqEd3H"

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

0

Testing Apple Pay

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.

Can Safari use Apple Pay?

You can easily and securely shop on your Mac in Safari using Apple Pay. Look for Apple Pay when you check out, then complete your purchase using your Mac with Touch ID, iPhone (iOS 10 or later), or Apple Watch (watchOS 3 or later).

Why does Apple Pay not work on Safari?

Activate Apple Pay in Safari If you keep running into the same issue while making web purchases on your Mac, select Safari > Preferences > Privacy on the macOS menu bar and ensure that the checkbox next to Allow websites to check for Apple Pay and Apple Card is active.

How do I set up Apple Pay on Safari?

How to add a debit or credit card for Apple Pay on your Mac or iPad.
Open Wallet settings on your device. On your Mac model with Touch ID, go to System Preferences > Wallet & Apple Pay. ... .
Tap Add Card. 3,4.
Follow the steps on the screen to add a card..
Verify your information with your bank or card issuer..

Can I use Apple Pay on a website on my phone?

How do I use Apple Pay? You can use Apple Pay to make purchases in stores, on websites, and in apps.