Digital Wallet API

The Apple Pay API provides you with the ability to implement Apple Pay on the Web

Endpoints

Sandbox
POST https://api.merchantwarrior.com/applepay/ Copy

Production
POST https://base.merchantwarrior.com/applepay/ Copy

Introduction

The Apple Pay API provides you with the ability to implement Apple Pay on the Web.

To begin with, you will need to obtain a Merchant UUID, API Key and API passphrase. These details will be issued to you when you create your MW account.

You can download sample material that may assist you with your implementation here.

Prerequisites

• All pages that will display the Apple Pay button must be deployed over HTTPS.
• Comply with Apple Pay Identity Guidelines and Apple Pay on the Web Human Interface Guidelines to ensure you're displaying Apple Pay properly.
• Make sure your customer's device is a compatible iPhone, iPad, Apple Watch or iMac.
• Register all domains that will display an Apple Pay button. See Step one below.

Steps

1. Verify your domain. You'll need to register all your domains that will display the Apple Pay button, including both top-level domains (e.g. example.com) and sub-domains(e.g. store.example.com).
1.1 Host the domain verification file on your server. You can download the sandbox verification file here. For production, please download it here instead.
1.2 Host the file at /.well-known/apple-developer-merchantid-domain-association on your domain(s) that will display the Apple Pay button. Apple will perform the verification automatically. For example, if your domain is https://example.com.au, host the file at https://example.com.au/.well-known/apple-developer-merchantid-domain-association. Make sure the file is publicly accessible or exclusively accessible by Apple Servers listed in Whitelist Apple IP Addresses for Domain Verification.

2. Check Apple Pay availability. Before displaying an Apple Pay button or creating an Apple Pay session, you must ensure that the Apple Pay JS API is available and enabled on the current device. You can find more details here.

3. Display the Apple Pay button on your website. Make sure you comply with the prerequisites listed above. You can use MW's applepay.css to assist with your display.

4. Create an ApplePaySession. You can use the following getMerchantSession API to generate a merchant session. This API must be invoked via the backend.

5. Set up the relevant callbacks. Apple's documentation provides a list of events for which you may set up event handlers. The most important ones are onvalidatemerchant and onpaymentauthorized. You can set up additional event handlers if you wish.

6. Decrypt a payment token. Once a customer authorises a transaction, you will receive a payment token from the Apple Pay server in the onpaymentauthorized event handler. You can invoke the following decryptApplePayToken API to decrypt it. We will then return a MW token to you, which you can use as part of processCard to complete a transaction.

getMerchantSession

The getMerchantSession method is used to create an Apple Pay merchant session

Required Parameters

Parameter Description
method

This field is case sensitive.
Example: getMerchantSession

merchantUUID

The value of this parameter is provided to you by Merchant Warrior.
Example: 123456789abcd

apiKey

The value of this parameter is provided to you by Merchant Warrior.
Example: 1a3b5c

validationURL

The URL that is returned by Apple Pay server.

domainName

The domain name where the Apple Pay button is displayed.
Example: www.example.com

displayName

A string that represents your store and will be displayed in the payment sheet.
Valid length: Up to 64 characters.

decryptApplePayToken

The decryptApplePayToken method is used to decrypt a payment token received from the Apple Pay Server

Required Parameters

Parameter Description
method

This field is case sensitive.
Example: decryptApplePayToken

merchantUUID

The value of this parameter is provided to you by Merchant Warrior.
Example: 123456789abcd

apiKey

The value of this parameter is provided to you by Merchant Warrior.
Example: 1a3b5c

applePayToken

The payment token that is returned by Apple Pay server.