# Apple Pay for Unified Payments API > **Information** > > To process Apple Pay payments in Kuwait, you must use the KNET network. For the integration instructions, see [Apple Pay via KNET](https://www.checkout.com/docs/payments/add-payment-methods/apple-pay/apple-pay-via-knet.md). ## Set up Apple Pay To process Apple Pay payments using the Payments API, you need an Apple developer account and create an [Apple merchant ID](https://developer.apple.com/documentation/passkit/setting-up-apple-pay). See [Apple's enrollment requirements](https://developer.apple.com/programs/enroll/) for more information. --- ## Before you start To set up Apple Pay, you need the following: - A domain with a valid TLS certificate – meaning your domain must start with `https`. - Access to a Secure Shell (SSH) terminal. - Access to upload files to your server. To process payments on an app or on a website using the Payments API, follow these steps: 1. Create a merchant identifier with Apple. 2. Create a certificate signing request. 3. Create an Apple Pay payment processing certificate. 4. Upload the signed payment processing certificate. 5. Register a merchant domain. 6. Create your Apple Pay certificate and private keys. 7. Test Apple Pay certificate and private key validity. 8. Integrate Apple Pay. --- ## Create a merchant identifier 1. In your Apple Developer account, go to the [Add Merchant IDs section](https://developer.apple.com/account/resources/identifiers/add/merchant), select _Merchant IDs_ and select _Continue_. 2. Add a useful description, like `merchant ID for test environment`. 3. Enter your desired Merchant ID name in the _Identifier_ section. Use a descriptive name to indicate both the domain and the environment you will use it in. For example, `merchant.com.mywebsite.sandbox`. > **Information** > > We recommend that you create separate merchant IDs for your sandbox and production environments. --- ## Create a certificate signing request To create a certificate signing request (CSR), call the [Generate a certificate signing request](https://api-reference.checkout.com/tag/Apple-Pay/#operation/generateApplePaySigningRequest) endpoint. > **Information** > > Your base URL's `{prefix}` value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints.md). **Production** `POST` `https://{prefix}.api.checkout.com/applepay/signing-requests` **Sandbox** `POST` `https://{prefix}.api.sandbox.checkout.com/applepay/signing-requests` You can use the `protocol_version` field to specify whether to use the EC or RSA protocol for the CSR encryption. ### Request example ```json { "protocol_version": "ec_v1" } ``` ### Response example ```json { "content": "-----BEGIN CERTIFICATE REQUEST-----MIIBSTCB8AIBADCBjzELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9uZG9uMRUwEwYDVQQKDAxDaGVja291dC5jb20xCzAJBgNVBA8MAklUMRUwEwYDVQQDDAxjaGVja291dC5jb20xIzAhBgkqhkiG9w0BCQEWFHN1cHBvcnRAY2hlY2tvdXQuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwjiZ410yhHCkwa04OfrPb0e5bqt4FncefJwAbFpcqARTWefYZNvLyYkV68PmAKoO7cthfAFVfoVNqXBEGzjg1TAKBggqhkjOPQQDAgNIADBFAiAcgJLboQK3GBQX/K5ghNzbcw4mnVcVk/rUmkIxu0M28gIhALO01kH13CZzMkAhRhnkeCUPaP+IqUqQaDdZL8d5xgFc-----END CERTIFICATE REQUEST-----" } ``` 1. On your desktop, create a new plain text file and name it `cko.csr`. 2. Paste the entire value returned in the response's `content` field into the new `cko.csr` file and save it. For example, your `cko.csr` file's contents look similar to the following: ``` -----BEGIN CERTIFICATE REQUEST-----MIIBSTCB8AIBADCBjzELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9uZG9uMRUwEwYDVQQKDAxDaGVja291dC5jb20xCzAJBgNVBA8MAklUMRUwEwYDVQQDDAxjaGVja291dC5jb20xIzAhBgkqhkiG9w0BCQEWFHN1cHBvcnRAY2hlY2tvdXQuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwjiZ410yhHCkwa04OfrPb0e5bqt4FncefJwAbFpcqARTWefYZNvLyYkV68PmAKoO7cthfAFVfoVNqXBEGzjg1TAKBggqhkjOPQQDAgNIADBFAiAcgJLboQK3GBQX/K5ghNzbcw4mnVcVk/rUmkIxu0M28gIhALO01kH13CZzMkAhRhnkeCUPaP+IqUqQaDdZL8d5xgFc-----END CERTIFICATE REQUEST----- ``` > **Information** > > The CSR has a Time to Live (TTL) period of 24 hours. You must create your Apple Pay payment processing certificate within this timeframe. If you miss the TTL period, you must generate a new CSR. --- ## Create a processing certificate 1. Sign in to your Apple Developer account, go to the Merchant IDs list section, and select the Merchant ID you created earlier. 2. In the _Apple Pay Payment Processing Certificate_ section, select _Create Certificate_. 3. Respond _No_ to the question about processing in China and select _Continue_. 4. Upload the `cko.csr` file from the previous step and select _Continue_. 5. Select _Download_ to retrieve your payment processing certificate. The certificate file name is `apple_pay.cer`. --- ## Upload the signed payment processing certificate 1. Encode the `apple_pay.cer` in base64 using the following command. ```bash openssl x509 -inform der -in apple_pay.cer -out base64_converted.cer ``` 2. The command creates a new file with the name `base64_converted.cer`. To enable Checkout.com to use the payment certificate to decrypt Apple Pay tokens and convert them to Checkout.com card tokens, call the [Upload a payment processing certificate](https://api-reference.checkout.com/tag/Apple-Pay/#operation/uploadApplePayCertificate), and set the `content` field to the content of the `base64_converted.cer` file. > **Information** > > Your base URL's `{prefix}` value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints.md). **Production** `POST` `https://{prefix}.api.checkout.com/applepay/certificates` **Sandbox** `POST` `https://{prefix}.api.sandbox.checkout.com/applepay/certificates` ### Request example ```json { "content": "MIIEfTCCBCOgAwIBAgIID/asezaWNycwCgYIKoZIzj0EAwIwgYAxNDAyBgNVBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0gRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0yMTA2MTExMzQ0MjVaFw0yMzA3MTExMzQ0MjRaMIGuMS0wKwYKCZImiZPyLGQBAQwdbWVyY2hhbnQuY29tLmNoZWNrb3V0LnNhbmRib3gxQzBBBgNVBAMMOkFwcGxlIFBheSBQYXltZW50IFByb2Nlc3Npbmc6bWV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AwRQIgTjywMwOrLX3TwDUrPn7yDGL/dhc+VNudv0uGBOWRyXACIQClFQFvgx+hfTwVdHt8klrswpgtZtbYjs74p9GYuc8Puw==" } ``` ### Response example ```json { "id": "aplc_hefptsiydvkexnzzb35zrlqgfq", "public_key_hash": "tqYV+tmG9aMh+l/K6cicUnPqkb1gUiLjSTM9gEz6Nl0=", "valid_from": "2021-01-01T17:32:28.000Z", "valid_until": "2025-01-01T17:32:28.000Z" } ``` --- ## Register a merchant domain > **Information** > > You must have a valid TLS certificate on your domain. To display the Apple Pay button in your site, you must register and verify all top-level domains and subdomains where you display the button. This step is necessary if you are processing Apple Pay in a webpage. 1. Sign in to your Apple Developer account, go to the [Merchant IDs list section](https://developer.apple.com/account/resources/identifiers/list/merchant) and select the Merchant ID you created earlier. 2. Under the _Merchant Domains_ section, select _Add Domain_. 3. Enter your domain and select _Save_. 4. Select _Download_ and you'll get a `.txt` file. 5. Upload this file to your server so it's accessible at the following location (replacing `yourdomain.com` with the URL of your domain): `https://yourdomain.com/.well-known/apple-developer-merchantid-domain-association`. To do this, create a folder called `.well-known` in the root directory of your website and put the `.txt` file in that folder. 6. Once you've uploaded the file, select _Verify_. --- ## Create your Apple Pay certificate and private keys 1. Open a terminal and create a `.csr` and `.key` file using the following command: ```bash openssl req -out uploadMe.csr -new -newkey rsa:2048 -nodes -keyout certificate_sandbox.key ``` 2. In the prompt, enter your details, and when asked for a password, leave it blank and select _Enter_. This will generate two files: `uploadMe.csr` and `certificate_sandbox.key`. 3. Sign in to your Apple Developer account, go to the [Merchant IDs list section](https://developer.apple.com/account/resources/identifiers/list/merchant) and select the merchant ID you created earlier. 4. Under the _Apple Pay Merchant Identity Certificate_ section, select _Create Certificate_. 5. Upload the `uploadMe.csr` file you just created from your terminal. 6. Select _Continue_ and then select _Download_ to get your `.cer` file. It will probably be named `merchant_id.cer`. 7. Convert this `.cer` file into a `.pem` file so you can use it in your code. Enter the following command in your terminal: ```bash openssl x509 -inform der -in merchant_id.cer -out certificate_sandbox.pem ``` --- ## Test Apple Pay certificate and private key Validate your Apple Pay certificate and private key files by requesting an Apple Pay payment session: ```curl curl -gv \ --data '{ "merchantIdentifier": "merchant.com.mywebsite.sandbox", "displayName": "merchant id for test environment", "domainName": "sandbox.mywebsite.com" }' \ --cert /path/to/certificate_sandbox.pem \ --key /path/to/certificate_sandbox.key \ https://apple-pay-gateway.apple.com/paymentservices/paymentSession ``` --- ## Integrate Apple Pay After following the previous steps, you now have the following: - An Apple merchant ID (for example, `merchant.com.mywebsite.sandbox`). - Checkout.com linked to your merchant ID. - A domain verified by Apple. - A `.key` and a `.pem` certificate file. > **Information** > > If you use an ecommerce platform where we support Apple Pay, such as Magento or WooCommerce, the files and certificates you created are enough to complete your integration. Follow the instructions provided by your particular platform. ### Support Apple Pay in a cross-domain iframe If you display the Apple Pay button inside an iframe hosted on a different domain from the top-level parent page, complete the following steps. Otherwise, you receive a _Payment Not Completed_ error during the `onvalidatemerchant` callback. 1. Add the `allow="payment *"` attribute to the iframe element: ```html ``` 2. Register and verify both the domain of the iframe and the domain of the top-level parent page with Apple. For more information, see [Register a merchant domain](#Register_a_merchant_domain). 3. When you create the `ApplePaySession`, use the `onvalidatemerchant` callback to send the domain of the top-level parent page to your backend, so your backend can set `initiativeContext` to this domain when it validates the merchant session with Apple: #### Frontend example ```javascript const session = new ApplePaySession(3, paymentRequest); session.onvalidatemerchant = async (event) => { try { // 1. Send Apple's validationURL to your backend const response = await fetch("/apple-pay/sessions", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ appleValidationUrl: event.validationURL, }), }); if (!response.ok) { throw new Error("Failed to fetch merchant session from backend"); } // 2. Get back the opaque merchant session object const merchantSession = await response.json(); // 3. Pass the session object back to Apple to complete validation session.completeMerchantValidation(merchantSession); } catch (error) { // Handle error } }; ``` ### Backend example ```javascript import express from "express"; import fs from "node:fs"; import { Agent } from "undici"; const app = express(); app.use(express.json()); // 1. Configure your Merchant Identity Certificates for mTLS const mtlsAgent = new Agent({ connect: { cert: fs.readFileSync("./certs/certificate.pem"), key: fs.readFileSync("./certs/certificate.key"), }, }); app.post("/apple-pay/sessions", async (req, res) => { try { const { appleValidationUrl } = req.body; // 2. Request the merchant session from Apple const response = await fetch(appleValidationUrl, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ merchantIdentifier: "merchant.com.example", displayName: "Your Store Name", initiative: "web", initiativeContext: "parent-domain.com", }), dispatcher: mtlsAgent, }); if (!response.ok) { const errorText = await response.text(); throw new Error( `Apple validation failed: ${response.status} - ${errorText}`, ); } // 3. Return the opaque merchant session object const merchantSession = await response.json(); res.json(merchantSession); } catch (error) { res.status(500).json({ error: "Failed to validate merchant session" }); } }); ``` ### Extract customer billing address You can extract the billing address that the customer set up in their Apple Pay wallet for use in your payment requests. Set the `requiredBillingContactFields: ["postalAddress"]` parameter when you create the `ApplePaySession` on the front end. You see the billing address displayed in the Apple Pay payment sheet. To specify a different billing address that you have stored on file for the customer, add the `billingContact` object. For example: ``` requiredBillingContactFields: ["postalAddress"], billingContact: { givenName: "Jia Tsang", addressLines: "123 Anywhere St", locality: "Anytown", postalCode: "123456", administrativeArea: "AL", country: "US" } ``` The billing address is returned in the object in the `onpaymentauthorized()` callback, which you can send to your back end to include in your payment request to Checkout.com. ### Extract customer email address and phone number You can extract the email address and phone number that the customer set up in their Apple Pay wallet for use in your payment requests. Set the `requiredShippingContactFields: ["phone", "email"]` parameter when you create the `ApplePaySession` on the front end. You see the email address and phone number displayed in the Apple Pay payment sheet. To specify a different email address or phone number that you have stored on file for the customer, add the `shippingContact` object. For example: ``` requiredShippingContactFields: ["name", "phone", "email"], shippingContact: { phoneNumber: "555-0100", emailAddress: "jia.tsang@example.com" } ``` The email address and phone number are included in the object returned in the `onpaymentauthorized()` callback, which is sent to your back end and included in your payment request to Checkout.com. Once you've completed the integration steps, you can display the Apple Pay button and validate an Apple Pay session. The following diagram shows a successful Apple Pay payment: ![Diagram of the payment flow for Apple Pay showing the communication between your customer, your front end, your server, and Checkout.com server](https://www.checkout.com/docs/NAS/Payments/PaymentMethods/apple_pay_flow.png) --- ## Generate a Checkout.com token from the Apple Pay token After you set up and configured Apple Pay, you're ready to accept Apple Pay payments through our payment gateway. After your customer validates their transaction with biometrics, Apple will generate a [payment token](https://developer.apple.com/documentation/applepayontheweb/applepaypaymenttoken). The first step in processing an Apple Pay transaction is to convert this Apple Pay token into a Checkout.com card token. Alternatively, if you want to decrypt the Apple Pay token yourself and process a payment, skip to [Request a payment](#Request_a_payment). For the full API specification, see the [API reference](https://api-reference.checkout.com/#tag/Tokens). > **Information** > > Your base URL's `{prefix}` value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints.md). **Production** `POST` `https://{prefix}.api.checkout.com/tokens` **Sandbox** `POST` `https://{prefix}.api.sandbox.checkout.com/tokens` ### Request example ```json { "type": "applepay", "token_data": { "version": "EC_v1", "data": "t7GeajLB9skXB6QSWfEpPA4WPhDqB7ekdd+F7588arLzvebKp3P0TekUslSQ8nkuacUgLdks2IKyCm7U3OL/PEYLXE7w60VkQ8WE6FXs/cqHkwtSW9vkzZNDxSLDg9slgLYxAH2/iztdipPpyIYKl0Kb6Rn9rboF+lwgRxM1B3n84miApwF5Pxl8ZOOXGY6F+3DsDo7sMCUTaJK74DUJJcjIXrigtINWKW6RFa/4qmPEC/Y+syg04x7B99mbLQQzWFm7z6HfRmynPM9/GA0kbsqd/Kn5Mkqssfhn/m6LuNKsqEmbKi85FF6kip+F17LRawG48bF/lT8wj/QEuDY0G7t/ryOnGLtKteXmAf0oJnwkelIyfyj2KI8GChBuTJonGlXKr5klPE89/ycmkgDl+T6Ms7PhiNZpuGEE2QE=", "signature": "MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID5jCCA4ugAwIBAgIIaGD2mdnMpw8wCgYIKoZIzj0EAwIwejEuMCwGA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IFADAKBggqhkjOPQQDAgNnADBkAjA6z3KDURaZsYb7NcNWymK/9Bft2Q91TaKOvvGcgV5Ct4n4mPebWZ+Y1UENj53pwv4CMDIt1UQhsKMFd2xd8zg7kGf9F3wsIW2WT8ZyaYISb1T4en0bmcubCYkhYQaZDwmSHQAAMYIBjTCCAYkCAQEwgYYwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTAghoYPaZ2cynDzANBglghkgBZQMEAgEFAKCBlTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xNzA4MDIxNjA5NDZaMCoGCSqGSIb3DQEJNDEdMBswDQYJYIZIAWUDBAIBBQChCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIGEfVr+4x9RQXyfF8IYA0kraoK0pcZEaBlINo6EGrOReMAoGCCqGSM49BAMCBEgwRgIhAKunK47QEr/ZjxPlVl+etzVzbKA41xPLWtO01oUOlulmAiEAiaFH9F9LK6uqTFAUW/WIDkHWiFuSm5a3NVox7DlyIf0AAAAAAAA=", "header": { "ephemeralPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEX1ievoT8DRB8T5zGkhHZHeDr0oBmYEgsDSxyT0MD0IZ2Mpfjz2LdWq6LUwSH9EmxdPEzMunsZKWMyOr3K/zlsw==", "publicKeyHash": "tqYV+tmG9aMh+l/K6cicUnPqkb1gUiLjSTM9gEz6Nl0=", "transactionId": "3cee89679130a4b2617c76118a1c62fd400cd45b49dc0916d5b951b560cd17b4" } } } ``` ### Response example ```json { "type": "applepay", "token": "tok_ymu4qlccztkedmd6b7c3hcf6ae", "expires_on": "2019-10-21T10:48:35Z", "expiry_month": 8, "expiry_year": 2023, "scheme": "Visa", "last4": "6222", "bin": "481891", "card_type": "DEBIT", "card_category": "CONSUMER", "issuer": "Test Bank", "issuer_country": "GB", "product_id": "F", "product_type": "Visa Classic" } ``` --- ## Request a payment **Using the Checkout.com token** Using the token `(tok_...)` you got in the response above, make a standard payment request. Although the field is optional, including the customer's billing address in your payment requests can help to: - Reduce interchange fees - Enable the issuer to perform Address Verification Service (AVS) checks - Improve acceptance rates Similarly, including the customer's email address and phone number in your payment requests can help to enrich data for reporting and fraud screening purposes. You can use your front end to extract the customer's [billing address](#Extract_customer_billing_address), [email address, and phone number](#Extract_customer_email_address_and_phone_number) from their Apple Pay Wallet, and include them in your payment request. For the full API specification, see the [API reference](https://api-reference.checkout.com/tag/Payments/#operation/requestAPaymentOrPayout). > **Information** > > Your base URL's `{prefix}` value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints.md). **Production** `POST` `https://{prefix}.api.checkout.com/payments` **Sandbox** `POST` `https://{prefix}.api.sandbox.checkout.com/payments` ### Request example ```json { "source": { "type": "token", "token": "tok_ymu4qlccztkedmd6b7c3hcf6ae", "billing_address": { "address_line1": "123 Anywhere St.", "city": "Anytown", "state": "AL", "zip": "123456", "country": "US" } }, "phone": { "country_code": "1", "number": "555-0100" }, "customer": { "email": "jia.tsang@example.com" }, "amount": 6500, "currency": "USD" } ``` ### Response example If you get a `201 Success` response and the `approved` field is `true`, your payment was successful. If the transaction failed, it's likely that the payment request was made with an invalid/expired card, or a valid card with an insufficient available balance. **Using a pre-decrypted Apple Pay token** To make a payment using an Apple Pay token that you have decrypted, use the `network_token` source type and specify the `token_type` as `applepay`. This source type allows you to provide the details about the token, as well as the cryptogram and ECI value obtained from the Apple Pay token. For the full API specification, see the [API reference](https://api-reference.checkout.com/). **Live** `POST` `https://{prefix}.api.checkout.com/payments` **Sandbox** `POST` `https://{prefix}.api.sandbox.checkout.com/payments` ### Request example ```json { "source": { "type": "network_token", "token": "4242424242424242", "token_type": "applepay", "expiry_month": "10", "expiry_year": "2025", "eci": "06", "cryptogram": "AgAAAAAAAIR8CQrXcIhbQAAAAAA" }, "amount": 1000, "currency": "USD" } ``` ### Response example If the `approved` field is `true`, your authorization was successful. If your authorization was not successful, it's possible the payment used an invalid/expired card, or a valid card with an insufficient available balance. > **Information** > > A successful response will include a `payment_account_reference` value, which is a unique reference to the underlying card for network tokens. If the card scheme provided us with an `eci` value, it will be included in the response. The value indicates the security level that the card scheme decided to request the payment with. --- ## Testing Apple Pay To test Apple Pay payments, you'll need the following: - An [Apple Pay compatible device](https://support.apple.com/en-us/HT208531). - A sandbox Apple Pay wallet, which you can add a test card to (see _Test Cards for Apps and the Web_ on Apple Pay's [sandbox testing page](https://developer.apple.com/apple-pay/sandbox-testing/)). For more information about testing, see our [testing resources](https://www.checkout.com/docs/developer-resources/testing.md). > **Note** > > When testing in a sandbox environment, you cannot use a real Apple Pay wallet with real cards.