Apple Pay
Get started with Apple Pay
This page provides a comprehensive guide to successfully integrate Apple Pay with DEUNA.
Apple Pay is a digital wallet platform and payment system that enables secure purchases in apps and websites. It allows users to make online payments from Safari on Mac, iPhone, iPad, and Apple Watch, using card data stored securely within the Apple ecosystem.
How it works
Integrating with Apple Pay is significantly different from other traditional payment methods, so it's important to understand how it works before integrating with DEUNA.
Apple Pay encrypts the buyer's card information using a payment token generated by Apple. This token is transmitted to the merchant's server, where DEUNA decrypts it and sends the card information to the configured payment processor.
Apple Pay Payment Token
The Apple Pay payment token is an encrypted object generated by Apple's servers during each transaction. It contains the buyer's card information securely encrypted using the public key from the merchant's payment processing certificate.
This token is unique to each transaction, ensuring that even if intercepted, it cannot be reused by third parties.
Cryptogram
A cryptogram is a dynamic, transaction-specific code generated during a payment to authenticate and protect the process. Apple Pay uses the 3DSecure payment type, in which case the cryptogram is transmitted as OnlinePaymentCryptogram within the decrypted token.
The cryptogram is validated by the card network to authorize the transaction. If present, it must always be sent to the PSP — otherwise, the transaction will fail.
ApplePay Configuration
An active Apple Developer account is required to configure Apple Pay.
This section details the complete Apple Pay configuration process, from creating the Merchant ID in the Apple Developer portal to registering the credentials in DEUNA.
Use this guide to prepare and configure Apple Pay with DEUNA.
- Apple Developer Configuration: Create a Merchant ID, generate and convert the required certificates and keys, and verify your merchant domains.
- DEUNA Admin setup: Add the Apple Pay connection, configure routing, and enable Apple Pay.
Once finished, you'll be ready to choose your integration path (SDK or Direct).
Apple Pay certificate options
In the DEUNA Admin, you will find two certificate options for Apple Pay:
- DEUNA: For merchants who do not have an Apple Developer account or a native mobile app (i.e., web-only). In this case, you must register your domain via the API to use DEUNA's certificates.
- Own: For merchants who have a native mobile app and an Apple Developer account. In this case, follow the steps in this document to generate your certificates and add your credentials in the Admin.
1 Merchant Certification
1.1 Configure Apple Pay in the Apple Developer portal
Docs: https://developer.apple.com/documentation/applepayontheweb/configuring-your-environment
1.1 Create a Merchant ID
- Sign in to your Apple Developer account.
- Go to Identifiers under the Certificates, Identifiers & Profiles section.
- Click the (+) button.
- Select Merchant IDs and click Continue.
- Enter the Description and Identifier for the merchant, then click Continue.
The Merchant ID follows a reverse-domain format, for example:merchant.com.yourdomain.pay
- Click Register to complete the registration.
1.2 Create the Apple Pay Payment Processing Certificate
This certificate is used by Apple to encrypt the buyer's card data. DEUNA uses it to decrypt the payment token.
- Generate the Certificate Signing Request (CSR) and its private key by running the following commands in your terminal:
# Generate an EC private key using the P-256 curve
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out payment_processing_private_key.pem
# Create a CSR using the private key
openssl req -new -sha256 \
-key payment_processing_private_key.pem \
-out payment_processing_csr.csr- The second command will prompt you for information to generate the certificate. Fill in the fields as follows:
Country Name (2 letter code) [AU]: US
State or Province Name (full name) [Some-State]: New York
Locality Name (eg, city) []: New York
Organization Name (eg, company) [Internet Widgits Pty Ltd]: DEUNA test # Merchant description
Organizational Unit Name (eg, section) []: # optional
Common Name (e.g. server FQDN or YOUR name) []: merchant.io.deuna.pay # Merchant ID
Email Address []: # optional
A challenge password []: # optional
An optional company name []: # optional
- As a result you will get two files that you must keep:
payment_processing_private_key.pempayment_processing_csr.csr
- Back in the Apple portal, Click on the Merchant ID you just created.
- Under the Apple Pay Payment Processing Certificate section, click Create Certificate.
- Click Choose File and select the
payment_processing_csr.csrfile you just generated. - Click Continue.
- Download and keep the
apple_pay.cercertificate generated by Apple.
1.3 Create the Apple Pay Merchant Identity Certificate
This certificate is used to authenticate the TLS communication between DEUNA's servers and Apple's servers when requesting a payment session.
- Click on the Merchant ID you created.
- Under the Apple Pay Merchant Identity Certificate section, click Create Certificate.
- Generate the CSR and its RSA private key by running the following commands in your terminal:
# Generate an RSA 2048-bit private key
openssl genrsa -out merchant_identity_rsa_private_key.pem 2048
# Create a CSR using the RSA private key
openssl req -new -sha256 \
-key merchant_identity_rsa_private_key.pem \
-out merchant_identity_rsa_csr.csr- The second command will prompt you for information to generate the certificate. Fill in the fields the same way as in the previous step:
Country Name (2 letter code) [AU]: US
State or Province Name (full name) [Some-State]: New York
Locality Name (eg, city) []: New York
Organization Name (eg, company) [Internet Widgits Pty Ltd]: DEUNA test # Merchant description
Organizational Unit Name (eg, section) []: # optional
Common Name (e.g. server FQDN or YOUR name) []: merchant.io.deuna.pay # Merchant ID
Email Address []: # optional
A challenge password []: # optional
An optional company name []: # optional
- As a result you will get two files that you must keep:
merchant_identity_rsa_private_key.pemmerchant_identity_rsa_csr.csr
- Back in the Apple portal, click Choose File and select the
merchant_identity_rsa_csr.csrfile you just generated. - Click Continue.
- Download and keep the
merchant_id.cercertificate generated by Apple.
1.4 Register a domain
- Click on the Merchant ID you created.
- Under the Merchant Domains section, click Add Domain.
- Enter your domain and click Save.
- Download the
.txtfile required for domain verification.
1.5 Verify the domain
- Place the downloaded
.txtfile inside a.well-knownfolder on your server. When accessinghttps://<domain>/.well-known/apple-developer-merchantid-domain-association.txt, the server must return the contents of that.txtfile. - Go back to the Merchant ID in the Apple portal.
- Under the Merchant Domains section, click Verify.
- The domain should now show a Verified status.
For testing environments, you can uselocalhostas the domain when registering credentials in DEUNA.
2. Register credentials in DEUNA with your owns certificates
Once all certificates have been downloaded, you need to extract their contents in PEM format to register them in DEUNA.
- Merchant name
- ApplePay Merchant ID: Merchant ID created in Apple Pay, e.g.
merchant.com.yourdomain.pay - Payment Processing Certificate:
- For this step you will need the
apple_pay.cerfile downloaded when registering the Apple Pay Payment Processing Certificate. - Run the following commands in your terminal, from the folder where the file is located:
- For this step you will need the
openssl x509 -inform DER -in "apple_pay.cer" -out certificate.pem
openssl x509 -in "certificate.pem" -text -noout
echo -e "const merchantCertificate:"
awk 'NR>1{printf "\\n"}{ printf "%s", $0 }' certificate.pem
echo -e ""
rm certificate.pem- El resultado debería en la sección
Payment Processing Certificateen el campoApple Pay Certificate.
-----BEGIN CERTIFICATE-----\nMIIEbDCCBBKgAwIBAgIILCdFbC/W4kcwCgYIKoZIzj0EAwIwgYAxNDAy...\n-----END CERTIFICATE-----
- Payment Processing Private Key
- ⚠️ For this step you will need the
payment_processing_private_key.pemfile generated when creating the CSR for the Apple Pay Payment Processing Certificate.
- ⚠️ For this step you will need the
openssl rsa -in "payment_processing_private_key.pem" -text -noout
echo -e "const merchantPrivateKey:"
awk 'NR>1{printf "\\n"}{ printf "%s", $0 }' payment_processing_private_key.pem
echo -e ""- The output should go in the Payment Processing Certificate section, in the
Private Keyfield.
-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg...\n-----END PRIVATE KEY-----
- Merchant Identity Certificate
- For this step you will need the
merchant_id.cerfile downloaded when registering the Apple Pay Merchant Identity Certificate.
- For this step you will need the
openssl x509 -inform DER -in "merchant_id.cer" -out certificate.pem
openssl x509 -in "certificate.pem" -text -noout
echo -e "const merchantCertificate:"
awk 'NR>1{printf "\\n"}{ printf "%s", $0 }' certificate.pem
echo -e ""
rm certificate.pem- The output should go in the Merchant Identity Certificate section, in the
Apple Pay Certificatefield.
-----BEGIN CERTIFICATE-----\nMIIGDTCCBPWgAwIBAgIQKcUD7Csg6A8Fxtg6/9tOyTANBgkqhkiG...\n-----END CERTIFICATE-----
- Merchant Identity Private Key
- For this step you will need the
merchant_identity_rsa_private_key.pemfile generated when creating the CSR for the Apple Pay Merchant Identity Certificate.
- For this step you will need the
openssl rsa -in "merchant_identity_rsa_private_key.pem" -text -noout
echo -e "const merchantPrivateKey:"
awk 'NR>1{printf "\\n"}{ printf "%s", $0 }' merchant_identity_rsa_private_key.pem
echo -e ""- The output should go in the Merchant Identity Certificate section, in the Private Key field.
-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCa...\n-----END PRIVATE KEY-----
- Add Merchant Domains
- Select the card networks
- Select allowed auth methods (always select 3DS)
3. Register credentials managed by DEUNA
- Merchant name
- ApplePay Merchant ID: Merchant ID created in Apple Pay, e.g.
merchant.com.yourdomain.pay - Add Merchant Domains
- Select the card networks
- Select allowed auth methods (always select 3DS)
Updated about 5 hours ago