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
Apple Pay Essentials

Apple Pay Essentials: Harness the power of Apple Pay in your iOS apps and integrate it with global payment gateways

By Ernest Bruce
$32.99
Book Feb 2016 118 pages 1st Edition
eBook
$25.99 $17.99
Print
$32.99
Subscription
$15.99 Monthly
eBook
$25.99 $17.99
Print
$32.99
Subscription
$15.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Feb 24, 2016
Length 118 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785886386
Vendor :
Apple
Category :
Languages :
Table of content icon View table of contents Preview book icon Preview Book

Apple Pay Essentials

Chapter 1. Getting Started with Apple Pay

Apple Pay is a mobile payment system that lets iPhone users pay for goods and services using Touch ID. Instead of entering or confirming payment card information (credit or debit card) every time they make a purchase, users can authorize payment for items securely by touching the Home button. It is important to note that during an Apple Pay transaction, payment card information never leaves the user's phone; this information is stored securely in the device. Instead, a payment token stores all the information you need to process the payment all the way from authorization to settlement (that is, when the user's funds are transferred to your merchant bank account).

Using Apple Pay, you do not have to store your customers' payment card information on your servers. This helps reduce your customers' misgivings about paying for goods within your app; they trust that their payment card information is secure in their devices. You benefit by not having to deal with payment card information at all, at least not for Apple Pay-based transactions. (When a user's device does not support Apple Pay, or the user has not yet added payment cards to the device, you may have to process payment using regular means, which may involve capturing and storing payment card information.)

Although you are freed from storing payment card details on your systems, you still have to deal with processing the payments, either directly or through a payment gateway. In either case, you need to get an Apple Pay merchant identifier and certificate to decrypt the payment token that Apple Pay creates with a transaction's payment information. To use Apple Pay in your app, you need to enable the Apple Pay capability in your project, which requires the Apple Pay merchant identifier.

This chapter describes how online payments work, online payments being a web-centric version of the traditional Electronic Draft Capture (EDC) system used to process credit card transactions. You will also learn the basics of the Apple Pay payment workflow, starting with displaying the Apple Pay button when Apple Pay is available on the user's device, presenting the Apple Pay payment sheet, and processing the transaction on your servers.

This chapter will do the following:

  • Provide an overview of the online payment process

  • Introduce the Apple Pay payment workflow

  • Show you how to create an Apple Pay merchant identifier and certificate

  • Describe how to turn on the Apple Pay capability for an app in Xcode

An overview of the online payment process


Customers usually carry payment cards (debit or credit cards) in purses or wallets, which they use to pay for goods and services. When a cardholder pays a merchant with a payment card, the merchant usually uses a payment gateway to process the payment. A payment gateway is an e-commerce service that authorizes payment card-based transactions. The payment gateway performs several tasks to process the transaction, but it's its main task is the encryption of payment card information before submitting the transaction for authorization to a payment processor. A payment processor interacts with the bank that issued the customer's card (known as the issuing bank or issuer) that ultimately authorizes or declines the transaction. The payment processor may be implemented by the payment gateway, a third party, or the merchant. A merchant would implement a custom payment processor to, for example, integrate with a custom inventory and ordering system.

Merchants that do not manage inventory may deal only with a payment gateway. Payment gateways provide libraries or frameworks that apps can link to. When processing a payment, the app hands off a payment token to the library, which processes the payment and returns the result (authorized or declined) to the app. The gateway performs all the tasks necessary to authorize the transaction and transfer the payment amount from the card issuer to the merchant's acquiring bank. The acquiring bank (also known as the acquirer) is the bank that receives the cardholder's payments and credits them to the merchant's bank account (which is a special type of account used to receive payment from payment cards, also known as a merchant account).

Merchants that need to integrate with custom ordering and inventory management systems need a more hands-on approach to payment processing. This is the scenario discussed in this book.

First, let's talk about how online payment systems work. The payment process takes place in two phases:

  • Authorization

  • Settlement

In a successful authorization, an authorization hold is placed on the customer's card, reserving the funds that finance the transaction. Later, the merchant consumes or settles the transaction to transfer the funds from the customer's card into the merchant's account.

The following steps describe the authorization process:

  1. The customer presents a payment card to pay for a product or service.

  2. The merchant encrypts the card's information and sends an authorization request to the payment gateway.

  3. The payment gateway then forwards the authorization request to the payment processor.

  4. The payment processor forwards the authorization request to the appropriate payment card association (Visa, MasterCard, American Express, Discover, and so on).

  5. The card association forwards the authorization request to the issuing bank, which ultimately approves or declines the transaction. Some card associations, such as Discover and American Express, are also issuing banks.

  6. The issuing bank receives the authorization request from the payment processor and sends its response (authorized or declined) to the payment processor. The issuing bank then holds a transaction authorization or authorization hold that links the merchant, payment card, and amount approved (the funds are reserved but not debited from the cardholder's account).

  7. The payment processor forwards the issuing bank's response to the payment gateway.

  8. The payment gateway, in turn, forwards the response to the merchant, who relays the information to the cardholder.

Either immediately, or at the end of the day, the merchant starts the settlement process to receive the funds. This process is similar to the procedure used to request the payment authorization; however, instead of authorizing the transaction, the issuing bank moves the authorization hold to a debit and prepares the transaction for settlement with the acquiring bank:

  1. The merchant submits the approved authorization to its acquiring bank through the payment processor.

  2. The acquiring bank makes a settlement request to the issuing bank.

  3. The issuing bank makes a settlement payment to the acquiring bank.

  4. The acquiring bank deposits the approved amount into the merchant's bank account.

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.

Enabling Apple Pay in your app


For your app to be able to use Apple Pay, you must have an Apple merchant identifier and merchant certificate. Apple uses the certificate to encrypt payment information in the payment token. Your payment gateway (Stripe, Worldpay, and so on) uses the certificate to decrypt information in the payment token.

Creating your app's Apple Pay merchant identifier

You must have access to your team's Member Center portal and your payment gateway's certificate management facilities.

Create your merchant identifier in your team's Member Center page through the following steps:

  1. In Member Center, click on Certificates, Identifiers & Profiles.

  2. Under iOS Apps, click on Identifiers.

  3. Under Identifiers, click on Merchant IDs.

  4. Click on Continue (if this is your first merchant identifier) or on the plus sign (+) button in the upper-right corner of the page.

  5. Enter a description for the merchant identifier in the Description field, for example MerchantApp merchant identifier.

  6. Enter the identifier string in the ID field, for example merchant.com.company.merchantapp.

  7. Click on Continue and then click on Register.

  8. Click on Done.

Request an Apple Pay certificate from your payment gateway by performing the following:

  1. In your payment gateway's certificate management page, create an Apple Pay certificate.

  2. Download the Certificate Signing Request (CSR) file to your Mac.

Now, follow these steps to create your app merchant certificate in Member Center:

  1. In the Certificates, Identifiers & Profiles page, under iOS Apps, under Certificates, click on All.

  2. Then, select Apple Pay Certificate and click on Continue.

  3. Under Which Merchant ID would you like to use?, select the appropriate merchant identifier and click on Continue.

  4. Under Generate your certificate, click on Choose File.

  5. Choose the CSR file you obtained from your payment gateway.

  6. Next, click on Generate and then click on Download to download your app merchant certificate to your Mac.

Upload your app merchant certificate to your payment gateway via the following steps:

  1. In your payment gateway's certificate management page, upload the merchant certificate you downloaded from the Member Center portal.

  2. Confirm that your merchant certificate is listed in your payment gateway account.

Installing your app's Apple Pay merchant certificate on your Mac

Double-click on the merchant certificate you downloaded earlier from Member Center. Keychain Access will then open and install the certificate along with your other certificates.

Enabling Apple Pay in your app's Xcode project

To provide your app with access to Apple Pay, you need to turn on the Apple Pay capability in the Xcode project. Perform the following:

  1. First, open your project in Xcode.

  2. Select the target that builds the app to open the target editor.

  3. Then, click on Capabilities.

  4. Find the Apple Pay capability and toggle the corresponding switch to its on position.

  5. In the dialog that appears, select the appropriate development team, and click on Choose.

Summary


In this chapter, you learned about the online payment process followed by merchants to obtain card-based payments. The chapter introduced general online payment concepts to describe how an app uses Apple Pay to perform a similar function but more securely. Finally, you learned how to create the Apple Pay merchant identifier and merchant certificate to enable Apple Pay payment in your apps.

The next chapter focuses on the payment request workflow, where you present the Apple Pay button when Apple Pay is available on the device, create the payment request, and present the payment sheet based on that request.

Left arrow icon Right arrow icon

Key benefits

  • Be it adding an Apple Pay button to your app or calculating sales tax with Apple Pay- this book gives you all the information you need to build a fully-functional Apply Pay application
  • Paying within iOS Apps made easier and secure with this no nonsense and powerful guide
  • Escape tedious payment options by creating compelling product card screens that present the ?Pay button, which your customers can tap to quickly order your products

Description

Apple Pay, one of the most talked about offerings of the latest iOS 9 release, is a digital wallet and electronic payment system developed by Apple Inc. Paying in stores or within apps has never been easier or safer. Gone are the days of searching for your wallet, and the wasted moments finding the right card! Now you can use your credit cards and rewards cards with just a touch. It allows payment to merchants, using Near field Communication (NFC), and within iOS apps. Implementing Apple Pay within apps for payment is a bit tricky, but our book solves this problem for you. Whether you are a brand new iOS app developer or a seasoned expert, this book arms you with necessary skills to successfully implement Apple Pay in your online-payment workflow. Whether you are a brand new iOS app developer or a seasoned expert, this book arms you with the necessary skills to successfully implement Apple Pay. We start off by teaching you how to obtain the certificates necessary to encrypt customers’ payment information. We will use Xcode and Objective C for the interface and Node.js for server side code. You will then learn how to determine whether the customer can use Apple Pay, and how to create payment requests. You will come to grips with designing a payment-processor program to interact with the payment gateway. Finally, we take a look at a business-focused view of Apple Pay protocols and classes. By the end of this book, you will be able to build a fully functional Apple Pay-integrated iOS app

What you will learn

[*] Design a product card that includes the Apple Pay button [*] Implement the Apple Pay workflow in an efficient way [*] Use NSDecimalNumber objects to perform financial calculations accurately [*] Manage custom order information in the Apple Pay workflow and your custom order management system [*] Extract payment information from a payment token [*] Implement a secure, server-side payment-processor program [*] Find out everything you wanted to know about Apple Pay in iOS 9

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Feb 24, 2016
Length 118 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785886386
Vendor :
Apple
Category :
Languages :

Table of Contents

13 Chapters
Apple Pay Essentials Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewer Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
Getting Started with Apple Pay Chevron down icon Chevron up icon
Payment Request Workflow Chevron down icon Chevron up icon
Payment Authorization Workflow Chevron down icon Chevron up icon
Payment Processing Workflow Chevron down icon Chevron up icon
Designing an Order Management Server Chevron down icon Chevron up icon
Apple Pay API Summary Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela