Apple Pay
You can accept payments through Apple Pay via Checkout (Hosted Payments Page - HPP) or via eComm API.
Follow the integration steps below to process transactions via Verifone ecomm API.
Merchant onboarding
- Merchant shall register a merchant ID through Apple (see instructions here: https://developer.apple.com/library/archive/ApplePay_Guide/Configuration.html#//apple_ref/doc/uid/TP40014764-CH2)
- Merchant needs to request through Verifone the generation of the cryptographic keys. Verifone generates cryptographic keys and provide the public key via a Certificate Signing Request (CSR) to the merchant.
- Merchant shall upload the CSR to the Apple Developer portal in return, Apple will provide the merchant a certificate.
(see instructions here: https://developer.apple.com/library/archive/ApplePay_Guide/Configuration.html#//apple_ref/doc/uid/TP40014764-CH2) - Merchant shall import the certificate that received in step #3 in Verifone.
- Merchant will need to download and host the domain-verification file at the following path:
https://[DOMAIN_NAME]/.well-known/apple-developer-merchantid-domain-association
Generate a unique merchant_reference
The merchant_reference needs to be unique to identify the shopper when they are redirected to your server by Apple Pay. In the next step, you will be creating a transaction through the API, the transaction will return an id that needs to be stored safely with the reference. When the shopper returns, you can use this reference to confirm either through the webhook or through the GET transaction API call if the shopper has successfully completed the transaction.
Required fields
parameters |
Description |
---|---|
payment_provider_contract | In the Payment Provider Contracts section in Verifone Central, set the Payment Type to Apple Pay for web, select your contract and copy the Payment Provider Contract ID. Please note this value is different in Sandbox and in Production. |
amount | Amount of the transaction |
merchant_reference | Unique UUID you generate and can link the transaction to when the customer returns |
currency_code | More on the all currencies supported here: Verifone eCommerce API | Verifone Developer Portal |
wallet_type |
string Enum: "APPLE_PAY" |
wallet_payload |
object The encrypted payload object provided by the Wallet on the frontend |
Start a payment session for Apple Pay wallet transactions
Create a merchant payment session
Parameters |
Description |
---|---|
validation_url |
string The ULR pointing to the Apple Pay validation location. |
domain |
string The domain from which the payment request will be initiated. |
payment_provider_contract |
string <uuid-flexible> The identifier of payment provider contract you want to process the transaction request with |
Web Integration
An Apple Pay web integration consists of implementing both client side and server side components. You will need to implement the following:
- Create your apple pay button and initialize your apple pay session when clicked.
https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_javascript - Initiate the merchant session by calling the on the
validatemerchant
event and provide the response to thesession.completeMerchantValidation
callback.
https://verifone.cloud/api-catalog/verifone-ecommerce-api#operation/validationUrl - Use the Apple Pay token to make a wallet transaction API call and complete the apple pay session based on the response.
https://verifone.cloud/api-catalog/verifone-ecommerce-api#operation/walletTransaction
Code sample
const ApplePaymentOptions = {
countryCode: "US",
currencyCode: "USD",
merchantCapabilities: ["supports3DS"],
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
total: {
label: "Demo (Card is not charged)",
type: "final",
amount: "1.99",
},
};
const canMakePayments =
window.ApplePaySession && window.ApplePaySession.canMakePayments();
let session;
function handleApplePayRequest(formValues) {
if (canMakePayments) {
session = new window.ApplePaySession(3, ApplePaymentOptions);
session.onpaymentauthorized = makeTransaction(formValues);
session.addEventListener("validatemerchant", validateMerchant);
session.begin();
console.log("INFO - BEGIN SESSION...");
}
}
function validateMerchant(e) {
// Pass the validation URL and domain to your server to make the wallet transaction API call
fetch(`YOUR_ENDPOINT`, {
method: "POST",
headers: REQUEST_HEADERS,
body: JSON.stringify({
validation_url: e.validationURL,
domain: window.location.hostname
}),
})
.then((res) => res.json())
.then((sessionObject) => {
session.completeMerchantValidation(sessionObject);
})
.catch((err) => console.log("ERROR - MERCHANT VALIDATION: ", err));
}
function makeTransaction(formValues) {
return (e) => {
const applePaymentObject = e.payment;
const payload = {
token: applePaymentObject.token.paymentData,
};
// Pass the apple pay token to your server to make the wallet transaction API call
fetch(`YOUR_ENDPOINT`, {
method: "POST",
headers: REQUEST_HEADERS,
body: JSON.stringify(payload),
})
.then((res) => res.json())
.then((res) => {
// Check the response status and complete the payment session
if (res.status === 'AUTHORIZED') {
session.completePayment(0);
}
})
.catch((err) => console.log("ERROR: ", err));
};
}