The VGSCollect class is the main component of the VGS Collect SDK. It provides methods for registering fields, submitting data, and tokenizing data.
Creating a VGSCollect
/// Constructor.////// - Parameters:/// - id: your organization Vault id./// - environment: your organization vault environment with data region.(e.g. "live", "live-eu1", "sandbox").`VGSCollect(id: string, environment: string = 'sandbox')`
You can have multiple VGSCollect instances; they will work independently with the fields you configure for each specific instance.
- All VGSCollect instances can be configured differently.\
The VGSCollect instance grabs the data from the VGSTextInputs during the submit(_:) request.
Route Id
If you have multiple Routes in your organisation Vault, you can set required routeId for the VGSCollect instance. VGSCollect will send data to this specific Route in your Vault.
/// - `routeId` (string): The vault route Id to set./// - Throws an error if the route Id is not a string.setRouteId(routeId: string): void
CNAME
When integrated with VGS, by default, the traffic is passed via the VGS proxy, which uses the tntxxxxx.sandbox.verygoodproxy.com format, where the tntxxxxx is your Vault identifier. The Collect SDK allows you to use your custom hostname and make requests to a non-VGS domain name.
Before adding a new Hostname, you should create a CNAME record for your existing domain in your DNS provider’s account that points to <VAULT_ID>.<ENVIRONMENT>.verygoodproxy.com.
Then, in your Application, set the Custom Hostname in the VGSCollect instance:
• When the hostname is not valid or not registered in the VGS system, it will be ignored by the SDK and all traffic will be passed through the VGS proxy directly.
• Only https scheme is supported.\
Custom Headers
Set custom headers for the VGSCollect instance.
Code example
Full example of how to setup a card form with VGSCollect:
/// - `cname` (string): The CNAME to set.
/// - Returns a Promise that resolves when the CNAME validation is complete.
setCname(cname: string): Promise<void>