Apple Pay

Learn how to accept Apple Pay through EGMS.

EGMS provides simultaneous access support for both Apple Pay and Google Pay. For integrating Google Pay, refer to the Google Pay documentation. This text mainly describes the process of integrating Apple Pay.

Set up Apple Pay and acquire the paymentData object

To integrate Apple Pay, first, comply with Apple's specifications for initial setup and communication with Apple:

  1. Setting up Apple Pay
  2. Based on the type of product integration, perform different interfacing tasks with Apple (App or Web)
  3. Acquire the paymentData object returned by Apple

📘

paymentData object

In Apple Pay development, the paymentData object is usually obtained through the onpaymentauthorized event of ApplePaySession after the user authorizes the payment. This event returns an ApplePayPayment object containing a token field. This token is an object comprising multiple subfields, including paymentData. Take reference for different integration types (App or Web).

Decrypt the paymentData object

Decrypt the paymentData object to prepare payment request parameters.

  1. Obtain Ephemeral Public Key: Extract ephemeralPublicKey from token.paymentData.header
  2. Generate Shared Key: Use your Payment Processing Certificate's private key and Ephemeral Public Key to generate a shared key, typically using the ECDH (Elliptic Curve Diffie-Hellman) algorithm
  3. Decrypt Data: Decrypt token.paymentData.data using the shared key and AES-256-GCM algorithm
  4. Extract the following parameters from the previously obtained token and decrypted data, to prepare for the subsequent payment request:
    • The value of token.paymentMethod.network, currently EGMS supports Visa or Mastercard
    • The value of data.applicationPrimaryAccountNumber from the decrypted data
    • The month (2 digits) + year (2 digits) values from data.applicationExpirationDate in the decrypted data
    • The value of data.paymentData.onlinePaymentCryptogram from the decrypted data

      📘

      Example of decrypted data

      {"applicationPrimaryAccountNumber":"483196**\*\***6467","applicationExpirationDate":"281231","currencyCode":"840","transactionAmount":499,"deviceManufacturerIdentifier":"040010030273","paymentDataType":"3DSecure","paymentData":{"onlinePaymentCryptogram":"AwAAAAQAPQe4ZeoAAAAAgTNgAQA=","eciIndicator":"7"},"paymentBrand":"Visa"}
      

For more details, refer to Apple Pay Payment Token Format Reference.

Request payment to EGMS

After receiving the payment request parameter, you can send a POST Payment request to EGMS.

Initiate a POST Payment request, where the paymentMethod object is defined as follows:

"paymentMethod": {  
    "type":"token",  
    "token":{  
        "value": Assign the value of data.applicationPrimaryAccountNumber obtained and decrypted from Apple,  
        "type":"networkToken",  
        "paymentBrand": Assign the card brand name corresponding to the value of token.paymentMethod.network obtained from Apple: Visa/Mastercard,  
        "walletIdentifiers":"ApplePay",  
        "expiryDate": Assign the month (2 digits) + year (2 digits) value from the decrypted data.applicationExpirationDate,  
        "tokenCryptogram": Assign the value of data.paymentData.onlinePaymentCryptogram from the decrypted data  
    }  
}

Process other requests and responses similar to a standard Payment request.