Book Image

Apple Pay Essentials

By : Ernest Bruce
Book Image

Apple Pay Essentials

By: Ernest Bruce

Overview of this book

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
Table of Contents (13 chapters)

The process phase

In the Process phase of the payment processing workflow, the order processing web app charges the user's card, updates the ordering and inventory data, and returns the transaction's status (that is, whether it is approved or declined) to the user app on the user's device as an HTTP response to the app's original HTTP request. This web app uses the payment gateway's server-side API to communicate with it.

In the example order processing web app (a Node.js web app), the HTTP request from the user app is handled by the middleware, as follows:

// server_app/red.js
// payment middleware'/payment', function(request, response, next)
   // 1. parse request
   var order_info_package= JSON.parse(request.body);
   // process charge token
   if (order_info_package.gateway == 'stripe')
      // 2. charge payment card
      var charge= stripe.charges.create
            amount      : order_info_package.amount,
            currency    : order_info_package...