Use Fast Checkout with Your iOS App

The SDK provides 2 main routes for invoking checkout:

  1. Checkout with a List of Products
  2. Checkout with a Cart ID

It is possible to use Fast Checkout either by passing the checkout() function an array of products, or by passing the checkout() function a cart ID.

Checkout with a List of Products

Products Checkout Function Breakdown

Copy
Copied to Clipboard
/// Present the Fast Checkout flow.
/// - presentedBy: The presenting view controller for the Fast Checkout flow.
/// - products: The list of products the user is ordering,
/// - couponCode: A discount code that the user might have entered.
/// - callback: A callback to listen for events during checkout.
public func checkout(
	presentedBy: UIViewController,
	products: [Product],
	couponCode: String,
	callback: @escaping (FastEvent) -> Void
)
NameTypeDescription
presentedByUIViewControllerContent view controller associated with the checkout flow.
products[Product] arrayThe Product array associated with the Fast Checkout. Refer to Product Object Breakdown for more details.
couponCodeString(Optional) Coupon, if any, included during checkout.
callbackClosureCallback to notify your app about important events (e.g. when an order is created, updated, or completed).

Product Object Breakdown

The Product object describes any product that can be ingested by the Fast backend and thus purchased via the SDK.

NameTypeDescription
ProductNSObjectThe product.
Product.platformProductIdStringThe product identifier.
Product.platformVariantIdString?A unique sub-identifier for this product.
Product.productOptions[ProductOption] arrayConfigurable properties of this Product (e.g. color, size, etc.). Refer to ProductOption Object Breakdown for more details.
Product.quantityIntThe number of this item that should be purchased.

ProductOption Object Breakdown

A ProductOption is a configuration that further describes the product being ordered (e.g. ProductOption(id: "color", value: "blue")).

NameTypeDescription
ProductOption.idStringThe identifier of the product option or configuration.
ProductOptionvalueStringThe value of the specified option.

Checkout with a Cart ID

Pass in a cartId that the Fast backend can break into a list of products and, if applicable, any discount code.

Cart Checkout Function Breakdown

Copy
Copied to Clipboard
/// Present the Fast Checkout flow.
/// - cartId: Unique identifier for a user's cart.
/// - callback: A callback to listen for events during checkout.
public func checkout(
	presentedBy: UIViewController,
	cartId: String,
	callback: @escaping (FastEvent) -> Void
)
NameTypeDescription
presentedByUIViewControllerContent view controller associated with the checkout flow.
cartIdStringThe ID of the cart associated with the Fast Checkout.
callbackClosureCallback to notify your app about important events (e.g. when an order is created, updated, or completed).

Initialize Theme

You also have the option of changing the theme used by the SDK. The theme of the SDK is by default set to the current device theme (auto), but can be overridden to use dark or light theme (e.g. if your app provides a setting to override the system's current theme).

setTheme()set light themeset dark theme
Copy
Copied to Clipboard
/// Override the theme setting for Fast Checkout
/// - theme: The theme value to set (auto, light, dark)
public func setTheme(theme: FastTheme) -> Void
Copy
Copied to Clipboard
// can be set to .light or .dark (default )
Fast.shared.setTheme(to: .light)
Copy
Copied to Clipboard
// can be set to .light or .dark (default )
Fast.shared.setTheme(to: .dark)