Apple Pay

You can initiate commercial payments on behalf of your merchants using Apple Pay in your frontend. Currently, this flow is for web-based platforms only. If you plan to build a mobile app, please mention it to your account manager.

Prerequisites (initial set up):

  1. If you don’t have it yet, first thing would be to create Apple developer account based on instructions from Apple: Before You Enroll – Apple Developer Program
  2. Then sign in to Your Apple Developer account
  3. Create new merchant identifier by opening Identifiers section
  1. Select “+” sign and Merchant IDs under it

  1. Fill in required data and register it
  2. Write email to [email protected] including merchant Identifier, brand Id and asking to create .csr file for Apple pay integration
  3. After receiving .csr file from us, payment processing certificate can be created in Apple Developer account. Open created merchant identifier and click “Create Certificate”

  1. Then upload .csr file received from us
  1. You will receive payment processing certificate from Apple. Send certificate to [email protected] in zip file. Certificate needs to be send in zip file because of security reasons we block all certificate files send to ConnectPay server. We will send you back merchant identity .csr file
  2. Then add your domain in Apple Developer portal. Open your merchant identifier, click “Add Domain” at the bottom of the page, enter it and save

  1. Download .txt file from Apple after saving your domain. You must place the domain validation file on your server at: https://yourdomain/.well-known/apple-developer-merchantid-domain-association. Without this file, it will not be possible to use Apple Pay on your domain. Upload this file to server so it’s accessible at the following location (replacing yourdomain.com with the URL of the domain): https://domain.com/.well-known/apple-developer-merchantid-domain-association.txt . To do this, create a folder called .well-known in the root directory of the website and put the .txt file in that folder
  1. Once .txt file have been uploaded, select Verify. Apple will check your domain ownership
  1. Then you will need to create merchant identity certificate. Open your merchant identifier in Apple Developer Portal, click “Create certificate” under Apple Pay Merchant Identity Certificate sections (make sure you’re not in the Apple Pay Payment Processing Certificate section). Upload .csr file received from #9 step and press “Continue”

  1. Download new .crt files and send it to [email protected] in a zip file. Certificate needs to be send in zip file because of security reason we block all certificate files send to ConnectPay server
  2. Please wait our confirmation that set up is finished
  3. Also, you’ll need to white-list Apple IP’s and domain names for merchant validation in production and testing. You can find the list here. Do not allow your server to access any other URLs for merchant validation

As BaaS partner, you can use same Apple merchant identifier for all sub-merchants.

Apple Pay commercial payments are settled after 3 days of payment initiation.

Flow:

Integration can be split in two parts – merchant validation together with session creation and payment initiation.

Merchant validation and session creation
  1. When your end-user selects to pay by Apple Pay, you need to check if they are using Safari browser by checking if window.ApplePaySession class exist.
  2. After that, you’ll need to check if device supports it. This can be done by calling Apple canMakePayments method. If you receive true value, then device supports making payments with Apple Pay and you can show Apple button on your frontend. It doesn’t verify whether or not the user has any provisioned cards in Wallet. If you want to show Apple button only for those users who have active cards added to the Wallet, you can use canMakePaymentsWithActiveCard method. If returned true, then device supports Apple Pay and there is at least one active card in Wallet that is qualified for payments on the web.
if(window['ApplePaySession'] u0026amp;u0026amp; ApplePaySession.canMakePayments(u0022pass merchant id hereu0022))

  1. You’ll need to style Apple Pay button based on Apple’s requirements. Styling done against requirements might bring blocking from Apple after some time.
  2. After you decide to show Apple Pay button and user selects to Pay, you’ll need to create a session with Apple by initiating Apple Pay session. For version parameter follow Apple’s guidelines, for payment request parameters, use:
  • countryCode – LT;
  • currencyCode – selected currency, for now EUR only;
  • supportedNetworks – visa, mastercard
  • merchantCapabilities – supports3DS
  • label – your Platform name or what you want to show on Apple pop-up;
  • amount – amount from user’s selection.
nvar request = { countryCode: 'LT', currencyCode: 'EUR', supportedNetworks: ['visa', 'masterCard'], merchantCapabilities: ['supports3DS'], total: { label: 'Your Merchant Name', amount: '10.00' }, } var session = new ApplePaySession(3, request);n
  1. After the session is created, call its begin method to show the payment sheet. When this method is called, the payment sheet is presented and the merchant validation process is initiated. Then use onvalidatemerchant function to start validation process.
const request = {n        countryCode: 'LT',n        currencyCode: 'EUR',n        supportedNetworks: ['visa', 'masterCard'],n        merchantCapabilities: ['supports3DS'],n        total: { label: 'ConnectPay', amount },n      }n  const session = new ApplePaySession(3, request);n  session.begin();n  session.onvalidatemerchant = (event) =u003e {n        const { validationURL } = event;n         // do the validation here         // after receiving the session object from back end call in         session.completeMerchantValidation(by passing the object here);n  };
  1. After Apple validates the session and provides session URL, send this URL together with your brand ID from your backend to us using Create Apple Pay Session API .
  2. We will complete merchant validation with Apple, create a session and return you merchant session object. Don’t modify this object, you’ll need to use it for payment authorization flow.
  3. Pass merchant session object received from us to Apple using completeMerchantValidation method to enable the user to authorize a transaction. The merchant session object expires 5 minutes after it is created.
Payment initiation
  1. When your session is validated and created at Apple side, user can now authorize a payment. When user authorizes a payment, onpaymentauthorized function is called. The event parameter contains the payment attribute. The onpaymentauthorized function must complete the payment and respond by calling completePayment before the 30 second timeout, after which a message appears stating that the payment couldn’t be completed.
session.onpaymentauthorized =  (event)=u003e {n        const token = event.payment.token;n        // handling the payment authorization n}
  1. Take Apple token from onpaymentauthorized function and send it to us using Initiate Apple Pay API. We will create a payment and send it to your customer’s issuer.
  2. For receiving payment status you have 2 options: calling our Get payment details API using paymentId provided in Initiate Apple Pay API response or receiving payment status from Notifications (you need to subscribe notifications to do that).
  3. After you receive terminal payment status from us – Failed or Approved, you need to complete payment on Apple side using completePayment method. Until this method is called Apple will load spinner on UI blocking user from further actions or time out it after 30 seconds claiming payment couldn’t be completed. If payment status is PendingProvider or Processing, retry calling Get payment details API until you receive terminal status.
  4. After payment is completed on Apple, you can decide what to do with user journey – show success/failure message or redirect to other page.

Splitting one payment for multiple
sub-merchants

Access token and brand information

Single payments

Payment details

Notifications

Scroll to Top