O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Apple Pay Essentials

Book Description

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

About This Book

  • 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

Who This Book Is For

This book is for anyone who wants to integrate Apple Pay in their applications. Basic familiarity with programming and the Xcode developer tools is expected.

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

In Detail

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

Style and approach

This is an easy-to-follow guide on integrating Apple Pay in your iOS Application. With step by step instructions along with excellent screen shots you will be able to learn everything that you wanted to know about Passbook and Apple Pay in iOS 8.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Apple Pay Essentials
    1. Table of Contents
    2. Apple Pay Essentials
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why subscribe?
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Getting Started with Apple Pay
      1. An overview of the online payment process
      2. The Apple Pay payment workflow
        1. Presenting the Apple Pay button
        2. Creating the payment request
        3. Presenting the payment sheet
        4. Responding to order changes and payment authorization
        5. Submitting the payment information to the payment gateway
      3. Enabling Apple Pay in your app
        1. Creating your app's Apple Pay merchant identifier
        2. Installing your app's Apple Pay merchant certificate on your Mac
        3. Enabling Apple Pay in your app's Xcode project
      4. Summary
    9. 2. Payment Request Workflow
      1. Getting information from an inventory service
        1. Getting inventory information
        2. Getting shipping information
      2. Displaying the product card
        1. Presenting product information
        2. Presenting the Apple Pay button
      3. Creating the payment request
        1. Specifying payment details
        2. Country and currency code
        3. Merchant identifier and capabilities
      4. Requiring shipping and billing information
        1. Requiring shipping or billing addresses
        2. Specifying shipping or billing addresses
        3. Specifying shipping methods
      5. Specifying summary items
      6. Specifying custom information tied to the order
      7. Summary
    10. 3. Payment Authorization Workflow
      1. Actors and operations in the authorization workflow
      2. Implementing a shared method to compute summary items
      3. Responding to user interactions with the payment sheet
        1. User changes shipping information
        2. User changes shipping method
        3. User authorizes payment request
      4. Summary
    11. 4. Payment Processing Workflow
      1. Actors and operations in the processing workflow
      2. The preprocess phase
        1. The merchant app receives the payment token
        2. The merchant app receives the charge token from the payment gateway
        3. The merchant app sends the order information to the order processing system
      3. The process phase
      4. The postprocess phase
        1. The merchant app receives the transaction status from the order processing web app
        2. The merchant app conveys the transaction status to the user
        3. The merchant app dismisses the payment sheet
      5. Summary
    12. 5. Designing an Order Management Server
      1. Configuring an order management server web app
      2. Defining order management data structures
      3. Providing inventory information to clients
      4. Processing orders from clients
      5. Implementing secure communication
      6. Summary
    13. 6. Apple Pay API Summary
      1. Main classes
        1. The PKPaymentButton class
          1. Creating the button
            1. +buttonWithType:style
        2. The PKPaymentRequest class
          1. Payment processing information
            1. countryCode (NSString*)
            2. currencyCode (NSString*)
            3. merchantCapabilities (PKMerchantCapability)
            4. merchantIdentifier (NSString*)
            5. supportedNetworks (NSArray<NSString*>*)
          2. Payment summary items
            1. paymentSummaryItems (NSArray<PKPaymentSummaryItem*>*)
          3. The required address fields
            1. requiredBillingAddressFields (PKAddressField), requiredShippingAddressFields (PKAddressField)
          4. Billing and shipping contacts
            1. billingContact (PKContact*), shippingContact (PKContact*)
          5. Shipping methods
            1. shippingMethods (NSArray<PKShippingMethod*>*)
          6. Shipping type
            1. shippingType (PKShippingType)
          7. Application data
            1. applicationData (NSData*)
        3. The PKPaymentSummaryItem class
          1. Creating a summary item
            1. +summaryItemWithLabel:amount:
            2. +summaryItemWithLabel:amount:type:
          2. Summary item components
            1. label (NSString*)
            2. amount (NSDecimalNumber*)
          3. Pending or final
            1. type (PKPaymentSummaryItemType)
        4. The PKPaymentMethod class
          1. Card tame
            1. displayName (NSString*)
          2. Card type
            1. type (PKPaymentMethodType)
          3. Payment network
            1. network (NSString*)
          4. Payment pass
            1. paymentPass (PKPaymentPass*)
        5. The PKShippingMethod class
          1. User-friendly description
            1. detail (NSString*)
          2. App-level identifier
            1. identifier (NSString*)
        6. The PKPaymentAuthorizationViewController class
          1. Determining Apple Pay support
            1. +canMakePayments
            2. +canMakePaymentsUsingNetworks:
            3. +canMakePaymentsUsingNetworks:capabilities:
          2. Initializing and presenting
            1. -initWithPaymentRequest:
            2. -initWithPaymentRequest:
          3. Payment sheet delegate
            1. delegate id <PKPaymentAuthorizationViewControllerDelegate>
        7. The PKPayment class
          1. Payment information
            1. token (PKPaymentToken*)
          2. Billing and shipping contacts
            1. billingContact (PKContact*)
            2. shippingContact (PKContact*)
            3. shippingMethod
        8. The PKPaymentToken class
          1. Encrypted payment information
            1. paymentData (NSData*)
          2. Payment method and transaction identifier
            1. paymentMethod (PKPaymentMethod*)
            2. transactionIdentifier (NSString*)
      2. Payment sheet user event protocol
        1. The PKPaymentAuthorizationViewControllerDelegate protocol
          1. The user chooses a payment card
            1. -paymentAuthorizationViewController:didSelectPaymentMethod: completion:
          2. The user selects a shipping address
            1. -paymentAuthorizationViewController:didSelectShippingContact: completion:
          3. The user selects a shipping method
            1. -paymentAuthorizationViewController:didSelectShippingMethod: completion:
          4. The user authorizes the payment request
            1. -paymentAuthorizationViewControllerWillAuthorizePayment:
            2. -paymentAuthorizationViewController:didAuthorizePayment: completion:
          5. The payment sheet is done
            1. -paymentAuthorizationViewControllerDidFinish:
      3. Auxiliary classes
        1. The PKContact class
        2. Contact address components
          1. emailAddress (NSString*)
          2. name (NSPersonNameComponents*)
          3. phoneNumber (CNPhoneNumber*)
          4. postalAddress (CNPostalAddress*)
        3. The NSPersonNameComponents class
          1. Person name components
            1. namePrefix (NSString*)
            2. givenName (NSString*)
            3. middleName (NSString*)
            4. familyName (NSString*)
            5. nameSuffix (NSString*)
            6. nickname (NSString)
            7. phoneticRepresentation (NSPersonNameComponents*)
        4. The CNPhoneNumber class
          1. Creating a phone number
            1. +phoneNumberWithStringValue:
          2. Phone number string
            1. stringValue (NSString*)
        5. The CNPostalAddress class
          1. Postal address components
            1. street (NSString*)
            2. city (NSString*)
            3. state (NSString*)
            4. postalCode (NSString*)
            5. country (NSString*)
            6. ISOCountryCode (NSString*)
      4. Summary
    14. Index