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.
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.
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'
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.
import UIKit
import VGSCheckoutSDK
class ViewController: UIViewController {
/// VGS Checkout object
var vgsCheckout: VGSCheckout?
}
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>"]
/// Init VGSCheckout with Configuration object.
vgsCheckout = VGSCheckout(configuration: checkoutConfiguration)
/// Present VGSCheckout Form
vgsCheckout?.present(from: self)
/// Set Checkout delegate
vgsCheckout?.delegate = self
Demo application with different Checkout Configurations here.
- SDK Documentation: https://www.verygoodsecurity.com/docs/payment-optimization/checkout/ios-sdk/
- API Documentation: https://verygoodsecurity.github.io/vgs-checkout-ios/
To follow VGSCheckoutSDK
updates and changes check the releases page.
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
- iOS 11+
- Swift 5
VGSCheckout iOS SDK is released under the MIT license. See LICENSE for details.