These are the minimum required steps to use the PointCheckout SDK in your IOS app.
- Add PointCheckoutSdk pod to your podfile:
pod 'PointCheckoutSdk', :git => 'git@github.com:pointcheckout/merchant-ios-sdk.git', :tag=> v${version}replace ${version} with the latest version of the SDK, you can check all available versions here, example:
pod 'PointCheckoutSdk', :git => 'git@github.com:pointcheckout/merchant-ios-sdk.git', :tag=> v1.4 - Execute
pod installinside the project directory. - Re-build the project.
The bellow diagram shows how the payment process works:
You can import the framework using import PointCheckoutSdk
Send new checkout request to PointCheckout's API (check the documentation for more details).
Create an object of PointCheckoutClient:
var pcClient = PointCheckoutClient(environment)environment: specifies the environment of the app, use Environment.TEST for testing purposes.
Keep a reference of the created client to reuse the same instance
To submit a payment call the static pay function of the PointCheckoutClient:
pcClient.pay(controller: viewController, checkoutKey: strCheckoutKey, delegate: callback)| Parameter | Description |
|---|---|
| controller | A UIViewController calling the pay function |
| checkoutKey | This key is included in the checkout response from PointCheckout API |
| delegate | Delegate that will be called on payment update or cancellation |
Calling the pay function will open a modal and the user will be able to login and complete the payment.
PointCheckoutPaymentDelegate has two callbacks, onUpdate and onDismiss.
import UIKit
import PointCheckoutSdk
class ViewController: UIViewController, PointCheckoutPaymentDelegate{
override func viewDidLoad() {
super.viewDidLoad()
}
func onUpdate(){
print("UPDATE CALLBACK")
}
func onDismiss(){
print("USER CLOSED THE MODAL")
}
}onUpdate will be called whenever the checkout status is updated (paid, cancelled, failed .etc). When this callback is invoked you should call PointCheckout API to fetch the new status of the checkout.
onDismiss will only be called if the user closes the modal by clicking on close button.
You can use our Demo app as an example of how to integrate our SDK on your application. you can access it from here. You can import the example app to Xcode and see how the SDK can be used.