Invoice component

Gain a better understanding of the invoice component, how to create and mount it, as well as how to submit the information it collects from customers

The invoice component collects information needed to comply with Taiwan's e-invoicing requirements. For background on these requirements, refer to e-Invoicing.

To use the component, you'll need to create it, mount it, and submit its data.

In the data returned by onChange, you can use showInvoiceAttribute to determine whether this component must be displayed.

Creating the invoice component

To create an instance of the invoice component, pass 'invoiceattribute' to createComponent().

let invoiceComponent;
invoiceComponent = components.createComponent('invoiceattribute');

Mounting the invoice component

To attach the invoice component to your DOM, pass the id of its container to mount().

<div id="invoice-container" style="display: block"></div>

Submitting the invoice component

The invoice component exposes done(), which submits the customer's input and returns a boolean. It requires that you use the await operator and, therefore, must be called inside an async function.

const invoiceComponentStatus = await invoiceComponent.done();

If done() returns true, this indicates that customers entered a properly formatted carrier value, and your code can advance them to the next stage of the checkout.

A false value indicates that customers either didn't provide a value or it's incorrectly formatted, and you shouldn't allow the checkout to advance. In this case, the component prompts customers to try again and offers them formatting assistance.

Last updated