Skip to main content
Version: 1.0.0

Web

Apple Pay purchase operation

To integrate the Apple Pay button on the payment page of an online store, you need to implement the ApplePaySession.canMakePaymentsWithActiveCard method, this method determines whether this device supports payment using Apple Pay.

If it supports payment, you need to draw the “Buy using Apple Pay” button.

Next, you need to create an object ApplePaySession, with the purchase parameters:

  countryCode: 'UA',
currencyCode: 'UAH',
supportedNetworks: ['visa', 'masterCard'],
merchantCapabilities: ['supports3DS'],
total: { label: 'Your Merchant Name', amount: '10.00' },

For a description of the fields, see the Apple Pay on Web documentation.

On the event onvalidatemerchant you need to hang a handler in which it will be called API “api/apple/validate” . The description of the method will be below.

On the event onpaymentauthorized you need to hang a handler that will call API “api/apple/payment”.

After confirming the payment in onpaymentauthorized, you must call the method

ApplePaySession.completePayment.

ApplePaySession documentation can be found on the Apple site.

Merchant Validation Apple Pay (api/apple/validate)

Production url: https://****.procard-ltd.com/api/apple/validate

POST parameters:

ParameterDescriptionTypeValue
operationType of transactionStringPurchase
apple_validation_urlThis parameter comes in the event onvalidatemerchant, event.validationURLString
Example:
session.onvalidatemerchant = (event) => {
  console.log(event.validationURL);
}
merchant_idmerchant identifierString
amountThe amount of the transaction. Example 500.00Float
signatureIn order to confirm the validity of the data, a verification signature must be generated and transmitted in the HMAC_SHA512 request using the SecretKey merchant.String
The string to be HMAC_SHA512 is generated by concatenating the parameters merchant_id, order_id, amount, currency_iso, description separated by “;” (semicolon) in UTF-8 encoding.
The order of parameters during concatenation is important!
order_idUnique transaction number on the merchant side. If the operation is duplicated, the merchant receives an error.String
currency_isoCurrency of paymentStringUAH
descriptionPurpose of payment. It is displayed on the payment page when entering payment details. Displayed in the account statement and registriesString
add_paramsAn array with additional parameters. Additional parameters are then returned to the merchant in a callback callArray
callback_urlURL to which information about the result of the payment will be sentString

The following parameters come in response:

ParameterDescriptionType
apple_validate_dataData to pass to session.completeMerchantValidation methodString
order_keyOrder ID in the payment systemInteger
codeAnswer code (0 - success)String
messageDecoding of the response codeString

Payment confirmation Apple Pay (api/apple/payment)

Production url: https://****.procard-ltd.com/api/apple/payment

The system itself determines which authentication path goes with or without 3DS depending on the data received from Apple.

POST parameters:

ParameterDescriptionType
order_keyOrder ID in the payment systemString
apple_pay_payment_dataBase64 encoded data received in new event onpaymentauthorized in parameter event.payment.String
Example:
session.onpaymentauthorized = (event) => {
  console.log(event.payment);}
}
apple_pay_payment_data_decryptedThe parameter is passed instead of apple_pay_payment_data if payment with a decrypted token is used. Base64 encoded data received in new event onpaymentauthorized in parameter event.paymentString

The answer comes:

ParameterDescriptionTypeValue
transactionStatusTransaction StatusStringApproved - Successfully
Declined - Renouncement
reasonText reason for rejectionString
reasonCodeFailure Error CodeString

After calling this method, a callback comes to the backend trader.

Request for payment with decrypted token example:

{
"order_key": "9910ae2538be76b828f63a08f14ddf4a267d5148713cb2bb2742848fd622cfd266d86cab7f44b",
"apple_pay_payment_data_decrypted": "ewoiYXBwbGljYXRpb25QcmltYXJ5QWNjb3VudE51bWJlciI6ICI0MDEyMDAwMDAwMDAzMTE5IiwKImFwcGxpY2F0aW9uRXhwaXJhdGlvbkRhdGUiOiAiMjgxMTMwIiwKImN1cnJlbmN5Q29kZSI6ICI5ODAiLAoidHJhbnNhY3Rpb25BbW91bnQiOiAxMDAwMCwKImRldmljZU1hbnVmYWN0dXJlcklkZW50aWZpZXIiOiAiMDQwMDEwMDMwMjczIiwKInBheW1lbnREYXRhVHlwZSI6ICIzRFNlY3VyZSIsCiJwYXltZW50RGF0YSI6ewoib25saW5lUGF5bWVudENyeXB0b2dyYW0iOiIxMjMiLAoiZWNpSW5kaWNhdG9yIjoiNSIKfQp9Cg=="
}

Decrypted token structure:

ParameterDescriptionType
applicationPrimaryAccountNumberThe tokenized card numberString
applicationExpirationDateExpiration date of the card (YYMMDD format)String
currencyCodeCurrency of paymentString
transactionAmountThe amount of the transaction. Example 500.00Float
deviceManufacturerIdentifierUnique identifier for the device manufacturerString
paymentDataTypeType of payment dataString
paymentData
onlinePaymentCryptogramA cryptogram for secure online transactionsString
eciIndicatorElectronic Commerce Indicator, shows the security level of the transactionString

Decrypted token example:

{
"applicationPrimaryAccountNumber": "4012000000003119",
"applicationExpirationDate": "281130",
"currencyCode": "980",
"transactionAmount": 10000,
"deviceManufacturerIdentifier": "040010030273",
"paymentDataType": "3DSecure",
"paymentData": {
"onlinePaymentCryptogram": "123",
"eciIndicator": "5"
}
}