Common interface for all vault SDK adapters.
Methods
on()
on(event, callback): void;
Registers an event listener for the specified event.
Parameters
Returns
void
Properties
destroy()
Destroys the SDK instance and removes all event listeners.
This is terminal; the instance cannot be used after this call.
Returns
void
getCardInfo()
getCardInfo: () => Promise<null | CardInfo>;
Gets card information such as BIN, detected brands, and last four digits.
Returns
Promise
<null
| CardInfo
>
Promise<CardInfo | null>
- Null if the form is not complete enough.
Example
const info = await hostedFields.getCardInfo();
if (info) {
console.log(info.bin);
console.log(info.detected_brands);
console.log(info.last_four_digit);
}
render()
Renders the fields in the targets specified in the config.
Returns
void
Throws
SecureFieldsErrors.FIELD_RENDER_FAILED If the target element for the field is not found.
Throws
SecureFieldsErrors.INSTANCE_DESTROYED If the instance has been destroyed.
See
SecureFieldsErrors
submit()
submit: (payload) => Promise<SubmitResult>;
Triggers validation and tokenization of the form.
Parameters
Parameter | Type | Description |
---|
payload | SubmitOptions | The payload containing expiry month, expiry year, cardholder name, and selected network. |
Returns
Promise
<SubmitResult
>
Throws
SecureFieldsErrors.TOKENIZATION_FAILED If the form is invalid or if there is an error during the process.
Throws
SecureFieldsErrors.INVALID_FORM If the form is not valid.
Example
const result = await hostedFields.submit({
expiryMonth: 12;
expiryYear: 25;
cardHolderName: 'Joe Dawn';
selectedNetwork: 'VISA';
saveToken: false;
});
See
SecureFieldsErrors
Events
success
Emitted when the form is successfully tokenized.
error
Emitted when there is an error during the tokenization process.