Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

VGS Checkout - is a universal checkout and user experience. Single, customized, consistent experience to your customers across devices and browsers that you control

License

Notifications You must be signed in to change notification settings

verygoodsecurity/vgs-checkout-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircleCI UT license swift

VGS Checkout iOS SDK

VGS provides you with a Universal Checkout and User Experience which is fully integrated with our payment optimization solution. We offer a single, customized, consistent experience to your customers across devices and browsers that you control. Provide a unified experience with all the features you want and no compromises to ensure your customers have the best experience with no distractions.

VGS Checkout iOS SDK Initial State VGS Checkout iOS SDK Edit State

Table of contents

Before you start

You should have your organization registered at VGS Dashboard. Sandbox vault will be pre-created for you. You should use your <vaultId> to start collecting data. Follow integration guide below.

Integration

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate VGSCheckoutSDK into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'VGSCheckoutSDK'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Xcode with Swift tools version of 5.3 is required for VGSCheckoutSDK. Earlier Xcode versions don't support Swift packages with resources. To check your current Swift tools version run in your terminal:

xcrun swift -version

NOTE: In some cases you can have multiple Swift tools versions installed.

Follow the official Apple SPM guide instructions for more details.
To use Swift Package Manager, in Xcode add the https://github.com/verygoodsecurity/vgs-checkout-ios.git dependency.

Usage

Import VGSCheckoutSDK into your project

import UIKit
import VGSCheckoutSDK

class ViewController: UIViewController {

  /// VGS Checkout object
  var vgsCheckout: VGSCheckout?
  
}

Setup Checkout Configuration

Depends on your needs, you can setup Checkout Configuration that will work with Payment Orchestration App or your custom API. Read more about VGSCheckoutAddCardConfiguration and VGSCheckoutCustomConfiguration.

You should use your vaultId to initialize configuration instance, it can be found in your organisation dashboard.

VGSCheckoutAddCardConfiguration setup

NOTE: Your backend should be responsible for retrieving accessToken which will allow you to create financial instruments with Payment Orchestration solution.

// Create  VGSCheckoutAddCardConfiguration with access token in your view controller.
VGSCheckoutAddCardConfiguration.createConfiguration(accessToken: "<ACCESS_TOKEN>", tenantId: "<TENANT_ID>", environment: "sandbox") {[weak self] configuration in
    guard let strongSelf = self else {return}
    /// Show billing address section.
    configuration.billingAddressVisibility = .visible
    
    /// Set valid countries. 
    configuration.billingAddressCountryFieldOptions.validCountries = ["CA", "US", "AU"] 
} failure: {[weak self] error in
    print(error.localizedDescription)
    print("ERROR! Cannot create VGSCheckoutAddCardConfiguration!")
}

VGSCheckoutCustomConfiguration setup

/// Create VGSCheckoutCustomConfiguration instance with vaultID and environment
var checkoutConfiguration = VGSCheckoutCustomConfiguration(vaultID: "<VAULT_ID>",
                                                       environment: "<ENVIRONMENT>")

/// Set field names
checkoutConfiguration.cardNumberFieldOptions.fieldName = "card_number"
checkoutConfiguration.billingAddressCountryFieldOptions.fieldName = "billing_address.country"
//... 

/// Show billing address section
checkoutConfiguration.billingAddressVisibility = .visible

/// Set request path
checkoutConfiguration.routeConfiguration.path = "/post"

/// Add extra data to request
checkoutConfiguration.routeConfiguration.requestOptions.extraData = ["<Custom Key>": "<Custom Value>"]

/// Set custom request headers
checkoutConfiguration.routeConfiguration.requestOptions.customHeaders = ["<Header Key>": "<Header Value>"]

Present VGSCheckout Form with Configuration object

/// Init VGSCheckout with Configuration object.
vgsCheckout = VGSCheckout(configuration: checkoutConfiguration)

/// Present VGSCheckout Form
vgsCheckout?.present(from: self)

/// Set Checkout delegate
vgsCheckout?.delegate = self

Demo Application

Demo application with different Checkout Configurations here.

Documentation

Releases

To follow VGSCheckoutSDK updates and changes check the releases page.

Metrics

VGSCheckoutSDK tracks a few key metrics to understand SDK features usage, which helps us know what areas need improvement. No personal information is tracked. You can easily opt-out of metrics collection in VGSCheckoutAnalyticsClient:

VGSCheckoutAnalyticsClient.shared.shouldCollectAnalytics = false

Dependencies

  • iOS 11+
  • Swift 5

License

VGSCheckout iOS SDK is released under the MIT license. See LICENSE for details.

About

VGS Checkout - is a universal checkout and user experience. Single, customized, consistent experience to your customers across devices and browsers that you control

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages