Form Submission

Default behaviour

When the form submits, the SDK will:

  • Validate all fields

  • Tokenize the card data

  • Add a hidden input with name="paymentToken" to your form

  • Allow the form to submit normally to your endpoint only if all validation and field tokenization passes.

Use this paymentToken in the body payload of the Sale API, in place of the card details. See Call Sale API with token

If using a JavaScript callback for form submission

When using the onSubmitPayment callback:

  • Validation and tokenization occur automatically

  • If both pass, the onSubmitPayment callback receives the payment token

  • You're responsible for sending the token to your server

Netvalve.initTokenFields({ onSubmitPayment: async (paymentToken) => { // Show loading state showLoadingSpinner(); // example sending the payment token inside callback try { const response = await fetch('/api/process-payment', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ paymentToken }) }); // Handle response const result = await response.json(); handlePaymentResult(result); } catch (error) { // Handle error showError('Payment processing failed'); } finally { // Hide loading state hideLoadingSpinner(); } } });

Remember: The payment token must be included in your sale API request body. Loading indicators and error handling are your responsibility - the SDK focuses solely on secure card data collection and tokenization.

See Also

Related pages