Search.../

getInvoice( )

Gets an existing invoice by ID.

Description

The getInvoice() function returns a Promise that resolves to the invoice with the specified ID.

Syntax

function getInvoice(id: string): Promise<Invoice>

getInvoice Parameters

NAME
TYPE
DESCRIPTION
id
string

ID of the invoice to get.

Returns

Fulfilled - The invoice with the given ID.

Return Type:

Promise<Invoice>
NAME
TYPE
DESCRIPTION
id
IdAndVersion

ID and version of the invoice.

status
string

Status of the invoice. One of:

  • "Draft"
  • "Sent"
  • "Processing"
  • "Paid"
  • "Overdue"
  • "Void"
  • "Deleted"
  • "PartiallyPaid"
  • "PartialAndOverdue"
number
string

Number of the invoice, unique within your site.

title
string

Title of the invoice.

currency
string

Currency code.

locale
Locale

Locale information.

customer
Customer

Customer listed on the invoice.

lineItems
Array<LineItem>

Line items listed on the invoice.

discount
Discount

Discount included in the invoice.

payments
Array<Payment>

List of payments already received from the customer.

taxes
Array<CalculatedTax>

List of taxes calculated based on the line items.

totals
TotalPrice

Total values.

dynamicTotals
InvoiceDynamicTotals

Invoice dynamic totals.

metadata
MetaData

Additional metadata included in the invoice.

companyId
string

Invoice company ID.

wasSent
boolean

Whether the invoice was sent to the customer.

dates
InvoiceDates

Dates associated with the invoice.

Was this helpful?

Get invoice by ID

Copy Code
1import {invoices} from 'wix-billing-backend';
2
3export function getInvoice(id) {
4 return invoices.getInvoice(id);
5}
6
7/* Promise resolves to:
8 *
9 * {
10 * "id":{
11 * "id": "411a5551-b0f6-4826-8a41-ebae2879f857",
12 * "version": 25
13 * },
14 * "status": "Draft",
15 * "number": "0000001",
16 * "title": "My Invoice",
17 * "currency": "USD",
18 * "customer": {
19 * "contactId": "4f7c6637-0657-4696-a00b-9bc2ae4e035d",
20 * "email": "john.doe@somedomain.com",
21 * "address": {
22 * "country": "USA",
23 * "subdivision": "NY",
24 * "city": "New York",
25 * "postalCode": "10011",
26 * "streetAddress": {
27 * "value": "235 W 23rd St",
28 * "type": "Name"
29 * },
30 * "addressLine": "someStreet",
31 * "formatted": "235 W 23rd St, New York, NY 10011, USA"
32 * },
33 * "billingAddress": {
34 * "country": "USA",
35 * "streetAddress": {
36 * "value": "235 W 23rd St",
37 * "type": "Name"
38 * },
39 * "addressLine": "235 W 23rd St, New York, NY 10011, USA",
40 * "postalCode": "10011",
41 * "subdivision": "NY",
42 * "city": "New York",
43 * "formatted": "235 W 23rd St, New York, NY 10011, USA"
44 * },
45 * "shippingAddress": {
46 * "country": "USA",
47 * "streetAddress": {
48 * "value": "235 W 23rd St",
49 * "type": "Name"
50 * },
51 * "addressLine": "235 W 23rd St, New York, NY 10011, USA",
52 * "postalCode": "10011",
53 * "subdivision": "NY",
54 * "city": "New York",
55 * "formatted": "235 W 23rd St, New York, NY 10011, USA"
56 * },
57 * "phone": "5555555555",
58 * "company": "Some Company",
59 * "companyId": "Some Company Id",
60 * "fullName": "John Doe",
61 * "firstName": "John",
62 * "lastName": "Doe"
63 * },
64 * "dates": {
65 * "issueDate": 2019-03-13T00:00:00.000Z,
66 * "dueDate": 2019-06-12T00:00:00.000Z,
67 * "lastSeenDate": 2019-03-14T00:00:00.000Z
68 * },
69 * "discount": {
70 * "value": 2.5,
71 * "type": "Fixed"
72 * },
73 * "lineItems":[
74 * {
75 * "id": "00001",
76 * "name": "Item 1",
77 * "description": "First Item",
78 * "price": 10.5,
79 * "quantity": 3,
80 * "taxes": [
81 * {
82 * "name": "tax name",
83 * "rate": 8.5,
84 * "code": "tax code"
85 * }
86 * ]
87 * },
88 * {
89 * "id": "00002",
90 * "name": "Item 2",
91 * "description": "Second Item",
92 * "price": 50,
93 * "quantity": 1,
94 * "taxes": [
95 * {
96 * "name": "tax name",
97 * "rate": 8.5,
98 * "code": "tax code"
99 * }
100 * ]
101 * }
102 * ],
103 * "locale": {
104 * "language": "en"
105 * },
106 * "payments": [{
107 * "id": "4j9q4o00-4205-8q83-003d-3ofd9d8wmf0w",
108 * "type": "offline",
109 * "amount": "25.50",
110 * "date": 2019-03-23T00:00:00.000Z"
111 * }],
112 * "totals": {
113 * "discountAmount": null,
114 * "taxedAmount": 6.93,
115 * "fees": [],
116 * "subtotal": 81.5,
117 * "total": 88.43
118 * },
119 * "dynamicTotals": {
120 * "paidAmount": 25.50,
121 * "balance": 62.39
122 * },
123 * "taxes": [
124 * {
125 * "name": "tax name",
126 * "rate": 8.5,
127 * "taxable": 81.5,
128 * "taxed": 6.93,
129 * "code": "tax code"
130 * }
131 * ],
132 * "metadata": {
133 * "notes": "Some note",
134 * "legalTerms": "Some legal terms",
135 * "sourceUrl": "http://legalurl.com",
136 * "source": "Some source",
137 * "sourceRefId": "Some source ref id"
138 * },
139 * "companyId": "Some company id",
140 * "wasSent": true
141 * }
142 */