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:

ParameterTypeDescriptionValue
operationStringType of transactionPurchase
apple_validation_urlStringThis parameter comes in the event onvalidatemerchant, event.validationURL
Example:
session.onvalidatemerchant = (event) => {
  console.log(event.validationURL);
}
merchant_idStringmerchant identifier
amountFloatThe amount of the transaction. Example 500.00
signatureStringIn 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.
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_idStringUnique transaction number on the merchant side. If the operation is duplicated, the merchant receives an error.
currency_isoStringCurrency of paymentUAH
descriptionStringPurpose of payment. It is displayed on the payment page when entering payment details. Displayed in the account statement and registries
add_paramsArrayAn array with additional parameters. Additional parameters are then returned to the merchant in a callback call
callback_urlStringURL to which information about the result of the payment will be sent

The following parameters come in response:

ParameterTypeDescription
apple_validate_dataStringData to pass to session.completeMerchantValidation method
order_keyIntegerOrder ID in the payment system
codeStringAnswer code (0 - success)
messageStringDecoding of the response code

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:

ParameterTypeDescription
order_keyStringOrder ID in the payment system
apple_pay_payment_dataStringBase64 encoded data received in new event onpaymentauthorized in parameter event.payment.
Example:
session.onpaymentauthorized = (event) => {
  console.log(event.payment);}
}
apple_pay_payment_data_decryptedStringThe 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.payment

The answer comes:

ParameterTypeDescriptionValue
transactionStatusStringTransaction StatusApproved - Successfully
Declined - Renouncement
reasonStringText reason for rejection
reasonCodeStringFailure Error Code
rrnStringReference Retrieval Number

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:

ParameterTypeDescription
applicationPrimaryAccountNumberStringThe tokenized card number
applicationExpirationDateStringExpiration date of the card (YYMMDD format)
currencyCodeStringCurrency of payment
transactionAmountFloatThe amount of the transaction. Example 500.00
deviceManufacturerIdentifierStringUnique identifier for the device manufacturer
paymentDataTypeStringType of payment data
paymentData
onlinePaymentCryptogramStringA cryptogram for secure online transactions
eciIndicatorStringElectronic Commerce Indicator, shows the security level of the transaction

Decrypted token example:

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