Accepting Apple Pay in Your iOS App

    To submit an app with Apple Pay to the App Store, you need to register a merchant ID with Apple and add the necessary entitlements to your app. This article will help you with every step of the setup process. If you need help after reading this, search our documentation or check out answers to common questions. You can even chat live with other developers in #stripe on freenode.

    Looking to integrate Apple Pay on your website? Read our Apple Pay on the web guide instead.

    Prerequisites

    To begin, you'll need a newer iOS device (iPhone 6 or 6+, iPad Air 2, or iPad mini 3) running iOS 8.1 or later, as well as a Mac with Xcode 6.1 or newer installed. You can install or upgrade Xcode in the Mac App Store.

    You'll also need an Apple Developer Account, as well as a membership in the iOS Developer Program. If you need to become a member, you can do so here.

    Registering for an Apple Merchant ID

    First, you'll need to obtain an Apple Merchant ID. Start by heading to the Registering a Merchant ID page on the Apple Developer website.

    Fill out the form with a description and identifier. Your description is for your own records and can be modified in the future (we recommend just using the name of your app). The idenfitier must be unique (across all apps, not just yours) and can't be changed later (although you can always make another one). We recommend using merchant.com.{your_app_name}. Save this value for later use when developing your app.

    Creating a new Apple Pay certificate

    You need to include a certificate in your app to encrypt outgoing payment data. This involves 3 steps:

    1. Obtain a CSR (certificate signing request) file from Stripe
    2. Use this CSR to generate a certificate through Apple
    3. Upload the certificate back to Stripe

    First, head to the Apple Pay section of the Account Settings page in the Dashboard. Choose "Create New Certificate" and a .certSigningRequest file will automatically download.

    Next, back on the Apple Developer site, visit the Add iOS Certificate page. Choose "Apple Pay Certificate" from the options and click "Continue". On the next page, choose the Merchant ID you created earlier from the dropdown and continue.

    The next page explains that you can obtain a CSR from your Payment Provider (which at this point you've done already) or create one manually. Important note: you must use the CSR provided by Stripe - creating your own won't work. So ignore the directions at the bottom of this page and continue on.

    You'll be prompted to upload a .certSigningRequest file. Choose the file you downloaded from the Dashboard and continue. You'll see a success page, with an option to download your certificate. Download it. Finally, return to the Dashboard and upload this .cer file to Stripe.

    Integrating with Xcode

    The last step of this process is to add the "Apple Pay" capability to your app. In Xcode, open your project settings, choose the "Capabilities" tab, and enable the "Apple Pay" switch. You may be prompted to log in to your developer account at this point. Enable the checkbox next to the merchant ID you created earlier, and you're done!

    Xcode capabilities pane

    Enable the Apple Pay capability in Xcode

    Troubleshooting

    If you're seeing errors from the Stripe API when attempting to create tokens, there's likely something wrong with your Apple Pay Certificate. You'll need to generate a new certificate and upload it to Stripe, as described above. 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, we recommend 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 certs generated by non-Stripe CSRs are revoked under your Apple Merchant ID. If this does not resolve the issue, delete the merchant ID in your Apple account and recreate it. Then, create a new certificate based on the same (Stripe-provided) CSR that was previously used. You do not need to re-upload this new certificate to Stripe. Once done, toggle the Apple Pay Credentials off and on in your app to make sure they refresh properly.

    Next steps

    You're now ready to start writing payment code and charging your users using Apple Pay. For next steps, including code examples, see our iOS tutorial.