> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: createInvoice(invoiceFields: InvoiceFields) # Method package: wixBillingBackend # Method menu location: wixBillingBackend --> Invoices --> createInvoice # Method Link: https://dev.wix.com/docs/velo/apis/wix-billing-backend/invoices/create-invoice.md # Method Description: 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 Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a new invoice ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { invoices } from 'wix-billing-backend'; const now = new Date(); const dueDate = new Date(); dueDate.setDate(now.getDate() + 30); let customer = { // contact ID and email address must match an // existing contact in the site's contact list "contactId": "4f7c6637-0657-4696-a00b-9bc2ae4e035d", "email": "john.doe@somedomain.com", "address": { "city": "New York", "subdivision": "NY", "postalCode": "10011", "country": "USA", "addressLine": "235 W 23rd St" }, "billingAddress": { "country": "USA", "streetAddress": { "value": "235 W 23rd St", "type": "Name" }, "addressLine": "235 W 23rd St, New York, NY 10011, USA", "addressLine2": "secondary address", "postalCode": "10011", "subdivision": "NY", "city": "New York" }, "shippingAddress": { "country": "USA", "streetAddress": { "value": "235 W 23rd St", "type": "Name" }, "addressLine": "235 W 23rd St, New York, NY 10011, USA", "addressLine2": "secondary address", "postalCode": "10011", "subdivision": "NY", "city": "New York" }, "phone": "5555555555", "company": "Some Company", "companyId": "Some Company Id", "fullName": "John Doe", "firstName": "John", "lastName": "Doe" }; let lineItems = [ { "id": "00001", "name": "Item 1", "description": "First Item", "price": 10.50, "quantity": 3, "taxes": [{ "name": "tax name", "rate": 8.5, "code": "tax code" }] }, { "id": "00002", "name": "Item 2", "description": "Second Item", "price": 50, "quantity": 1, "taxes": [{ "name": "tax name", "rate": 8.5, "code": "tax code" }] } ]; let discount = { "value": 2.5, "type": "Fixed" }; const payments = [{ "id": "00001", "type": "Offline", "amount": 25.50, "date": now }]; let metadata = { "notes": "Some note.", "legalTerms": "Some legal terms", "sourceUrl": "http://legalurl.com", "source": "Some source", "sourceRefId": "Some source ref id" }; let dates = { "issueDate": now, "dueDate": dueDate }; export const createInvoice = webMethod(Permissions.Anyone, () => { let createInvoiceFields = { "title": "My Invoice", "customer": customer, "currency": "USD", "lineItems": lineItems, "discount": discount, "payments": payments, "metadata": metadata, "dates": dates, "locale": { language: "ja" } }; return invoices.createInvoice(createInvoiceFields); }); /* Promise resolves to: * { * "id": { * "id": "fe00fd47-c30e-47da-9b5a-8cacfbed744d" * "version": 23 * } * } */ ``` ---