inai Checkout iOS SDK

Adding inai Checkout SDK to your Xcode project

📘

Minimum Requirements

iOS 9, Swift 5.x

Drag and drop inai_ios_sdk.xcframework into the xcode project.

Checkout

To invoke checkout, an order is required.

Create an order

To create an order, use our Order API documented at https://docs.inai.io/reference/post_v1-orders. Use the order_id returned in the API response to invoke the save payment method flow in the inai checkout SDK.

SDK Initialization Configuration

Variables

Description

inai_sdk_client_username

The client username can be obtained from Settings > Credentials in the Dashboard

orderId

The orderId refers to the inai order created by the merchant backend.

To invoke the checkout flow in the SDK, copy the snippet below and update the configuration parameters of InaiConfig instance,

let config = InaiConfig(token: inai_sdk_client_username!,
                                  orderId : orderId, styles : nil)

Implement Protocol Stub

The inai Checkout SDK requires the calling ViewController to implement the following protocol stub as part of the InaiCheckoutDelegate protocol

func payment_finished(with result: Inai_PaymentResult) {
    switch result.status {
    case Inai_PaymentStatus.success:
        // Handle Payment Success
        break
    case Inai_PaymentStatus.failed :
        // Handle Payment Failed
        break
    case Inai_PaymentStatus.canceled:
        // Handle Payment Canceled
        break
    @unknown default:
        break;
    }
}

Initialize the SDK for Checkout

You can now initialize the SDK with the above delegated ViewController and present the inai checkout view

if let inaiCheckout = InaiCheckout(config: config) {
        inaiCheckout.presentCheckout(viewController: self, delegate: self)
} else {
        // Handle configuration errors here
}

Save Payment Method

Saving payment methods enables customers for a faster checkout experience. The customer’s payment method information is captured once and can be used for subsequent payments in the future.

To save a payment method, an order is required.

Create an order

To create an order, use our Order API documented at https://docs.inai.io/reference/post_v1-orders. Use the order_id returned in the API response to invoke the save payment method flow in the inai checkout SDK.

SDK Initialization Configuration

Variables

Description

inai_sdk_client_username

The client username can be obtained from Settings > Credentials in the Dashboard

orderId

The orderId refers to the inai order created by the merchant backend.

To invoke the save payment method flow in the SDK, copy the snippet below and update the configuration parameters of InaiConfig instance,

let config = InaiConfig(token: inai_sdk_client_username!, orderId : orderId)

Implement Protocol Stub

The inai Checkout SDK requires the calling ViewController to implement the following protocol stub as part of the InaiPaymentMethodDelegate protocol

func paymentMethodSaved(with result: Inai_PaymentMethodResult) {
    switch result.status {
    case Inai_PaymentMethodStatus.success:
        // Handle Save Payment Method Success
        break
    case Inai_PaymentMethodStatus.failed :
        // Handle Save Payment Method Failed
        break
    case .canceled:
        // Handle Save Payment Method Canceled
        break
    @unknown default:
        break;
    }
}

Initialize the SDK for Saving Payment Method

You can now initialize the SDK with the above delegated ViewController and present the inai add payment method view

if let inaiCheckout = InaiCheckout(config: config) {
        inaiCheckout.addPaymentMethod(type: "Card", viewController: self, delegate:self)
} else {
    // Handle configuration errors here
}

Pay with Saved Payment Method

In order to use a saved payment method to complete a payment, invoke the payment flow in the SDK. This flow will implicitly take care of 3DS flow and capturing any additional information as requested by the payment service provider to complete the payment.

To pay with a saved payment method, an order and a saved payment method is required.

Create an order

To create an order, use our Order API documented at https://docs.inai.io/reference/post_v1-orders. Use the order_id returned in the API response to invoke the save payment method flow in the inai Checkout SDK.

Saved Payment Methods

To retrieve the list of saved payment methods of a customer, use our List Payment Methods API documented at https://docs.inai.io/reference. Ideally the list of saved payment methods must be displayed as preferred payment methods for the customer to choose from. Upon the customer choosing a particular saved payment method to complete a payment, use the payment_method_id associated with the chosen saved payment method to invoke payments flow in the inai Checkout SDK.

SDK Initialization Configuration

Variables

Description

inai_sdk_client_username

The client username can be obtained from Settings > Credentials in the Dashboard

orderId

The orderId refers to the inai order created by the merchant backend.

To invoke the pay with saved payment method flow in the SDK, copy the snippet below and update the configuration parameters of InaiConfig instance,

let config = InaiConfig(token: inai_sdk_client_username!, orderId : orderId)

Implement Protocol Stub

The inai Checkout SDK requires the calling ViewController to implement the following protocol stub as part of the InaiCheckoutDelegate protocol

func payment_finished(with result: Inai_PaymentResult) {
    switch result.status {
    case Inai_PaymentStatus.success:
        // Handle Payment Success
        break
    case Inai_PaymentStatus.failed :
        // Handle Payment Failed
        break
    case Inai_PaymentStatus.canceled:
        // Handle Payment Canceled
        break
    @unknown default:
        break;
    }
}

Initialize the SDK for Paying with Saved Payment Method

You can now initialize the SDK with the above delegated ViewController and initiate a payment with a saved payment method

if let inaiCheckout = InaiCheckout(config: config) {
    inaiCheckout.presentPayWithPaymentMethod(paymentMethodId: paymentMethodID, viewController: self, delegate: self)
} else {
    // Handle configuration errors here
}

🚧

Get latest iOS SDK

Contact customer support for the latest version of the SDK

Customizing the checkout widget

The widget may be styled and customized in various ways. These steps are documented at Customizing the checkout widget.