Skip to content

pointcheckout/ios-sdk

Repository files navigation

PointCheckout Merchant SDK

These are the minimum required steps to use the PointCheckout SDK in your IOS app.

Getting started

  • 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 install inside the project directory.
  • Re-build the project.

Using the SDK

The bellow diagram shows how the payment process works:

Import

You can import the framework using import PointCheckoutSdk

Checkout request

Send new checkout request to PointCheckout's API (check the documentation for more details).

Create PointCheckoutClient

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

Payment submit

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.

Payment listener

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.

Demo app

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.