Skip to content

khanhuitse05/primer-sdk-ios

 
 

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 with Cocoapods. Just add the PrimerSDK pod and run pod install.

target 'MyApp' do
  # Other pods...

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

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

Example app:

Make sure you've got CocoaPods installed

  • At the root of this repo, open your Terminal
    • cd Example
    • pod install

About

iOS SDK for Primer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Swift 99.5%
  • Other 0.5%