updateInvoice( )


Update an existing invoice.

The updateInvoice() function returns a Promise that resolves to the ID and version of the updated invoice.

Note: The customer listed on the invoice must be an existing site contact or member.

Method Declaration
Copy
function updateInvoice(
  id: IdAndVersion,
  invoiceFields: InvoiceFields,
  fieldMask: Array<string>,
): Promise<Response>;
Method Parameters
idIdAndVersionRequired

ID and version of the invoice to update.


invoiceFieldsInvoiceFieldsRequired

The data used to update the invoice.


fieldMaskArray<string>

Fields to update in the invoice. If not specified, all fields update.

One of:

  • "customer"
  • "lineItems"
  • "number"
  • "locale"
  • "discount"
  • "title"
  • "currency"
  • "issueDate"
  • "dueDate"
  • "taxes"
  • "totals.total"
  • "totals.subtotal"
  • "totals.subtotal"
  • "totals.fees"
  • "metadata.notes"
  • "metadata.legalTerms"
  • "metadata.sourceUrl"
  • "metadata.sourceProperties"
  • "metadata.source"
  • "metadata.sourceRefId"
Returns
Return Type:Promise<Response>
Update an existing invoice
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { invoices } from "wix-billing-backend"; export const updateInvoice = webMethod(Permissions.Anyone, (id) => { return invoices.getInvoice(id).then((result) => { //make some changes result.metadata.notes = "An updated note."; let updateFields = { title: result.title, customer: result.customer, currency: result.currency, lineItems: result.lineItems, discount: result.discount, payments: result.payments, metadata: result.metadata, dates: result.dates, }; return invoices.updateInvoice(result.id, updateFields); }); }); /* Promise resolves to: * { * { * "id": { * "id": "1ed3a515-24f9-4039-8937-2e69b6a2f33a", * "version": 31 * } * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?