Apple Pay was announced on WWDC 2014 by Tim Cook. It is a mobile payment service by Apple. It lets you buy goods or services by a single touch (with Touch ID). And it is amazing! But you can use Apple Pay only if you're a lucky owner of iPhone 6 or iPhone 6 Plus as only these devices have the Secure Element (SE) so far. It is a chip that stores your payment card credentials, isolating from the main processor where your app runs.
So, you have NFS, Touch ID and your payment credentials in your iPhone, and that's all you need for making some payments at Macy's and Bloomingdale's, drugstores Walgreens and Duane Reade, Subway and McDonald's, and many others. Apple Pay works with Visa payWave, MasterCard PayPass, and American Express ExpressPay terminals. It is cool but for developers, the integration of Apple Pay with our own apps is the most interesting thing about it. So we can use Apple Pay in our apps too.
It is not an In-App Purchase and not connected with it at all. Pass Kit Framework provides API for Apple Pay, and StoreKit provides API for In-App Purchase. How does it work? A user chooses credit card (if there are more than one) by tapping the Apple Pay button and confirms shipping information on the Payment Sheet. Then they just pay by holding a finger on the Touch ID sensor of the phone.
By the way, Apple Pay button and Payment Sheet are the UI elements that we use in mobile app development. Apple Pay has very strict Guidelines about UI. Payment Sheet is almost not customizable and Apple gives us ready-to-use Apple Pay button resources.
Under the hood, the process goes in the following way: PassKit checks if a user can make a payment with the help of a device. If it's ok an app shows the Apple Pay button. After that the user confirms the order and uses the Touch ID to make the payment, Secure Element encrypts user's payment credentials with the user's order information and sends it to the Apple Pay Service. Apple service decrypts it and encrypts it in your Payment Provider's suitable format. Payment Provider is a server which connects to a bank merchant system and makes your payments. You can use your own server but Apple gives a list of recommended third-party payment platforms. In the end, the Payment Provider sends Success or Error message to the user.
In order to be able to make a payment, your app needs a special Apple Pay entitlement that you can enable in the Member Center and Xcode. Also, you need to register a merchant identifier and set up cryptographic keys in the Member Center which are used to send payment data to apply Pay service and to your Payment Provider in a safe way.
You may use step-by-step instructions on www.developer.apple.com. The payment request is represented by PKPaymentRequest class. PKPaymentRequest includes information about payment processing capabilities, the payment amount, and shipping information. It consists of three blocks of properties:
- Working with Payment properties
Working with Billing and Shipping Addresses properties
requiredBillingAddressFields: PKAddressFieldEmail | ...
requiredShippingAddressFields: PKAddressFieldPostalAddress | ...
Adding Application Data properties:
The settings look pretty straightforward. Then let's consider on PKPaymentAuthorizationViewController class. It allows a user to select billing and shipping information that is needed by a payment request, and it lets the user to authorize the payment to be made. This is a Payment Sheet that we can initialize with the payment request.
[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request
PKPaymentAuthorizationViewController decides if the user can make a payment or not, by method (BOOL) canMakePayments. And we need to implement some delegate methods from PKPaymentAuthorizationViewControllerDelegate in view controller where Payment Sheet will be presented.
didSelectShippingAddress – triggered when the user chooses his shipping address
didSelectShippingMethod – triggered when the user chooses his shipping method
didAuthorizePayment – triggered when a user authorizes the payment with Touch ID PaymentAuthorizationViewControllerDidFinish – triggered when the payment is completed or if there is some error. We can't say that there is a lot of code here and it looks pretty simple for developers to support Apple payment system in their apps. But probably setting up and configuring Payment Provide might take some additional time.
More details about us.
If you have any questions or would like to contact us about the possible request on a design or mobile-friendly websites/mobile apps development please use the Contact form.