Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apple Pay Essentials

You're reading from  Apple Pay Essentials

Product type Book
Published in Feb 2016
Publisher
ISBN-13 9781785886386
Pages 118 pages
Edition 1st Edition
Languages
Author (1):
Ernest Bruce Ernest Bruce
Profile icon Ernest Bruce

The Apple Pay payment workflow


If you develop an app that is capable of interacting with a payment gateway to process payment cards, you or your company is a merchant, and the app is a merchant app.

This is an overview of the payment workflow:

  1. Present the Apple Pay button: Present this button only if the user can make Apple Pay payments.

  2. Create the payment request: This request contains essential payment information and details about the order.

  3. Present the payment sheet: This sheet presents order information that the user can modify, such as shipping information.

  4. Respond to changes by the user: As the user makes changes, update items such as shipping costs and discounts.

  5. Submit payment information to payment gateway: When the user authorizes the payment request, submit the payment and order information to the appropriate systems.

Presenting the Apple Pay button

When a user reaches a screen in your app that lets the user purchase something, the app should present the Apple Pay button (if the user can use Apple Pay on the device) so that the user can tap the button, verify the purchase details, and authorize the app through Touch ID to complete the order and charge the order amount to the appropriate payment card. Deciding whether the user can use Apple Pay involves two steps:

  • Determining whether the device supports Apple Pay

  • Determining whether the user has added payment cards that you support to the device

    Tip

    Your app must make both checks before displaying the Apple Pay button. If either check fails, the app must not present the Apple Pay button. Instead, it should offer a traditional payment method (such as obtaining a credit card number and a shipping address) through a Buy button.

Creating the payment request

If the user can use Apple Pay, your app prepares a payment request. A payment request is an object that describes the items to charge for, the card associations that you support, and billing and shipping information.

The main components of a payment request are payment summary items, which describe the payment request to the user. A payment summary item represents a component of the transaction, such as the subtotal, a discount, shipping cost, tax, and the grand total. Each item has a label that describes what each amount means. The last item is the most important because it identifies the payee and the debit amount that the user will see in the next payment card statement. Therefore, this item should have your company's name as its label.

In addition to the payment summary items, your app sets properties of the payment request that describe which card associations and online payment protocols you support. Your app must support at least the 3D Secure protocol. The EMV (Europay, MasterCard, and Visa) protocol is optional.

The payment request also lets you indicate that you want the user to specify particular order details, such as shipping or billing information. For example, you may require an e-mail or postal address.

If your ordering system requires additional information, such as the order number, you can include this information in the payment request as custom application data. Apple Pay includes a hash of this information in the payment token you receive when the user authorizes the payment. If your ordering system requires this information later, your app must be able to provide it separately.

Presenting the payment sheet

Once your app creates the payment request and the user taps the Apple Pay button, the app presents a payment sheet to the user. The payment sheet (formally known as the payment authorization view controller) presents the payment summary items in the payment request to the user for review. The user can change aspects of the order before authorizing payment. The user may also decide not to purchase the goods and cancel the transaction.

Responding to order changes and payment authorization

Your app implements a delegate of the payment sheet to respond to the user's actions by, for example, updating the order shipping cost and grand total when the user chooses a different shipping method.

Note

When the user authorizes the payment request with Touch ID, Apple Pay interacts with the device's secure element (the chip that securely stores payment card details on the device, details that not even Apple has access to) and Apple's servers to generate a one-time-use payment token. The payment information describes the payment transaction and contains all the information needed to charge the payment amount to the user's payment card (but this does not contain card numbers).

Apple encrypts the information in the token on its servers using your merchant certificate.

Submitting the payment information to the payment gateway

When the payment sheet tells its delegate that the user has authorized the payment request and sends the user the payment information, the delegate calls a synchronous method that forwards the payment information to your payment gateway. When the method returns, it provides the delegate with the result of the payment request. If the payment request is approved, the payment sheet displays a confirmation to the user that the transaction is approved and informs its delegate. The delegate then dismisses the payment sheet and displays a custom confirmation screen; such a screen may display the order number and a thank you message. If the payment request is not approved, the delegate must display an appropriate screen and ask the user for another form of payment.

You have been reading a chapter from
Apple Pay Essentials
Published in: Feb 2016 Publisher: ISBN-13: 9781785886386
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}