Apple Pay
Apple Pay is a digital wallet service provided by Apple Inc. that allows payers to make payments with supported iOS and macOS devices. Apple Pay is a supported digital wallet in the Mastercard Gateway.
This topic includes step-by-step integration steps for Apple Pay. For more information about digital wallets and their payment flow, see Digital Wallets.
These integration methods are supported.
| Integration methods | Payment methods | Operations | Card brands supported |
|---|---|---|---|
|
|
|
|
To view examples of API requests for digital wallet payments, download the Postman collection.
Prerequisites
To accept Apple Pay payments:
- Sign up with Apple and create your merchant ID. See steps to sign up with Apple and create a Merchant ID here.
- Your payment service provider must enable your merchant profile on the gateway to support device payments.
- If you want the gateway to perform the decryption of the payment token, your merchant profile on the gateway must have the "Enable Apple Pay on Hosted Checkout" and "Enable Gateway-Managed Apple Pay on the web payments" privileges required for Hosted Checkout integration method.
Adding support for Apple Pay to your integration
You can integrate Apple Pay into your mobile app or the checkout page of your web site using the Direct Payment integration method.
To let payers complete Apple Pay on the Web payments from an eligible desktop or browser by using an eligible iPhone, see Apple Pay on the Web cross-device experience. This experience is covered for Direct API and Hosted Session integrations only.
- Procure a signed certificate from Apple and upload it to the gateway in the Merchant Administration.
If you want to decrypt the payment token on your server, see Decrypting the Payment Token.
- On payment confirmation, provide the following fields in the AUTHORIZE, PAY, or UPDATE SESSION request.
order.walletProvider = APPLE_PAYApple Pay digital wallet provider
order.amountTotal amount for the order. The value you provide must be the final amount of the order including shipping and other additional amounts.
order.currencyCurrency of the order
sourceOfFunds.provided.card.devicePayment.paymentTokenEncrypted payment token obtained from the Apple Pay SDK. For example, the value in
PKPaymentToken.paymentData.
AUTHORIZE request example for decryption in gateway
{
"apiOperation": "AUTHORIZE",
"order": {
"currency": "USD",
"amount": "61.00",
"walletProvider": "APPLE_PAY"
},
"sourceOfFunds": {
"type": "CARD",
"provided":{
"card":{
"devicePayment":{
"paymentToken":"{\r\n\t\"version\": \"EC_v1\",\r\n\t\"data\":\"WO\/fTbdARsB1Rg3tS4ISwNG4cWDRk3JZDSbP32iDdeMP7UFouS...\",
\r\n\t\"signature\": \"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkg...\",
\r\n\t\"header\": {\r\n\t\t\"transactionId\": \"c162557e7ae1c69a47583bc2364d1a3e531428d13fb664032f9e09fa37381fc1\",
\r\n\t\t\"ephemeralPublicKey\": \"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEMeuRqVEOZAQ...\",
\r\n\t\t\"publicKeyHash\": \"tBGp1mEoHLiHwfOkazpKVbf3cMKmVS98PGufUJ2Q3ys=\"\r\n\t}\r\n}"
//This is only a sample token and will not pass validation. Substitute this with an actual payment token returned from Apple Pay (PKPaymentToken.paymentData).
//The gateway considers this value to be a string, NOT JSON itself. The parentheses are a part of the string.
}
}
}
},
"transaction": {
"source": "INTERNET"
}
}
The gateway decrypts the payment token and processes the transaction using the decrypted data. In addition to the standard fields, the following response fields are returned for a successful authorization using the payment token, if the issuer successfully maps the Device Primary Account Number (DPAN) to the Funding Primary Account Number (FPAN):
sourceOfFunds.provided.card.encryption = DEVICEIndicates that the payer’s device, such as a mobile phone, encrypts the data.
sourceOfFunds.provided.card.deviceSpecificNumberReturns a 6.4 masked DPAN.
sourceOfFunds.provided.card.deviceSpecificExpiry.monthReturns the DPAN expiry month.
sourceOfFunds.provided.card.deviceSpecificExpiry.yearReturns the DPAN expiry year.
sourceOfFunds.provided.card.numberReturns the masked FPAN, typically 0.4 masked, when available from the acquirer.
sourceOfFunds.provided.card.expiry.monthReturns the FPAN expiry month, when available from the acquirer.
sourceOfFunds.provided.card.expiry.yearReturns the FPAN expiry year, when available from the acquirer.
sourceOfFunds.provided.card.devicePayment.cryptogramFormatIdentifies the format of the cryptogram provided for the digital wallet payment.
If you request for an unmasked PAN to be returned in the transaction response, the gateway returns an unmasked DPAN and FPAN, depending on the acquirer support.
responseControls.sensitiveData field to UNMASK, and authenticate your call to the API using certificate authentication.AUTHORIZE response example
{
"authorizationResponse": {
"commercialCard": "123",
"commercialCardIndicator": "1",
"date": "0314",
"financialNetworkCode": "MCC",
"posData": "1025104006600",
"posEntryMode": "812",
"processingCode": "003000",
"responseCode": "00",
"stan": "46465",
"time": "101534",
"transactionIdentifier": "447345902",
"transactionIntegrityClass": "A1"
},
"device": {
"ani": "12341234"
},
"gatewayEntryPoint": "WEB_SERVICES_API",
"merchant": "TESTMERCHANT",
"order": {
"amount": 30.10,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"certainty": "FINAL",
"chargeback": {
"amount": 0,
"currency": "USD"
},
"creationTime": "2023-03-14T10:15:33.819Z",
"currency": "USD",
"id": "844205983",
"lastUpdatedTime": "2023-03-14T10:15:34.265Z",
"merchantAmount": 30.10,
"merchantCategoryCode": "1234",
"merchantCurrency": "USD",
"status": "AUTHORIZED",
"totalAuthorizedAmount": 30.10,
"totalCapturedAmount": 0.00,
"totalDisbursedAmount": 0.00,
"totalRefundedAmount": 0.00,
"walletProvider": "APPLE_PAY"
},
"response": {
"acquirerCode": "00",
"acquirerMessage": "Approved",
"gatewayCode": "APPROVED",
"gatewayRecommendation": "PROCEED"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"devicePayment": {
"cryptogramFormat": "3DSECURE"
},
"deviceSpecificExpiry": {
"month": "1",
"year": "39"
},
"deviceSpecificNumber": "512345xxxxxx0008",
"encryption": "DEVICE",
"expiry": {
"month": "11",
"year": "27"
},
"fundingMethod": "UNKNOWN",
"number": "xxxxxxxxxxxxxxxx",
"scheme": "MASTERCARD",
"storedOnFile": "NOT_STORED"
}
},
"type": "CARD"
},
"timeOfLastUpdate": "2023-03-14T10:15:34.265Z",
"timeOfRecord": "2023-03-14T10:15:33.930Z",
"transaction": {
"acquirer": {
"batch": 20230314,
"date": "0314",
"id": "SYSTEST_ACQ_S2I",
"merchantId": "12345678",
"transactionId": "447345902"
},
"amount": 30.10,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"authorizationCode": "112233",
"currency": "USD",
"id": "950596203",
"receipt": "307310046465",
"source": "INTERNET",
"stan": "46465",
"terminal": "1111",
"type": "AUTHORIZATION"
},
"version": "71"
}
Decrypting the payment token
You can choose to decrypt the payment token on your server instead of providing the payment token for decryption to the gateway. In this case, you must store the encryption credentials and execute the decryption.
- On payment confirmation, submit the encrypted payment token returned by Apple Pay to your server.
- Decrypt the payment token on your server using your private key. For information on the decryption steps, see Payment token format reference.
- Provide the payment data keys from the decrypted token in the corresponding transaction fields in the AUTHORIZE, PAY, or UPDATE SESSION request.
Table: Payment data keys and the corresponding API request fields
Apple Pay JSON Key Corresponding API Request Field Description applicationPrimaryAccountNumbersourceOfFunds.provided.card.numberDPAN of the card that funds this transaction applicationExpirationDatesourceOfFunds.provided.card.expiry.monthsourceOfFunds.provided.card.expiry.yearExpiration date of the applicationPrimaryAccountNumbercardholderNamesourceOfFunds.provided.card.nameOnCardCardholder's name (optional) currencyCodeorder.currencyISO 4217 currency code for the transaction transactionAmountorder.amountOrder amount paymentDataTypesourceOfFunds.provided.card.devicePayment.cryptogramFormatCryptogram format. Set this to 3DSECURE.onlinePaymentCryptogramsourceOfFunds.provided.card.devicePayment.onlinePaymentCryptogramCryptogram in EMV 3-D Secure format eciIndicatorsourceOfFunds.provided.card.devicePayment.eciIndicatorElectronic Commerce Indicator (ECI), if available - In addition to the Payment data keys and the corresponding API request fields, provide the following fields in the AUTHORIZE, PAY, or UPDATE SESSION request and submit it to the gateway:
transaction.source = INTERNETChannel through which you received authorization for the payment for this order. Value
INTERNETindicates that the payer initiated the payment online.order.walletProvider = APPLE_PAYApple Pay digital wallet provider.
device.mobilePhoneModel(optional)Identifier of the mobile device used to initiate the payment.
posTerminal.locationPhysical location of the device in relation to your business premises. The possible values are
PAYER_TERMINAL_OFF_PREMISES or PAYER_TERMINAL_ON_PREMISES.If you do not provide a value,PAYER_TERMINAL_OFF_PREMISESis used.sourceOfFunds.type = CARD
- In addition to the standard fields, the following response fields are returned for a successful authorization.
- sourceOfFunds.provided.card.deviceSpecificNumber: The DPAN in masked format.
- sourceOfFunds.provided.card.deviceSpecificExpiry.month
- sourceOfFunds.provided.card.deviceSpecificExpiry.year
- sourceOfFunds.provided.card.number: The FPAN in masked format.
- sourceOfFunds.provided.card.expiry.month: The expiry month of the card.
- sourceOfFunds.provided.card.expiry.year: The expiry year of the card.
- sourceOfFunds.provided.card.devicePayment.cryptogramFormat
AUTHORIZE request example for decryption in your server
{
"apiOperation": "AUTHORIZE",
"order": {
"amount": "30.10",
"currency": "USD",
"walletProvider": "APPLE_PAY"
},
"sourceOfFunds": {
"provided": {
"card": {
"number": "512345000000X008", Replace "X" with "0"
"expiry": {
"month": "01",
"year": "39"
},
"devicePayment": {
"cryptogramFormat": "3DSECURE",
"onlinePaymentCryptogram": "IA/8pdiWftSsxpFT6wABoDABhgA=",
"eciIndicator": "20"
}
}
},
"type": "CARD"
},
"device": {
"ani": "12341234"
},
"transaction": {
"source": "INTERNET"
}
}
The response is similar regardless of whether the decryption happens in the gateway or your server.
Apple Pay on the Web cross-device experience
Apple Pay on the Web includes a cross-device experience, which Apple also refers to as "Pay in More Browsers." When a payer starts Apple Pay checkout on your website in an eligible desktop or browser environment, Apple Pay can present a cross-device interaction, such as a code that the payer scans, that lets the payer complete the payment using an eligible iPhone.
Supported integration models
The following table shows the integration models covered by this guidance for the Apple Pay on the Web cross-device experience.
| Integration model | Documentation status for this capability |
|---|---|
| Direct Payment | In scope |
| Hosted Session | In scope |
| Hosted Checkout | Out of scope at this time |
Hosted Checkout is not in scope for the Apple Pay on the Web cross-device experience at this time. Support for this experience in Direct Payment and Hosted Session integrations does not indicate support in Hosted Checkout.
Responsibilities
For Direct Payment and Hosted Session integrations, you own the Apple Pay on the Web implementation, including Apple merchant validation and Apple Pay session establishment. The following table describes who is responsible for each part of the cross-device experience.
| Party | Responsibilities |
|---|---|
| Apple and the browser or platform |
|
| You (the merchant) |
|
| Your payment service provider | Enables your merchant profile on the gateway to support device payments, as described in Prerequisites. |
| Mastercard Gateway |
|
Cross-device payment flow
The following steps describe the cross-device payment flow at a conceptual level. The label at the start of each step identifies which part of the flow it belongs to.
- Merchant implementation: The payer starts Apple Pay checkout on your eligible web checkout page.
- Apple/platform experience: Apple Pay or the applicable browser or platform presents the available cross-device interaction.
- Apple/platform experience: The payer follows the presented handoff using an eligible Apple device.
- Merchant validation/session establishment: Your Apple Pay implementation manages the applicable Apple Pay JS session and merchant validation flow.
- Merchant validation/session establishment: The Apple merchant session is established through the applicable Apple API.
- Merchant implementation: After the payer confirms the payment, you receive the encrypted Apple Pay payment token.
- Merchant implementation: You submit the payment token using your existing supported Direct Payment or Hosted Session integration.
- Gateway payment-token processing: The gateway processes the payment token through the existing supported Apple Pay payment flow.
- Gateway payment-token processing: Existing gateway response, error handling, testing, and troubleshooting guidance continues to apply.
Submitting the payment token
Submit the Apple Pay payment token that you receive from the cross-device experience in the same way as any other Apple Pay on the Web payment token. For token submission, supported operations, decryption options, request construction, and response handling, see the following existing guidance:
- Adding support for Apple Pay to your integration and Decrypting the payment token in this guide.
- API Reference: AUTHORIZE, PAY, and UPDATE SESSION.
- Direct Payment and Hosted Session integration guidance.
- Digital Wallets for the digital wallet payment flow.
- Testing your Apple Pay integration and Expected gateway responses in this guide, and Apple Sandbox testing.
Apple Pay resources
For Apple Pay on the Web implementation details, including merchant registration, certificates, domain verification, merchant validation, session handling, and browser, device, and operating system requirements, see Apple Pay documentation:
Credential on file transactions
This section describes how to submit cardholder-initiated transactions (CITs) and merchant-initiated transactions (MITs) with Apple Pay to the gateway to comply with card scheme standards for processing these transactions.
If you collect payment details from your payers, store them, and then use them to process future payments, inform the gateway in the initial transaction that you are storing the payment details and intend to use them in the future. You must also provide this information to the gateway when you use the stored payment details in subsequent payments, whether the payer initiates them (CIT) or you initiate them (MIT) based on a payment agreement with the payer.
- Cardholder-initiated transaction (CIT): A transaction that the payer actively participates in by authenticating on a device, such as a smartphone or tablet. Typically, device payments are secure purchases made using a credit or debit card associated with the device. A CIT can be a one-off payment where you do not store the payment details that the payer provides. However, the payer can agree for you to store their payment details for future use, usually as part of a customer registration or account creation process, so that you can perform subsequent CITs using the stored payment details.
- Merchant-initiated transaction (MIT): A transaction that you perform using stored payment details without the active participation of the payer. You can submit MITs if you have a payment agreement in which the payer agrees for you to store their payment details for future use and authorizes you to initiate subsequent payments without their active participation. For example, you can offer:
- Recurring payments: You charge the payer on a predefined schedule for products or services, such as a magazine subscription or a gym membership.
- Installments: The payer pays for a single purchase in several installments.
- Top-ups: You charge the payer on demand, such as an account top-up when the available amount falls below a defined threshold.
sourceOfFunds.provided.card.storedOnFile field to indicate to the gateway whether the payment details are stored, not stored, or you intend to store them.For more information, see Cardholder and Merchant Initiated Payments and Credential on File Transactions.
CITs and MITs with decryption in gateway
You can let the gateway decrypt the payment token on your behalf. In this case, the gateway stores the encryption credentials and executes the decryption.
Cardholder-initiated transactions
If the payer agrees for you to store their payment details for future use, provide the following fields in the initial transaction:
sourceOfFunds.type = CARDsourceOfFunds.provided.card.devicePayment.paymentTokenEncrypted payment token obtained from the Apple Pay SDK. For example, the value in
PKPaymentToken.paymentData.sourceOfFunds.provided.card.storedOnFile = TO_BE_STOREDIndicates that the payer agrees for you to store their payment details for future use.
transaction.source = INTERNETIndicates that the payer initiated the transaction.
order.walletProvider = APPLE_PAYApple Pay digital wallet provider.
agreement.idUnique identifier that you generate for the payment agreement with the payer.
agreement.typeType of payment agreement. The possible values are
RECURRING,UNSCHEDULED,INSTALLMENT, orOTHER.
For subsequent payments that the payer initiates using the stored payment details, provide the following fields:
sourceOfFunds.type = CARDsourceOfFunds.provided.card.devicePayment.paymentTokenEncrypted payment token obtained from the Apple Pay SDK.
sourceOfFunds.provided.card.storedOnFile = STOREDIndicates that the transaction uses stored payment details.
transaction.source = INTERNETorder.walletProvider = APPLE_PAYagreement.idSame
agreement.idthat you provided in the initial transaction. This allows the gateway to link the payments in a series.
URL: https://eu-gateway.mastercard.com/api/rest/version/<version>/merchant/<merchant_ID>/order/<order_ID>/transaction/<transaction_ID>
HTTP Method: PUT
{
"order": {
"amount": "1500",
"currency": "GBP",
"walletProvider": "APPLE_PAY"
},
"apiOperation": "AUTHORIZE",
"agreement": {
"id": "563376190",
"type": "RECURRING"
},
"transaction": {
"source": "INTERNET"
},
"sourceOfFunds": {
"type": "CARD",
"provided": {
"card": {
"storedOnFile": "TO_BE_STORED",
"devicePayment": {
"paymentToken": "{\"version\":\"EC_v1\",\"data\":\"WO/fTbdARsB1Rg3tS4ISwNG4cWDRk3JZDSbP32iDdeMP7UFouS...\",\"signature\":\"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkg...\",\"header\":{\"transactionId\":\"c162557e7ae1c69a47583bc2364d1a3e531428d13fb664032f9e09fa37381fc1\",\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEMeuRqVEOZAQ...\",\"publicKeyHash\":\"tBGp1mEoHLiHwfOkazpKVbf3cMKmVS98PGufUJ2Q3ys=\"}}"
}
}
}
}
}
PKPaymentToken.paymentData.
{
"agreement": {
"id": "563376190",
"type": "RECURRING"
},
"authorizationResponse": {
"commercialCardIndicator": "3",
"date": "0111",
"financialNetworkCode": "MIE",
"financialNetworkDate": "2024-01-11",
"posData": "1025104006600",
"posEntryMode": "812",
"processingCode": "000000",
"responseCode": "00",
"stan": "198378",
"time": "070743",
"transactionIdentifier": "000GT4"
},
"gatewayEntryPoint": "WEB_SERVICES_API",
"merchant": "TESTMERCHANT",
"order": {
"amount": 1500.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"certainty": "FINAL",
"chargeback": {
"amount": 0,
"currency": "GBP"
},
"creationTime": "2024-01-11T07:07:43.261Z",
"currency": "GBP",
"fundingStatus": "NOT_SUPPORTED",
"id": "405535038",
"lastUpdatedTime": "2024-01-11T07:07:44.367Z",
"merchantAmount": 1500.00,
"merchantCategoryCode": "1234",
"merchantCurrency": "GBP",
"status": "AUTHORIZED",
"totalAuthorizedAmount": 1500.00,
"totalCapturedAmount": 0.00,
"totalDisbursedAmount": 0.00,
"totalRefundedAmount": 0.00,
"walletProvider": "APPLE_PAY"
},
"response": {
"acquirerCode": "00",
"acquirerMessage": "Approved",
"gatewayCode": "APPROVED",
"gatewayRecommendation": "PROCEED"
},
"result": "SUCCESS",
"risk": {
"response": {
"gatewayCode": "ACCEPTED",
"provider": "EMULATOR",
"review": {
"decision": "NOT_REQUIRED"
},
"rule": [
{
"data": "520424",
"name": "MSO_BIN_RANGE",
"recommendation": "NO_ACTION",
"type": "MSO_RULE"
}
],
"totalScore": -99
}
},
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"devicePayment": {
"cryptogramFormat": "3DSECURE"
},
"deviceSpecificExpiry": {
"month": "5",
"year": "26"
},
"deviceSpecificNumber": "520424xxxxxx3951",
"encryption": "DEVICE",
"fundingMethod": "UNKNOWN",
"number": "xxxxxxxxxxxxxxxx",
"scheme": "MASTERCARD",
"storedOnFile": "TO_BE_STORED"
}
},
"type": "CARD"
},
"timeOfLastUpdate": "2024-01-11T07:07:44.367Z",
"timeOfRecord": "2024-01-11T07:07:43.280Z",
"transaction": {
"acquirer": {
"batch": 20240112,
"date": "0112",
"id": "CBA_S2I",
"merchantId": "123456",
"transactionId": "000GT4"
},
"amount": 1500.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"authorizationCode": "569516",
"currency": "GBP",
"funding": {
"status": "NOT_SUPPORTED"
},
"id": "951587782",
"receipt": "401107198378",
"source": "INTERNET",
"stan": "198378",
"terminal": "CBAS2I01",
"type": "AUTHORIZATION"
},
"version": "78"
}
Gateway tokenization of a previous order
To store the payment details from a previous successful CIT, use the CREATE OR UPDATE TOKEN operation and provide the order ID of the CIT in the referenceOrderId field. The gateway returns a gateway token for the payment details used in the referenced order and stores the token in the token repository configured on your merchant profile. For more information, see Gateway Tokenization.
URL: https://eu-gateway.mastercard.com/api/rest/version/<version>/merchant/<merchant_ID>/token
HTTP Method: POST
{
"referenceOrderId": "405535038"
}
{
"referenceOrderId": "405535038",
"repositoryId": "UNIQUETOKRANDON",
"response": {
"gatewayCode": "BASIC_VERIFICATION_SUCCESSFUL"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"deviceSpecificExpiry": {
"month": "5",
"year": "26"
},
"deviceSpecificNumber": "520424xxxxxx3951",
"expiry": "0526",
"fundingMethod": "UNKNOWN",
"scheme": "MASTERCARD"
}
},
"type": "CARD"
},
"status": "VALID",
"token": "9251571190099835",
"usage": {
"lastUpdated": {
"merchantId": "TESTMERCHANT",
"time": "2024-01-11T07:09:04.589Z"
},
"lastUsedTime": "2024-01-11T07:09:04.680Z"
},
"verificationStrategy": "BASIC"
}
Merchant-initiated transactions
In the initial transaction in the series, provide the fields for the initial transaction described in Cardholder-initiated transactions.
For subsequent payments in the series that you initiate, provide the following fields:
sourceOfFunds.type = CARDsourceOfFunds.tokenGateway token that the gateway returned when you tokenized the payment details.
sourceOfFunds.provided.card.storedOnFile = STOREDtransaction.source = MERCHANTIndicates that you initiated the transaction.
order.walletProvider = APPLE_PAYagreement.idSame
agreement.idthat you provided in the initial transaction. This allows the gateway to link the payments in a series.
URL: https://eu-gateway.mastercard.com/api/rest/version/<version>/merchant/<merchant_ID>/order/<order_ID>/transaction/<transaction_ID>
HTTP Method: PUT
{
"apiOperation": "AUTHORIZE",
"order": {
"amount": "100",
"currency": "GBP",
"walletProvider": "APPLE_PAY"
},
"sourceOfFunds": {
"provided": {
"card": {
"storedOnFile": "STORED"
}
},
"token": "9251571190099835",
"type": "CARD"
},
"agreement": {
"id": "563376190",
"type": "RECURRING"
},
"transaction": {
"source": "MERCHANT"
}
}
{
"agreement": {
"id": "563376190",
"type": "RECURRING"
},
"authorizationResponse": {
"commercialCardIndicator": "3",
"date": "0111",
"financialNetworkCode": "MIE",
"financialNetworkDate": "2024-01-11",
"posData": "2024104000000",
"posEntryMode": "102",
"processingCode": "000000",
"responseCode": "00",
"stan": "199378",
"time": "071007",
"transactionIdentifier": "000GT8"
},
"gatewayEntryPoint": "WEB_SERVICES_API",
"merchant": "TESTMERCHANT",
"order": {
"amount": 100.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"certainty": "FINAL",
"chargeback": {
"amount": 0,
"currency": "GBP"
},
"creationTime": "2024-01-11T07:10:07.850Z",
"currency": "GBP",
"fundingStatus": "NOT_SUPPORTED",
"id": "112835989",
"lastUpdatedTime": "2024-01-11T07:10:07.921Z",
"merchantAmount": 100.00,
"merchantCategoryCode": "1234",
"merchantCurrency": "GBP",
"status": "AUTHORIZED",
"totalAuthorizedAmount": 100.00,
"totalCapturedAmount": 0.00,
"totalDisbursedAmount": 0.00,
"totalRefundedAmount": 0.00,
"walletProvider": "APPLE_PAY"
},
"response": {
"acquirerCode": "00",
"acquirerMessage": "Approved",
"gatewayCode": "APPROVED",
"gatewayRecommendation": "PROCEED"
},
"result": "SUCCESS",
"risk": {
"response": {
"gatewayCode": "ACCEPTED",
"provider": "EMULATOR",
"review": {
"decision": "NOT_REQUIRED"
},
"rule": [
{
"data": "520424",
"name": "MSO_BIN_RANGE",
"recommendation": "NO_ACTION",
"type": "MSO_RULE"
}
],
"totalScore": -25
}
},
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"devicePayment": {
"cryptogramFormat": "3DSECURE"
},
"deviceSpecificExpiry": {
"month": "5",
"year": "26"
},
"deviceSpecificNumber": "520424xxxxxx3951",
"fundingMethod": "UNKNOWN",
"number": "xxxxxxxxxxxxxxxx",
"scheme": "MASTERCARD"
}
},
"token": "9251571190099835",
"type": "CARD"
},
"timeOfLastUpdate": "2024-01-11T07:10:07.921Z",
"timeOfRecord": "2024-01-11T07:10:06.746Z",
"transaction": {
"acquirer": {
"batch": 20240112,
"date": "0112",
"id": "CBA_S2I",
"merchantId": "123456",
"transactionId": "000GT8"
},
"amount": 100.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"authorizationCode": "487460",
"currency": "GBP",
"funding": {
"status": "NOT_SUPPORTED"
},
"id": "665566840",
"receipt": "401107199378",
"source": "MERCHANT",
"stan": "199378",
"terminal": "CBAS2I01",
"type": "AUTHORIZATION"
},
"version": "78"
}
CITs and MITs with decryption in your server
You can decrypt the payment token on your server instead of providing the payment token to the gateway for decryption. In this case, you must store the encryption credentials and execute the decryption.
Cardholder-initiated transactions
Decrypt the payment token and provide the payment data keys from the decrypted token in the corresponding API request fields, as described in Decrypting the payment token.
If the payer agrees for you to store their payment details for future use, provide the following fields in the initial transaction:
sourceOfFunds.type = CARDsourceOfFunds.provided.card.numbersourceOfFunds.provided.card.expiry.monthsourceOfFunds.provided.card.expiry.yearsourceOfFunds.provided.card.nameOnCard(optional)sourceOfFunds.provided.card.devicePayment.cryptogramFormatsourceOfFunds.provided.card.devicePayment.onlinePaymentCryptogramsourceOfFunds.provided.card.storedOnFile = TO_BE_STOREDIndicates that the payer agrees for you to store their payment details for future use.
transaction.source = INTERNETIndicates that the payer initiated the transaction.
order.walletProvider = APPLE_PAYApple Pay digital wallet provider.
agreement.idUnique identifier that you generate for the payment agreement with the payer.
agreement.typeType of payment agreement. The possible values are
RECURRING,UNSCHEDULED,INSTALLMENT, orOTHER.
URL: https://eu-gateway.mastercard.com/api/rest/version/<version>/merchant/<merchant_ID>/order/<order_ID>/transaction/<transaction_ID>
HTTP Method: PUT
{
"apiOperation": "AUTHORIZE",
"order": {
"amount": "580",
"currency": "AUD",
"walletProvider": "APPLE_PAY"
},
"sourceOfFunds": {
"provided": {
"card": {
"number": "5123456789012346",
"expiry": {
"month": "01",
"year": "39"
},
"devicePayment": {
"cryptogramFormat": "3DSECURE",
"onlinePaymentCryptogram": "gIGCg4SFhoeIiYqLjI2Oj5CRkpM="
},
"storedOnFile": "TO_BE_STORED"
}
},
"type": "CARD"
},
"agreement": {
"id": "790022360",
"type": "UNSCHEDULED",
"amountVariability": "FIXED"
},
"transaction": {
"source": "INTERNET"
},
"device": {
"ani": "12341234",
"mobilePhoneModel": "Some Mobile Model"
},
"posTerminal": {
"location": "PAYER_TERMINAL_OFF_PREMISES",
"lane": "Lane_01"
}
}
{
"agreement": {
"id": "790022360",
"type": "UNSCHEDULED"
},
"authorizationResponse": {
"commercialCard": "123",
"commercialCardIndicator": "1",
"date": "0206",
"financialNetworkCode": "MCC",
"posData": "1024104006600",
"posEntryMode": "812",
"processingCode": "003000",
"responseCode": "00",
"stan": "12461",
"time": "073029",
"transactionIdentifier": "520506008",
"transactionIntegrityClass": "A1"
},
"device": {
"ani": "12341234",
"mobilePhoneModel": "Some Mobile Model"
},
"gatewayEntryPoint": "WEB_SERVICES_API",
"merchant": "TESTMERCHANT",
"order": {
"amount": 580.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"certainty": "FINAL",
"chargeback": {
"amount": 0,
"currency": "AUD"
},
"creationTime": "2024-02-06T07:30:29.265Z",
"currency": "AUD",
"id": "20448370",
"lastUpdatedTime": "2024-02-06T07:30:29.578Z",
"merchantAmount": 580.00,
"merchantCategoryCode": "1234",
"merchantCurrency": "AUD",
"status": "AUTHORIZED",
"totalAuthorizedAmount": 580.00,
"totalCapturedAmount": 0.00,
"totalDisbursedAmount": 0.00,
"totalRefundedAmount": 0.00,
"walletProvider": "APPLE_PAY"
},
"posTerminal": {
"lane": "Lane_01",
"location": "PAYER_TERMINAL_OFF_PREMISES"
},
"response": {
"acquirerCode": "00",
"acquirerMessage": "Approved",
"gatewayCode": "APPROVED",
"gatewayRecommendation": "PROCEED"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"devicePayment": {
"cryptogramFormat": "3DSECURE"
},
"deviceSpecificExpiry": {
"month": "1",
"year": "39"
},
"deviceSpecificNumber": "512345xxxxxx2346",
"fundingMethod": "UNKNOWN",
"number": "xxxxxxxxxxxxxxxx",
"scheme": "MASTERCARD",
"storedOnFile": "TO_BE_STORED"
}
},
"type": "CARD"
},
"timeOfLastUpdate": "2024-02-06T07:30:29.578Z",
"timeOfRecord": "2024-02-06T07:30:29.315Z",
"transaction": {
"acquirer": {
"batch": 20240206,
"date": "0206",
"id": "SYSTEST_ACQ_S2I",
"merchantId": "123456",
"transactionId": "520506008"
},
"amount": 580.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"authorizationCode": "112233",
"currency": "AUD",
"id": "973019956",
"receipt": "403707012461",
"source": "INTERNET",
"stan": "12461",
"terminal": "11111",
"type": "AUTHORIZATION"
},
"version": "78"
}
Gateway tokenization of a previous order
To submit subsequent CITs and MITs, you must store the device payment credentials after you decrypt the payment token, and you should get the payer's consent to store them. You can either store the payment credentials yourself and use them directly in subsequent MITs, or request a gateway token for the payment credentials and use the token in subsequent transactions.
To request a gateway token, use the CREATE OR UPDATE TOKEN operation and provide the order ID of a previous successful CIT in the referenceOrderId field. The gateway returns a gateway token for the payment details used in the referenced order and stores the token in the token repository configured on your merchant profile. For more information, see Gateway Tokenization.
URL: https://eu-gateway.mastercard.com/api/rest/version/<version>/merchant/<merchant_ID>/token
HTTP Method: POST
{
"referenceOrderId": "20448370"
}
{
"referenceOrderId": "20448370",
"repositoryId": "REPO58687",
"response": {
"gatewayCode": "BASIC_VERIFICATION_SUCCESSFUL"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"deviceSpecificExpiry": {
"month": "1",
"year": "39"
},
"deviceSpecificNumber": "512345xxxxxx2346",
"expiry": "0139",
"fundingMethod": "DEBIT",
"scheme": "MASTERCARD"
}
},
"type": "CARD"
},
"status": "VALID",
"token": "9333494766422756",
"usage": {
"lastUpdated": {
"merchantId": "TESTMERCHANT",
"time": "2024-02-06T07:30:36.224Z"
},
"lastUsedTime": "2024-02-06T07:30:36.251Z"
},
"verificationStrategy": "BASIC"
}
Merchant-initiated transactions
In the initial transaction in the series, provide the fields for the initial transaction described in Cardholder-initiated transactions.
For subsequent payments in the series that you initiate using a gateway token, provide the following fields:
sourceOfFunds.type = CARDsourceOfFunds.tokenGateway token that the gateway returned when you tokenized the payment details.
sourceOfFunds.provided.card.storedOnFile = STOREDtransaction.source = MERCHANTIndicates that you initiated the transaction.
order.walletProvider = APPLE_PAYagreement.idSame
agreement.idthat you provided in the initial transaction. This allows the gateway to link the payments in a series.
For subsequent payments in the series that you initiate using the stored payment credentials instead of a gateway token, provide the following fields:
sourceOfFunds.type = CARDsourceOfFunds.provided.card.numbersourceOfFunds.provided.card.expiry.monthsourceOfFunds.provided.card.expiry.yearsourceOfFunds.provided.card.nameOnCard(optional)sourceOfFunds.provided.card.devicePayment.cryptogramFormatsourceOfFunds.provided.card.devicePayment.onlinePaymentCryptogramsourceOfFunds.provided.card.storedOnFile = STOREDtransaction.source = MERCHANTorder.walletProvider = APPLE_PAYagreement.idSame
agreement.idthat you provided in the initial transaction. This allows the gateway to link the payments in a series.agreement.typeType of payment agreement. The possible values are
RECURRING,UNSCHEDULED,INSTALLMENT, orOTHER.
In addition to these fields, provide the following fields in the AUTHORIZE, PAY, or UPDATE SESSION request:
device.mobilePhoneModel(optional)Identifier of the mobile device used to initiate the payment.
posTerminal.locationPhysical location of the device in relation to your business premises. The possible values are
PAYER_TERMINAL_OFF_PREMISESorPAYER_TERMINAL_ON_PREMISES. If you do not provide a value, the gateway usesPAYER_TERMINAL_OFF_PREMISES.
URL: https://eu-gateway.mastercard.com/api/rest/version/<version>/merchant/<merchant_ID>/order/<order_ID>/transaction/<transaction_ID>
HTTP Method: PUT
{
"apiOperation": "AUTHORIZE",
"order": {
"amount": "580",
"currency": "AUD",
"walletProvider": "APPLE_PAY"
},
"sourceOfFunds": {
"provided": {
"card": {
"storedOnFile": "STORED"
}
},
"token": "9333494766422756",
"type": "CARD"
},
"agreement": {
"id": "790022360",
"type": "UNSCHEDULED",
"amountVariability": "FIXED"
},
"transaction": {
"source": "MERCHANT"
},
"device": {
"ani": "12341234",
"mobilePhoneModel": "Some Mobile Model"
},
"posTerminal": {
"location": "PAYER_TERMINAL_OFF_PREMISES",
"lane": "Lane_01"
}
}
{
"agreement": {
"id": "790022360",
"type": "UNSCHEDULED"
},
"authorizationResponse": {
"commercialCard": "123",
"commercialCardIndicator": "1",
"date": "0206",
"financialNetworkCode": "357",
"posData": "2024104000000",
"posEntryMode": "102",
"processingCode": "003000",
"responseCode": "00",
"stan": "5222",
"time": "073039",
"transactionIdentifier": "498794485"
},
"device": {
"ani": "12341234",
"mobilePhoneModel": "Some Mobile Model"
},
"gatewayEntryPoint": "WEB_SERVICES_API",
"merchant": "TESTMERCHANT",
"order": {
"amount": 580.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"certainty": "FINAL",
"chargeback": {
"amount": 0,
"currency": "AUD"
},
"creationTime": "2024-02-06T07:30:39.453Z",
"currency": "AUD",
"id": "398599440",
"lastUpdatedTime": "2024-02-06T07:30:39.376Z",
"merchantAmount": 580.00,
"merchantCategoryCode": "1234",
"merchantCurrency": "AUD",
"status": "AUTHORIZED",
"totalAuthorizedAmount": 580.00,
"totalCapturedAmount": 0.00,
"totalDisbursedAmount": 0.00,
"totalRefundedAmount": 0.00,
"walletProvider": "APPLE_PAY"
},
"posTerminal": {
"lane": "Lane_01",
"location": "PAYER_TERMINAL_OFF_PREMISES"
},
"response": {
"acquirerCode": "00",
"acquirerMessage": "Approved",
"gatewayCode": "APPROVED",
"gatewayRecommendation": "PROCEED"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"devicePayment": {
"cryptogramFormat": "3DSECURE"
},
"deviceSpecificExpiry": {
"month": "1",
"year": "39"
},
"deviceSpecificNumber": "512345xxxxxx2346",
"fundingMethod": "UNKNOWN",
"number": "xxxxxxxxxxxxxxxx",
"scheme": "MASTERCARD",
"storedOnFile": "STORED"
}
},
"token": "9333494766422756",
"type": "CARD"
},
"timeOfLastUpdate": "2024-02-06T07:30:39.376Z",
"timeOfRecord": "2024-02-06T07:30:39.097Z",
"transaction": {
"acquirer": {
"batch": 20240206,
"date": "0206",
"id": "SYSTEST_ACQ_S2I",
"merchantId": "123456",
"transactionId": "498794485"
},
"amount": 580.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"authorizationCode": "112233",
"currency": "AUD",
"id": "357366279",
"receipt": "403707005222",
"source": "MERCHANT",
"stan": "5222",
"terminal": "11111",
"type": "AUTHORIZATION"
},
"version": "78"
}
URL: https://eu-gateway.mastercard.com/api/rest/version/<version>/merchant/<merchant_ID>/order/<order_ID>/transaction/<transaction_ID>
HTTP Method: PUT
{
"apiOperation": "AUTHORIZE",
"order": {
"amount": "580",
"currency": "AUD",
"walletProvider": "APPLE_PAY"
},
"sourceOfFunds": {
"provided": {
"card": {
"number": "5123456789012346",
"expiry": {
"month": "01",
"year": "39"
},
"devicePayment": {
"cryptogramFormat": "3DSECURE",
"onlinePaymentCryptogram": "gIGCg4SFhoeIiYqLjI2Oj5CRkpM="
},
"storedOnFile": "STORED"
}
},
"type": "CARD"
},
"agreement": {
"id": "667531488",
"type": "UNSCHEDULED",
"amountVariability": "FIXED"
},
"transaction": {
"source": "MERCHANT"
},
"device": {
"ani": "12341234",
"mobilePhoneModel": "Some Mobile Model"
},
"posTerminal": {
"location": "PAYER_TERMINAL_OFF_PREMISES",
"lane": "Lane_01"
}
}
{
"agreement": {
"id": "667531488",
"type": "UNSCHEDULED"
},
"authorizationResponse": {
"commercialCard": "888",
"commercialCardIndicator": "3",
"financialNetworkCode": "777",
"posData": "2024104000000",
"posEntryMode": "102",
"processingCode": "003000",
"responseCode": "00",
"stan": "24094",
"transactionIdentifier": "123456789"
},
"device": {
"ani": "12341234",
"mobilePhoneModel": "Some Mobile Model"
},
"gatewayEntryPoint": "WEB_SERVICES_API",
"merchant": "TESTMERCHANT",
"order": {
"amount": 580.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"certainty": "FINAL",
"chargeback": {
"amount": 0,
"currency": "AUD"
},
"creationTime": "2024-02-07T10:48:51.977Z",
"currency": "AUD",
"id": "209444505",
"lastUpdatedTime": "2024-02-07T10:48:52.315Z",
"merchantAmount": 580.00,
"merchantCategoryCode": "1234",
"merchantCurrency": "AUD",
"status": "AUTHORIZED",
"totalAuthorizedAmount": 580.00,
"totalCapturedAmount": 0.00,
"totalDisbursedAmount": 0.00,
"totalRefundedAmount": 0.00,
"walletProvider": "APPLE_PAY"
},
"posTerminal": {
"lane": "Lane_01",
"location": "PAYER_TERMINAL_OFF_PREMISES"
},
"response": {
"acquirerCode": "00",
"acquirerMessage": "Approved",
"gatewayCode": "APPROVED",
"gatewayRecommendation": "PROCEED"
},
"result": "SUCCESS",
"sourceOfFunds": {
"provided": {
"card": {
"brand": "MASTERCARD",
"devicePayment": {
"cryptogramFormat": "3DSECURE"
},
"deviceSpecificExpiry": {
"month": "1",
"year": "39"
},
"deviceSpecificNumber": "512345xxxxxx2346",
"fundingMethod": "UNKNOWN",
"number": "xxxxxxxxxxxxxxxx",
"scheme": "MASTERCARD",
"storedOnFile": "STORED"
}
},
"type": "CARD"
},
"timeOfLastUpdate": "2024-02-07T10:48:52.315Z",
"timeOfRecord": "2024-02-07T10:48:52.045Z",
"transaction": {
"acquirer": {
"batch": 20240207,
"date": "0207",
"id": "SYSTEST_ACQ_S2I",
"merchantId": "123456",
"transactionId": "123456789"
},
"amount": 580.00,
"authenticationStatus": "AUTHENTICATION_NOT_IN_EFFECT",
"authorizationCode": "024094",
"currency": "AUD",
"id": "873384770",
"receipt": "403810024094",
"source": "MERCHANT",
"stan": "24094",
"terminal": "11111",
"type": "AUTHORIZATION"
},
"version": "78"
}
Testing your Apple Pay integration
TEST- prefix.
If you use a TEST- prefixed card, the gateway returns 14 - invalid card number. This is expected behavior. It does not indicate a configuration error. See expected gateway responses below.To test your Apple Pay integration using your test merchant profile and a supported FPAN as provided by Apple for Sandbox testing.
- Configure your app to use the Apple Pay Sandbox environment with your gateway test merchant profile. When the payer selects a card in Apple Pay, the app generates a payment token in test mode.
- If the gateway decrypts the payment token, procure a signed certificate from Apple and upload it to the gateway through Merchant Administration in production using your gateway test merchant profile. The gateway uses the certificate to decrypt the payment token.
- If you decrypt the payment token in your server, use the DPAN from the decrypted token to perform test transactions.
If the response.gatewayCode field indicates that the transactions are APPROVED or DECLINED, the gateway could process your test transactions successfully.
Testing Apple Pay integration with gateway test data
You can test your integration with the gateway in production using your test merchant profile with a valid test card and provide the order amount value as provided in the following table to get the expected simulated response.
| Order amount | Response |
|---|---|
5656 |
Approved |
5757 |
Declined |
5858 |
TIMED_OUT |
5959 |
UNSPECIFIED_FAILURE |
6161 |
Partially Approved |
6262 |
System Error |
6363 |
UNKNOWN |
Expected gateway responses
If the response.gatewayCode field indicates that the transactions are APPROVED or DECLINED, or any other responses as per the order amount simulation, the gateway could process your test transactions successfully.
If the response.gatewayCode field indicates 14 - invalid card number when you use a TEST- prefixed card, this is expected behavior.
Apple Pay with the Mobile SDK
The Mobile SDK helps you develop a mobile app that accepts Apple Pay payments through the gateway. The gateway offers support for Apple Pay through the Mobile SDK. Click here for the Mobile SDK integration guidelines for the iOS platform.