Search...
updateInvoice( )
Update an existing invoice.
Description
The updateInvoice()
function returns a Promise that resolves to the updated invoice's
ID when the invoice is updated.
Note: The customer listed on the invoice must be an existing site contact or member.
Syntax
function updateInvoice(id: IdAndVersion, invoiceFields: InvoiceFields, [fieldMask: Array<string>]): Promise<Response>
updateInvoice Parameters
NAME
TYPE
DESCRIPTION
id
IdAndVersion
ID and version of the invoice to update.
invoiceFields
InvoiceFields
The data used to update the invoice.
fieldMask
Optional
Array<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
Fulfilled - ID and version of the updated invoice.
Return Type:
Promise<Response>
NAME
TYPE
DESCRIPTION
id
IdAndVersion
ID and version information.
Was this helpful?
Update an existing invoice
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { invoices } from 'wix-billing-backend';34export const updateInvoice = webMethod(Permissions.Anyone, (id) => {5 return invoices.getInvoice(id)6 .then((result) => {7 //make some changes8 result.metadata.notes = "An updated note.";910 let updateFields = {11 "title": result.title,12 "customer": result.customer,13 "currency": result.currency,14 "lineItems": result.lineItems,15 "discount": result.discount,16 "payments": result.payments,17 "metadata": result.metadata,18 "dates": result.dates19 };20 return invoices.updateInvoice(result.id, updateFields);21 });22});2324/* Promise resolves to:25 * {26 * {27 * "id": {28 * "id": "1ed3a515-24f9-4039-8937-2e69b6a2f33a",29 * "version": 3130 * }31 * }32 * }33 */