window.confidoHostedFields.submitFields(async (err) => {
if (err) {
// There was an error with submitting the field
// data. We should pause here, and let the user
// fix the issue.
return;
}
// Field data was submitted successfully.
// Now we can finish off the payment from
// our backend.
const otherFormData = gatherOtherFormData();
const result = await fetch("/my-api/payment-session-complete", {
method: "post",
body: JSON.stringify({
paymentToken,
...otherFormData,
}),
});
// The result from your backend
console.log(result);
});