VGS Tokenization Configuration
This section outlines how to configure VGSTextField
to create aliases (tokenize data) using the VGS Vault API.
Inbound Route setup
To begin using the Vault API with the VGS Collect SDK, you must first establish an Inbound connection. Navigate to the Dashboard and create a new Inbound Route. Configure the Upstream Host to forward requests to your preferred Vault API (v1 or v2).
Tokenization Configurations
To tokenize data from VGSTextField
, use one of the available tokenization configuration types:
.cardNumber
VGSCardNumberTokenizationConfiguration
.cvc
VGSCVCTokenizationConfiguration
.expDate
VGSExpDateTokenizationConfiguration
.cardHolderName
VGSCardHolderNameTokenizationConfiguration
.ssn
VGSSSNTokenizationConfiguration
.date
VGSDateTokenizationConfiguration
.none
VGSTokenizationConfiguration
These configurations extend VGSConfiguration and introduce additional tokenizationParameters
required for interacting with the Vault API.
/// `VGSTokenizationConfiguration` - Generic configuration for fields with arbitrary data. Required for Vault API usage.
public class VGSTokenizationConfiguration: VGSConfiguration {
/// `VGSTokenizationParameters` - Tokenization parameters configuration.
public var tokenizationParameters = VGSTokenizationParameters()
}
Some advanced features such as fieldName policies are not supported by the Vault API.
Tokenization Parameters
VGSTokenizationParametersProtocol
defines the parameters required to describe how field input should be tokenized:
/// Describes tokenization behavior for text field input.
public protocol VGSTokenizationParametersProtocol {
/// The format of the tokenized alias.
var format: String { get }
/// The storage type (PERSISTENT or VOLATILE).
var storage: String { get }
}
Tokenization format
The tokenization format defines how the alias) will appear in the response. Each field has a default format set by the SDK, but it can be overridden if needed.
.cardNumber
FPE_SIX_T_FOUR
.cvc
NUM_LENGTH_PRESERVING
.expDate
UUID
.cardHolderName
UUID
.ssn
UUID
.date
UUID
.none
UUID
Tokenization storage
VGS supports two storage types: PERSISTENT
and VOLATILE
.
Available values are defined in the VGSVaultStorageType
enum.
.cardNumber
PERSISTENT
.cvc
VOLATILE
.expDate
PERSISTENT
.cardHolderName
PERSISTENT
.ssn
PERSISTENT
.date
PERSISTENT
.none
PERSISTENT
While most fields allow you to customize storage type, this setting cannot be changed for
.cvc
and.cardNumber
.
Code example
/// Use VGSCVCTokenizationConfiguration with predefined tokenization parameters
let cvcConfiguration = VGSCVCTokenizationConfiguration(collector: vgsCollect, fieldName: "card_cvc")
cvcCardNum.configuration = cvcConfiguration
/// Use VGSCardNumberTokenizationConfiguration and override tokenization format
let cardConfiguration = VGSCardNumberTokenizationConfiguration(collector: vgsCollect, fieldName: "card_number")
cardConfiguration.tokenizationParameters.format = VGSVaultAliasFormat.UUID.rawValue
cardNumber.configuration = cardConfiguration
See also:
Last updated