We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
apple pay integration in Magento 2 via authorize.net
Features for Magento 2 Apple Pay extension
- Accelerated checkout process with one-tap / single-touch payment option
- Make payments safe and secure
- Uses Authorize.net payment gateway
- Supports multi-store and multi-language
- Supports multiple currencies and maximises conversion rates.
- Pre-requisites: Authorize.Net and Apple pay accounts are needed.
- Looking for GraphQL/Hyva Compatibility? Contact us now!
Apple Pay Extension Buy Now
After you purchased our Magento 2 Apple pay extension, follow the instructions below
Configuring the Apple Pay Payment Method in the Magento 2 Extension
Step 1: Copy and paste the file into the corresponding folder. app/code/Thecommerceshop/Applepayauth
Step 2: Setup Upgrade by using the following cmd in terminal php bin/magento setup:upgrade and provide respective permission for the folder
Step 3: Login to the Magento 2 admin panel and go to Store->Configuration-> Sales tab->Payment Method->ApplePay
Server Setup
- Use the Apple pay developer account https://developer.apple.com/ to create a Merchant ID
- You need to generate a new merchant id for each domain and need to update the Merchant ID in Authorize.net as shown below
Merchant Id generation in Apple Pay
- Select Identifiers under Certificates, Identifiers & Profiles
- To Create a new Identifier, Select + icon
- Select Merchant Ids under Register a new identifier
- Select Continue at the top
- Add Description and Identifier and Select Continue
- Select Register
Authorize.net configuration
- Login to the https://developer.authorize.net/ portal
- Navigate Digital Payment Solutions
- Select Apple Pay Sign/Up or Enabled
- Update/ Add Apple Merchant ID
- Download CSR certificate - CertificateRequest_csr.txt
Create Apple Apple Pay Payment Processing Certificate
- Select Certificates, Identifiers & Profiles
- Select Identifiers
- Filter and navigate to merchant id
- Select Certificate Under Apple Pay Payment Processing Certificate
- Upload the CSR file (which we downloaded from authorize.net) under Upload a Certificate Signing Request
- Select Continue.
- Note: Ensure Certificate status is Active as shown below
Merchant domain validation
- Select Add Domain under the Merchant Domains section.
- Enter Domain name.
- Note: Copy the entire domain from the site URL. Example:magento244-applepay.enterpriseapplicationdevelopers.com
- Select Save
- Select the Download button, apple-developer-merchantid-domain-association.txt will be downloaded
- Move the download txt file to the server path domain.com/.well-known/apple-developer-merchantid-domain-association.txt. (Example:
https://magento244-applepay.enterpriseapplicationdevelopers.com/.well-known/apple-developer-merchantid-domain-association.txt) - Select Verify and ensure the site is verified as shown below
Apple Pay Merchant Identity Certificate
- On Mac system, Navigate KeyChains app
- Select Keychain Access menu → Certificate Assistant
- Select Request a Certificate from the authority
- Enter details and select continue
- Save the certificate(CertificateSigningRequest.certSigningRequest) in the desired location.
Create Merchant Identity Certificate
- Inside the MAC developer apple account, Navigate to Apple Pay Merchant Identity Certificate Selected Merchant identifier
- Select Create Certificate
- Upload the above CertificateSigningRequest.certSigningRequest certificate under Upload a Certificate Signing Request
- Select Continue and Download merchant_id.cer certificate
- Navigate to the downloaded file and double-click, to add it to the keychain
Generating .pem key for payment
- On a Mac laptop, Select the KeyChains app
- Navigate Category → My Certificates
- Double click Select your Apple pay merchant identity certificate
- Popup will be shown with certificate details
- Under Trust, change the Always Trust option for When Using Certificate option.
- Close the popup widget.
- Select arrow and right click on the key icon
- Select Export
- Enter Password for file
- Enter the MAC system login user password and save Certificates.p12 file in desired location. Screenrecording: https://nimb.ws/nciX9Z
- Double click Certificates.p12 file
Convert Certificates.p12 to .pem format
- Navigate to the certificate directory in terminal
- Run format: openssl pkcs12 -in path.p12 -out newfile.pem (Example: openssl pkcs12 -in Certificates.p12 -out applepay.pem -nodes)
- Move the file to remote server certificate directory: (Example: scp applepay.pem magento244@magento244-applepay.enterpriseapplicationdevelopers.com:/var/www/html/magento2.4.2/var/applepay/applepay.pem)
- Give file permission to cert file.
- Upload the file in Admin panel -> Sales → Payment Methods → Apple Pay → Pem file
- Place test order and verify flow
Points to remember in this configuration
- The Pem file name should be named as “applepay.pem”
- To add Authorize.net credentials inside the Admin panel -> Configuration -> Sales -> Payment Methods -> Applepay. (https://nimb.ws/LzbgAt)
- Add apple pay merchant id inside the Magento admin panel - Admin -> Configuration -> Sales -> Payment Methods -> Applepay (Screenshot from magento2 admin panel - https://nimb.ws/rbtIVy .Screenshot from apple pay for merchant id - https://nimb.ws/haVtx6)
- Don't forget to add PEM key password in the admin configuration
Known challenges you may face while this integration
If you are in any sandbox environment,
- Sandbox test account: In your test device(iPhone), under Settings → Profile, ensure the sandbox profile is logged in instead of the developer account
- Add Apple-approved sandbox test card details. Refer: Sandbox Testing
- Ensure Region is the United states while setting the sandbox account in iPhone
- Don't forget to add the PEM key password in the admin configuration. If you didn't update the PEM key password, you will get the following error in the log.
Curl failed with error #0: could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key
found, wrong passphrase, or wrong file format?)
If you are in the live environment,
- Ensure valid shipping, billing, and phone numbers are provided. And live orders are allowed from the US region only.
Web References
- Apple Pay on the Web
- Configuring Your Environment
- Sandbox Testing
- Generating .pem file using Open SSL
- Configure Apple pay using apple pay documentation