Introduction

To use the Invoices API, import {invoices} from the wix-billing-backend module:

Copy
Did this help?

addPayment( )


Adds a payment to the invoice and reports the payment to the payment provider.

The addPayment() function returns a Promise that resolves when the specified payment is added to the invoice with the specified ID.

Method Declaration
Copy
Method Parameters
idIdAndVersionRequired

ID and version of the invoice.


paymentPaymentRequired

The payment that should be added to the invoice.

Returns
Return Type:Promise<Response>
JavaScript
Did this help?

createInvoice( )


Creates a new invoice.

The createInvoice() function returns a Promise that resolves to the created invoice's ID when the invoice is created.

Note: The customer ID and email address listed on the invoice must match an existing contact in the site's contact list.

Method Declaration
Copy
Method Parameters
invoiceFieldsInvoiceFieldsRequired

The data used to create an invoice.

Returns
Return Type:Promise<Response>
Create a new invoice
JavaScript
Did this help?

createInvoicePreviewUrl( )


Creates a link that can be used by a customer to preview the invoice.

The createInvoicePreviewUrl() function returns a Promise that resolves to a temporary link to a preview of the invoice with the specified ID.

You can get a list of invoices by querying your site's "Billing/Invoices" collection. Each invoice in the query result contains the _id and version fields, which must be used when calling createInvoicePreviewUrl().

By default, createInvoicePreviewUrl() can be called by site contributors only. To allow customers to generate the invoice preview link, set suppressAuth in the options argument to true.

Method Declaration
Copy
Method Parameters
idIdAndVersionRequired

Object containing the ID and version of the invoice.


optionsAuthOptions

An object with the following boolean property: suppressAuth.

Returns
Return Type:Promise<string>
JavaScript
Did this help?

deleteInvoice( )


Deletes an invoice by ID.

The deleteInvoice() function returns a Promise that resolves when the invoice with the specified ID is deleted.

Method Declaration
Copy
function deleteInvoice(id: string): Promise<void>;
Method Parameters
idstringRequired

ID of the invoice to delete.

Delete invoice by ID
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { invoices } from "wix-billing-backend"; export const deleteInvoice = webMethod(Permissions.Anyone, (id) => { return invoices.deleteInvoice(id); });
Did this help?