/
SDK Methods
SDK Methods
Accessing methods
Depending on how chose to integrate HPF, there are 3 ways you can access the sdk’s methods
from
window.Netvalve
Example: await window.Netvalve.tokenizeFields()
from the object returned when calling
window.Netvalve.initFields
during the JS SDK setup.
const sdk = window.Netvalve.initFields({ })
await sdk.tokenizeFields();
From the
<netvalve-tokenfields>
html web component
const sdk = document.querySelector('netvalve-tokenfields'); // GET INSTANCE
const token = await sdk.tokenizeFields();
tokenizeFields()
An asynchronous function for validating all fields and performing tokenization.
Arguments: None;
Returned Value: Promise
If validation + tokenization is successful, the promise resolves to a
string
tokenIf either fails, the promise resolves to
null
Example Usage
document.querySelector('#submit-button')?.addEventListener('click', async (e) => {
e.preventDefault();
const token = await window.Netvalve.tokenizeFields(); // PERFORM TOKENIZATION
if (token) document.querySelector('form').submit(); // TOKEN RECEIVED. SUBMITTING FORM
else console.error('Token submission failed, received null.');
});
Related: Form Submission
, multiple selections available,
Related content
SDK Integration Approaches
SDK Integration Approaches
More like this
HTML SDK Configuration Field Attributes
HTML SDK Configuration Field Attributes
More like this
Initialize Token Fields
Initialize Token Fields
More like this
Form Submission
Form Submission
More like this
Token Fields (HPF)
Token Fields (HPF)
More like this
Events
Events
More like this