# Split a payment with multiple merchants

Split an Apple Pay payment between multiple merchants using the multi-merchant of record (MMoR) function by sending the multiTokenContexts array to Apple Pay and individual payment requests to our gateway.

**Prerequisites:** [Add Apple Pay to your integration](/guides/payments/apple-pay/apple-pay-integrate) · [Set up Apple Pay for a merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant)

If you need to split an Apple Pay payment between multiple merchants or third parties, you can use the multi-merchant of record (MMoR) function within Apple Pay. With MMoR, the cardholder authorizes the total amount once, and then you send the separate amounts to each merchant or third party.

<a id="how-it-works"></a>
## How it works

1. You send a request to the Apple Pay JS API that contains the amount for each merchant.
2. Apple returns a
   
   cryptogram
   
   after your customer authorizes the total amount.
3. You send a payment request to our gateway for each merchant. Each payment request contains the same cryptogram and the amount that the merchant should receive.

<a id="before-you-begin"></a>
## Before you begin

- [Integrate with Apple Pay](/guides/payments/apple-pay/apple-pay-integrate).
- [Set up Apple Pay for each merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant) and store their merchant identifier.

You must use Apple Pay JS API version 14 or later.

<a id="integration-steps"></a>
## Integration steps

1. Update your Apple Pay integration.
2. Send a payment request for each merchant.

<a id="step-1-update-your-apple-pay-integration"></a>
## Step 1. Update your Apple Pay integration

Update your Apple Pay integration to include the `multiTokenContexts` array in the `ApplePayPaymentRequest`. Each entry in the array represents a payment amount to each merchant.

If your request is successful and the customer authorizes the payment, Apple Pay returns a cryptogram that you need to include in each payment request to our gateway.

<a id="request-parameters"></a>
### Request parameters

| Parameter | Description |
| --- | --- |
| **merchantIdentifier** | Merchant identifier that we assigned when you set up the merchant with Apple Pay. |
| **externalIdentifier** | Order ID for the payment. This value must match the value for `orderId` in the payment request. |
| **merchantName** | Name of the merchant that you set up with Apple Pay. |
| **amount** | Amount that each merchant receives from the total amount. |

<a id="multitokencontexts-example"></a>
### multiTokenContexts example

```json
"multiTokenContexts": [
  { "merchantIdentifier": "PMID-101", "externalIdentifier": "ORDER-A1", "merchantName": "Merchant 1", "amount": "100.00" },
  { "merchantIdentifier": "PMID-102", "externalIdentifier": "ORDER-B7", "merchantName": "Merchant 2", "amount": "25.00" },
  { "merchantIdentifier": "PMID-103", "externalIdentifier": "ORDER-C3", "merchantName": "Merchant 3", "amount": "10.00" }
]
```

<a id="step-2-send-a-payment-request-for-each-merchant"></a>
## Step 2. Send a payment request for each merchant

After you receive the cryptogram from the Apple Pay JS API, send a payment request to our Payments endpoint for each merchant.

In each payment request, include the same cryptogram in the `encryptedData` parameter, but adjust the following parameters for each merchant:

- `processingTerminalId` – Unique identifier that we assigned to the merchant's terminal.
- `order.orderId` – Order ID that matches the `externalIdentifier` that you sent to the Apple Pay JS API.
- `order.amount` – Amount that the merchant receives.

If your requests are successful, our gateway sends the amounts to each merchant.
