Skip to content

primer-io/primer-sdk-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Primer iOS SDK

Primer's Official Universal Checkout iOS SDK




💪 Features of the iOS SDK

💳   Create great payment experiences with our highly customizable Universal Checkout

🧩   Connect and configure any new payment method without a single line of code

✅   Dynamically handle 3DS 2.0 across processors and be SCA ready

♻️   Store payment methods for recurring and repeat payments

🔒   Always PCI compliant without redirecting customers

📚 Documentation

Consider looking at the following resources:

💡 Support

For any support or integration related queries, feel free to Contact Us.

🚀 Quick start

Take a look at our Quick Start Guide for accepting your first payment with Universal Checkout.


🧱 Installation

With CocoaPods

The iOS SDK is available via Cocoapods. Add the PrimerSDK to your Podfile:

target 'MyApp' do
  # Other pods...

  # Add this to your Podfile
  pod 'PrimerSDK' # Add this line
end

Then, at the root of this repo, open your terminal and run

  • bundle install
  • cd Debug\ App
  • bundle exec pod install

For specific versions of the SDK, please refer to the changelog.

With Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into Xcode. In order to add PrimerSDK with Swift Package Manager;

  1. Select your project, and then navigate to Package Dependencies
  2. Click on the + button at the bottom-left of the Packages section
  3. Paste https://github.com/primer-io/primer-sdk-ios.git into the Search Bar
  4. Press Add Package
  5. Let Xcode download the package and set everything up


👩‍💻 Usage

📋 Prerequisites

🔍  Initializing the SDK

Import the Primer SDK and set its delegate as shown in the following example:

import PrimerSDK

class MyViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Initialize the SDK with the default settings.
        Primer.shared.configure(delegate: self)
    }
}

extension MyViewController: PrimerDelegate {

    func primerDidCompleteCheckoutWithData(_ data: CheckoutData) {
        // Primer checkout completed with data
        // do something...
    }
}

Note: Check the SDK API Reference for more options to customize your SDK.

🔍  Rendering the checkout

Now you can use the client token that you generated on your backend. Call the showUniversalCheckout(clientToken) function (as shown below) to present Universal Checkout.

class MyViewController: UIViewController {
    func startUniversalCheckout() {
        Primer.shared.showUniversalCheckout(clientToken: self.clientToken)
    }
}

You should now be able to see Universal Checkout! The user can now interact with Universal Checkout, and the SDK will create the payment. The payment’s data will be returned on primerDidCompleteCheckoutWithData(:).

Note: There are more options which can be passed to Universal Checkout. Please refer to the section below for more information.

Contributing guidelines:

Contributing doc

Using the Debug App

The Debug App provides you with tools to test your Primer configuration and interact with different payment methods and Universal Checkout features