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
paymentData objectTo integrate Apple Pay, first, comply with Apple's specifications for initial setup and communication with Apple:
- Setting up Apple Pay
- Based on the type of product integration, perform different interfacing tasks with Apple (App or Web)
- Acquire the
paymentDataobject returned by Apple
paymentDataobjectIn Apple Pay development, the
paymentDataobject is usually obtained through theonpaymentauthorizedevent ofApplePaySessionafter the user authorizes the payment. This event returns anApplePayPaymentobject containing a token field. This token is an object comprising multiple subfields, includingpaymentData. Take reference for different integration types (App or Web).
Decrypt the paymentData object
paymentData objectDecrypt the paymentData object to prepare payment request parameters.
- Obtain Ephemeral Public Key: Extract
ephemeralPublicKeyfromtoken.paymentData.header - 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
- Decrypt Data: Decrypt
token.paymentData.datausing the shared key and AES-256-GCM algorithm - 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.applicationPrimaryAccountNumberfrom the decrypted data - The month (2 digits) + year (2 digits) values from
data.applicationExpirationDatein the decrypted data - The value of
data.paymentData.onlinePaymentCryptogramordata.paymentData.emvDatafrom the decrypted data - The value of
data.paymentData.eciIndicatorfrom the decrypted dataExample of decrypted data{"applicationPrimaryAccountNumber":"483196**\*\***6467","applicationExpirationDate":"281231","currencyCode":"840","transactionAmount":499,"deviceManufacturerIdentifier":"040010030273","paymentDataType":"3DSecure","paymentData":{"onlinePaymentCryptogram":"AwAAAAQAPQe4ZeoAAAAAgTNgAQA=","eciIndicator":"7"},"paymentBrand":"Visa"}
- The value of
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 or data.paymentData.emvData from the decrypted data,
"eci": Assign the value of data.paymentData.eciIndicator from the decrypted data
}
}Process other requests and responses similar to a standard Payment request.
