Apple Pay on the Web Payment Authorization

B2C Commerce provides Apple Pay with information about the customer and basket: line items, shipping methods, and stored contact information. When the shopper authorizes payment, Apple Pay provides B2C Commerce with a token containing the encrypted payment information.

B2C Commerce creates an order from the basket, and provides the encrypted payment information to the storefront payment service provider in an authorization request. B2C Commerce updates the order with the transaction information in the authorization response.

B2C Commerce provides Apple Pay with the outcome of the authorization, and if successful, shows the storefront order confirmation page.

To authorize Apple Pay payment:

  1. The shopper clicks or taps the Buy with Apple Pay button.
  2. B2C Commerce creates the payment request.
  3. B2C Commerce creates a merchant session, requested from the B2C Commerce Web Server to Apple.
  4. The session is returned to B2C Commerce and is forwarded with the payment request.
  5. The app shows the Apple Pay sheet.
  6. The shopper uses their Touch ID or passcode.
  7. Payment data is generated.

The Apple Pay payment processing authorization process looks as follows:

Merchant Validation

The following is an example of merchant validation:

session.onvalidatemerchant = function (event) {
   var promise = performValidation(event.validationURL0;

   promise,then(function (merchantSession) {
      session.completeMerchantValidation(merchantSession);
});
}
  1. A valid merchant DOM event is dispatched to the session.
  2. The event has a validationURL property.
  3. Validation is performed.
  4. Call completeMerchantValidation.

Authorize Payment

The following is an example of authorizing payment:

session.onpaymentauthorized = function (event) {
   var promise = sendPaymentToken(event.payment.token);

   promise.then(function (success) {
      var status;
      if (success)
         status - ApplePaySession.STATUS_SUCCESS;
      else
         status = ApplePaySession,STATUS_FAILURE;

      session.completePayment(status);
      showConfirmation();
   });
}