> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mattildapayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apple Pay on iOS with the SDK

Both our native iOS SDK and React Native SDKs support native Apple Pay out of the box.

## About this integration

Our SDK requires you to perform the following steps to get set up.

* Enable Apple Pay in your merchant dashboard.
* Sign up for an Apple Pay Developer account and [register a payment processing certificate](/guides/features/apple-pay/ios#register-a-certificate).
* [Add the merchant ID](/guides/features/apple-pay/ios#add-the-certificate-to-your-app) and its processing certificate to your app.
* Pass the merchant ID to the constructor of the SDK.

## Enable Apple Pay

To enable Apple Pay, head over to your dashboard and then go to
**Connections** -> **Catalog** -> **Apple Pay**.

Next, complete and submit the form to create a new Apple Pay service.

### Register a certificate

To process Apple Pay in a mobile application you will need to register for an
Apple Pay developer account and join the [Apple developer program](https://developer.apple.com/programs/).

Once set up, you can generate a new Apple Pay processing certificate using the Gr4vy dashboard.

Go to
**Connections** -> **Apple Pay** -> **Certificates** and click on **Add certificate**
to start the process.

<img src="https://mintlify.s3.us-west-1.amazonaws.com/mattilda/assets/images/apple-pay/new-certificate.png" alt="Apple Pay: Add a new certificate" />

You will be prompted to provide a name and download a **Certificate Signing Request** (CSR).

Next, visit the [Apple developer dashboard](https://developer.apple.com/account/resources/identifiers/list/merchant)
to generate a payment processing certificate.

* Create or select a **Merchant ID** to associate a payment processing certificate with.
* In the **Apple Pay Payment Processing Certificate** section click on **Create Certificate**.
* Select **Choose File** to upload the CSR you downloaded from the dashboard, and then Continue.
* Verify the certificate details and **Download** the signed certificate from Apple.

Next, go back to our dashboard and upload the signed certificate.

### Add the certificate to your app

In order for your app to accept Apple Pay, you must set the same Apple **Merchant ID** in your application.
In your Xcode project find the **Signing & Capabilities** in your project editor.

Select the same **Merchant ID** you used to register your payment certificate. Please ensure your provisioning profiles
and signing certificates are updated to contain this ID.

## Integrate Apple Pay

### Update SDK initialization

Because the Xcode project can be configured with more than one merchant ID, update the initialization of
our SDK to pass the `applePayMerchantId` to the constructor.

<CodeGroup>
  ```swift Swift theme={"dark"}
  import gr4vy_ios

  let result = Gr4vy.init(
    gr4vyId: "mattilda",
    token: "[TOKEN]",
    amount: 1299,
    currency: "MXN",
    country: "MX",
    buyerId: nil,
    environment: Gr4vyEnvironment.sandbox,
    applePayMerchantId: "[MERCHANT_ID]"
  )
  ```

  ```swift React Native theme={"dark"}
  import EmbedReactNative from '@gr4vy/embed-react-native';

  const handleCheckout = () => {
    EmbedReactNative.showPaymentSheet({
      gr4vyId: 'mattilda',
      environment: 'sandbox',
      token: '[TOKEN]',
      amount: 1299,
      currency: 'AUD',
      country: 'AU',
      applePayMerchantId: "[MERCHANT_ID]"
      ...
    })
  }
  ```
</CodeGroup>

<Snippet file="apple-pay/testing.mdx" />

### Create sandbox transaction

To make an Apple Pay sandbox transaction the following are required.

* An Apple device with a Sandbox Tester account on it
* An app with an Apple merchant ID associated with it
* A merchant ID with a signed payment processing certificate associated with it
* Apple Pay enabled in the dashboard
* The payment processing certificate registered in the dashboard
* A card processor enabled that can process Apple Pay in the given currency.

For a currency that has a card processor that supports Apple Pay, you
should see the payment option in your app. Select Apple Pay and continue
with the payment. You should see the Apple Pay sheet appear.

### Create production transaction

To make an Apple Pay transaction in production replace the Sandbox Tester account
with a regular Apple account with real cards.

<Snippet file="apple-pay/common-issues-ios.mdx" />
