Submit a Form

When end-user submits the form, you will have to call the SDK’s submit() function.

async function onFormSubmit(e: Event) {
    e.preventDefault();
    await hostedFields.submit();
}

The hostedFields.submit() requires a webkitToken value you would have to provide to the hosted field configuration.

const config = {
  webkitToken: 'valid value comes from MoneInWebInit',
  ...
}
const hostedFields = new LwHostedFields(config);

Is there an onBeforeRedirect hook?

If you need to do something before the redirection, you can disable this autoRedirectbehaviour. In this case the submit() function will return a SubmissionResult object. Then you can use this object to invoke the redirection by yourself whenever you want by calling the redirectByFormSubmission() function.

async function onFormSubmit(e: Event) {
    e.preventDefault();
    let submissionResult = await hostedFields.submit(false /* disable autoRedirect */);
    // onBeforeRedirect()
    LwHostedFields.redirectByFormSubmission(submissionResult.webRedirection); //redirect the payer
}