How to Set Up Apple Pay Using Stripe For Your Shopping App

0
Shares
How to Set Up Apple Pay Using Stripe For Your Shopping App
3.3 (66.67%) 3 votes

how to set up apple pay

Apple took a big step into the world of mobile payments with the introduction of the iPhone 6 and Apple Pay. There are two ways you can use Apple Pay to purchase items: at the point of sale using Near Field Communication (NFC), or within an iOS app.

In our last article, we talked about how integrating mobile payment gateways can benefit for your shopping app and how Stripe is used by most popular startup apps like Uber, Instacart, Grab, Postmates, and more. However, we somehow missed to talk about how to set up Apple Pay using Stripe in your iOS app.

In this article, we’re going to fix this. Get your Xcode installed and running, and let’s learn how to set up Apple Pay using Stripe!

What is Apple Pay?

Apple Pay enables people to easily and securely pay using their iPhone, iPad, and Apple Watch. Apple Pay is available within native iOS applications, and on the web in Safari starting with iOS 10 or macOS Sierra.

How Does Apple Pay Work?

Apple Pay is quite similar to Paypal because in that you can integrate it in your app to allows users to pay for their purchased goods and/or services online. But, what makes Apple Pay different is that it uses NFC technology that lets users pay for products in physical stores equipped with NFC readers.

For you reference, here is the list of stores that accept Apple Pay.

Now, the Apple’s payment system is compatible with all existing readers like American Express and ExpressPay, Visa PayWave, but unlike Samsung pay, it does not work at standard payment terminals with magnetic stripe readers.

To pay using Apple Pay, first you’ll need to add your credit cards through Wallet app. Though, you don’t need to write the complete credit card number or expiry date as you can use your iPhone’s camera to read this information automatically.

Now, to make a transaction, all you need to do is select Apple Pay from the payment options list, choose your credit card, and hold your fingerprint on Touch ID to authorize the transaction.

How Does Apple Pay Store My Credit Card Details?

Simple answer is: It Doesn’t!

Instead, it assigns a unique Device Account Number for each device, and saves this number in the Secure Element Chip on the device in an encrypted format.

So, when it is processing any transaction, it doesn’t transmit the data on a bank card to seller. Here, it uses its dynamic safety code. By doing this, it ensures that nobody can reveal your credit card information using Apple device.

Also, since Apple Pay stores a secure transaction on device, you won’t need to have data connection for Apple Pay. What this means is, you can pay for products without your iPhone if you own an Apple Watch.

In fact, you might have also noticed that Apple Pay system is spreading quite fast, so make sure you can grab the users paying through Apple Pay, we’ll see how to set up Apple Pay using Stripe in your iOS app.

When Should I Use Apple Pay?

Many people keep getting confused as to when we should be using In App purchases and when to use Apple pay. The key difference is that any thing digital which you sell inside the app needs to be using In App purchases. If you are selling any physical products like tickets, uber, event tickets etc can use Apple pay.

Quick overview of how it works

  • You create a Merchant ID and matching certificate in Developer Portal.
  • Your ID and certificate are used to encrypt the payment data.
  • Display Payment sheet to user.
  • User uses Touch ID to authorize transaction.
  • Your app receives the payment token.
  • This token is encrypted using your Merchant ID and certificate so only your application can decrypt it.
  • Send token for processing using one of payment platforms like Stripe.

How to Set Up Apple Pay Using Stripe

Login/Signup Stripe Account

First, go to https://dashboard.stripe.com/login and login to your account. If you don’t have a Stripe account then click on Signup.

screen-shot-2017-04-05-at-4-31-40-pm

Create Private key for the merchant certificate

After login into your account, go to Payments, then click on Apple Pay and add new application.

screen-shot-2017-04-05-at-4-34-50-pm

This will download the Stripe.certSigningRequest file and show a popup window.

screen-shot-2017-04-05-at-4-43-15-pm

Create AppID on Apple Developer Portal

Go to https://developer.apple.com/account, login/signup if required.

Go to Certificates, IDs & Profiles, then select AppIDs under identifier section.

Select (+) to add new App ID.

screen-shot-2017-04-05-at-4-57-44-pm

Enter App ID Description : StripeApplePay

Enter Bundle ID : com.example.StripeApplePay

Check Apple Pay option under App Services.

screen-shot-2017-04-05-at-5-01-16-pm

Now click on continue.

It will show like the below image. Now click on register and done.

