Primer iOS SDK
Primer's Official Universal Checkout iOS SDK
💪 Features of the iOS SDK
📚 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;
- Select your project, and then navigate to Package Dependencies
- Click on the + button at the bottom-left of the Packages section
- Paste https://github.com/primer-io/primer-sdk-ios.git into the Search Bar
- Press Add Package
- Let Xcode download the package and set everything up
👩💻 Usage
📋 Prerequisites
🔑 Generate a client token by creating a client session in your backend.🎉 That's it!
🔍 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:
Example app:
Make sure you've got CocoaPods installed
- At the root of this repo, open your Terminal
cd Example
pod install