# Take payments with Apple Pay in your app

> Have an Agent register a merchant ID, turn on Apple Pay for your app, and make the payment processing certificate from the file your payment provider gives you.

Source: https://air.build/docs/build/take-payments-with-apple-pay/

Apple Pay lets people pay in your app with the cards in their Wallet. On your Apple team, the app needs three things: a merchant ID, which names you as the seller; the Apple Pay capability, turned on for the app; and a certificate for the merchant ID. Your payment provider, the company that charges the card, tells you which certificate it needs, and may give you a file to make it from. Your Agents do the Apple side.

> [!NOTE]
> Apple's [Configure Apple Pay](https://developer.apple.com/help/account/capabilities/configure-apple-pay/) page says merchant IDs and payment processing certificates need the Account Holder or Admin role in your Apple Developer team.

> [!NOTE]
> AirBuild has no screen for merchant IDs or Apple Pay certificates. Ask an Agent in the Project's chat. It uses `asc merchant-ids` and `asc certificates create`, listed under `merchant-ids` and `certificates` in [asc: signing, devices and users](https://air.build/docs/cli/asc-signing/#merchant-ids).

## Before you start

- The Team's owner has connected an Apple Developer account and switched a team on. See [Connect your Apple Developer account](https://air.build/docs/app-store/connect-apple-developer-account/).
- The app has a Bundle ID, which it gets on its first build. See [Find your app's Bundle ID and its last build](https://air.build/docs/projects/find-your-apps-bundle-id/).
- You have a payment provider that takes Apple Pay, and its Apple Pay instructions. Apple's [Apple Pay planning](https://developer.apple.com/apple-pay/planning/) page explains how payment providers fit in.

## Register a merchant ID

Ask in the Project's chat, for example:

```text
Register a merchant ID for Apple Pay called "Notes Shop" with the identifier merchant.com.example.notes.
```

The Agent registers it with `asc merchant-ids create`, which takes an identifier and a name. The command's help gives `merchant.com.example` as an example of an identifier. Apple's [Configure Apple Pay](https://developer.apple.com/help/account/capabilities/configure-apple-pay/) page says a merchant ID never expires and one can serve several apps, so if you already have one, ask "Which merchant IDs does my Apple team have?" first. The Agent lists them with `asc merchant-ids list`.

## Turn on Apple Pay for the app

Ask, for example:

```text
Add Apple Pay to the app with the merchant ID merchant.com.example.notes. Put a Pay button on the checkout screen.
```

The Agents add the capability to the app and turn it on for the app's App ID (Apple calls it Apple Pay Payment Processing), then build the app again. What changes, and how to check it, is in [Turn on iCloud, App Groups or another capability](https://air.build/docs/build/turn-on-an-app-capability/).

`asc` has no command that links a merchant ID to an App ID, and this page doesn't know whether turning on the capability links it. Check in your Apple Developer account that the merchant ID is selected for the app's Apple Pay capability; Apple's [Enable app capabilities](https://developer.apple.com/help/account/identifiers/enable-app-capabilities/#enable-apple-pay) page shows where. If you change it there, ask the Agents to build again so the app's provisioning profile picks it up.

## Make the payment processing certificate

The certificate Apple returns pairs with the private key the certificate signing request (CSR) was made from. Who holds that key depends on who makes the request.

### From your payment provider's file

1. Get the CSR file from your payment provider, as its Apple Pay instructions say.

2. Attach the file to a message in the Project's chat, as it is. See [Send photos, files and sketches to an Agent](https://air.build/docs/projects/send-photos-and-files/).

3. Ask, for example:

   ```text
   Make the Apple Pay payment processing certificate for merchant.com.example.notes from the attached CSR, and send me the certificate file.
   ```

4. The Agent makes the certificate with `asc merchant-ids certificates create` (or `asc certificates create`) from your file. Apple's answer includes the certificate, so the Agent can save it as a file and send it to you in the chat. The certificate (a `.cer` file) isn't secret, so the chat is fine for it.

5. Upload the certificate to your payment provider, as its instructions say.

The private key stays with your payment provider, and nothing secret comes back to the chat.

### Without a file

If your payment provider's instructions don't give you a CSR file, the Agent can make the private key and the request itself (`--generate-csr`). Then the key is yours to keep, not your provider's, and the command's help says to keep it out of the repository and out of logs.

Ask the Agent to save the key in a folder the project's `.gitignore` leaves out, such as `secrets/`, and to tell you its path. That keeps it out of the repository, a shared link and an export of the source. It still shows in **Files**, dimmed, where anyone in the Team can open it. To take a copy for your server or your payment provider, open it in **Files** and use **Export** (see [Find the files and documents Agents made](https://air.build/docs/projects/find-files/#save-a-file-or-the-whole-project)), or ask the Agent to send it to you in your DM with that Agent (see [Create group chats and talk to one Agent](https://air.build/docs/projects/groups-and-dms/#talk-to-one-agent)), then touch and hold the file (on the Mac, right-click it) and choose **Save As…**. Don't ask for the key in the Project's chat: everyone in the chat can open it, and you can't recall a message the Agent sent.

### Which certificate

`asc` makes four kinds of Apple Pay certificate, each for one merchant ID: `APPLE_PAY`, `APPLE_PAY_RSA`, `APPLE_PAY_MERCHANT_IDENTITY` and `APPLE_PAY_PSP_IDENTITY`. Its help names them without saying which is which. Tell the Agent the name your payment provider uses for the one it wants. Apple's [Configure Apple Pay](https://developer.apple.com/help/account/capabilities/configure-apple-pay/#create-a-payment-processing-certificate) page describes the payment processing certificate, and says it expires every 25 months.

## Try it on a device

Check Apple Pay on a real iPhone or iPad, with a build made after the capability was turned on. See [Turn on iCloud, App Groups or another capability](https://air.build/docs/build/turn-on-an-app-capability/#check-it-on-a-device). This page doesn't know whether the Apple Pay sheet works in Preview.

If the sheet doesn't open or a payment fails, tell the Agent what you saw in the chat, with a screenshot.

## See, change or remove

| Ask | `asc` |
| --- | --- |
| "Which certificates does merchant.com.example.notes have, and when do they expire?" | `merchant-ids certificates list` |
| "Rename the merchant ID to Notes Store." | `merchant-ids update --name` |
| "Delete the merchant ID merchant.com.example.old." | `merchant-ids delete`, only with `--confirm`, so the Agent asks you first. |
| "Revoke the old payment processing certificate." | Agents can't: revoking is your step in your Apple Developer account. See Apple's [Revoke a certificate](https://developer.apple.com/help/account/certificates/revoke-a-certificate/). |

## Questions

**Can I set this up in AirBuild without an Agent?**

No. AirBuild has no screen for merchant IDs or Apple Pay certificates. Ask an Agent, or use your Apple Developer account on the web.

**Can I take Apple Pay on my website too?**

`asc` can make a merchant identity certificate (`APPLE_PAY_MERCHANT_IDENTITY`), but it has no command that registers your website's domain for Apple Pay. See Apple's [Configure Apple Pay on the web](https://developer.apple.com/help/account/capabilities/configure-apple-pay-on-the-web/).

**Can I sell subscriptions or in-app content with Apple Pay?**

Apple's [App Review Guidelines](https://developer.apple.com/app-store/review/guidelines/#goods-and-services-outside-of-the-app) say Apple Pay is one of the ways to take payment for physical goods or services used outside the app; their [In-App Purchase](https://developer.apple.com/app-store/review/guidelines/#in-app-purchase) section covers what has to be sold with In-App Purchase. To sell with In-App Purchase, see [Sell in-app purchases and subscriptions](https://air.build/docs/app-store/sell-in-app/).

**Can an Agent make other certificates this way?**

No. `asc certificates create` makes only Wallet pass and Apple Pay certificates. Asked for another kind, it says the type "is a signing certificate, which Airbuild manages": AirBuild holds your team's signing certificates and signs your builds with them itself. For Wallet passes, see [Make Wallet passes for your app](https://air.build/docs/build/make-wallet-passes/).

**The Agent says the CSR file is empty.**

The file you attached has nothing in it. Get the file from your payment provider again and attach it to a new message.

**Apple Pay doesn't work in a build I installed with a free Apple ID.**

A free Apple ID keeps only App Groups and Keychain Sharing, so Apple Pay is left out. Install with your Team's developer account or through TestFlight. See [Turn on iCloud, App Groups or another capability](https://air.build/docs/build/turn-on-an-app-capability/#with-a-free-apple-id).