screen-shot-2017-04-05-at-5-02-17-pm

Create MerchantID on Apple Developer Portal

Go to https://developer.apple.com/account/ios/identifier/merchant/landing, login/signup if required.

Select Merchant IDs under Identifiers section.

Select (+) to add new Merchant ID.

screen-shot-2017-04-05-at-5-05-27-pm

Now, enter Description : StripeApplePay

Enter Merchant ID : merchant.com.example.StripeApplePay

Continue > Register > Done.

screen-shot-2017-04-05-at-5-06-38-pm

Here, the merchant ID is created.

Upload Downloaded stripe.certSigningRequrest File to Merchant ID

Select newly created merchant ID > Edit.

screen-shot-2017-04-05-at-5-09-04-pm

Select Create Certificate Under the  Processing Certificate.

screen-shot-2017-04-05-at-5-11-28-pm

Select “No” for the Will payments associated with this Merchant ID be processed exclusively in China?

You will find step to create certSigningRequest file, skip that already downloaded stripe.certSigningRequest

screen-shot-2017-04-05-at-5-15-21-pm

Choose downloaded stripe.certSigningRequest file.

screen-shot-2017-04-05-at-5-17-18-pm

Download (Download Merchant certificate apple_pay.cer ) > Done

Your strip private certificate successfully bind with your application merchant ID.

Upload Downloaded Merchant Certificated to stripe.com

Go to the screen where we left on https://dashboard.stripe.com/account/apple_pay

Select downloaded Merchant certificate apple_pay (3).cer and click continue.

screen-shot-2017-04-05-at-5-27-16-pm

You will get the merchant.com.example.StripeApplePay under the iOS certificates section.

screen-shot-2017-04-05-at-5-31-51-pm

Here, you have successfully bind the stripe and apple pay certificates.

Get Your Secret|Publisher Keys

Select API option as shown in the image.

Copy these keys, we will need these keys in the application code.

screen-shot-2017-04-05-at-5-36-42-pm

Create a new XCode Project

Open Xcode, click on file then new and select create new project.

Select Single View Application and click on next.

screen-shot-2017-04-05-at-5-42-25-pm

In the next tab, write your project name and details.

screen-shot-2017-04-05-at-5-43-28-pm

Integreat Stripe pod

Open terminal and write – cd path/to/project/StripApplePay

In your pod file, add the below pod.

pod 'Stripe'

screen-shot-2017-04-05-at-6-02-36-pm

Save pod file and close it.

In terminal > $ pod install

This will generate the StripeApplePay.xcworkspace

Open StripeApplePay.xcworkspace

Enable Apple Pay Capabilities

Select StripeApplePay project from navigation bar.

Go to Capabilities.

Enable Apple Pay.

Our merchant ID will be automatically loaded i.e. merchant.com.example.StripeApplePay

Select the merchant ID.

screen-shot-2017-04-06-at-12-07-32-pm

Configure Project for Stripe Gateway

Goto AppDelegate.swift

Import Strip

In applicationDidFinishLaunchingWithOptions: add below line as first line

STPPaymentConfiguration.shared().publishableKey = "pk_test_WkjizjxN2MdJ3Mvsjbwpd0E7q"

This will configure app with your stripe+applePay certificate.

STPPaymentConfiguration.shared().appleMerchantIdentifier = "merchant.com.example.StripeApplePay"

This will configure merchant ID we have created on apple developer portal.

UI + Code

Goto Main.storyboard

In ViewController scene drag/drop one button.

Set button title to “Buy With Apple Pay” or design as per the ApplePayGuidelines
Add its action method named “btnApplePayDidTap:”

screen-shot-2017-04-06-at-12-13-43-pm

Code

Add code for the method “btnApplePayDidTap:” as show in the image.

Implement “PKPaymentAuthorizationViewControllerDelegate” by creating extension of view controller.

Add delegate code as shown in the image.

screen-shot-2017-04-06-at-12-25-47-pm

Now run the app.

screen-shot-2017-04-06-at-12-21-45-pm

As you know Apple Pay is one of the best features of iOS 8 and how it provided multiple benefits, in fact Entrepreneurs and app owners also implement this feature in their mobile apps. Though, if you’re building a startup app from scratch and want to implement Apple Pay using Stripe, you can either contact expert developer or hire iPhone app development company to help you with that.

 
0
Shares
 

Have an iOS App Idea in Mind? Let's Discuss!