Search...
onInvoiceCreated( )
An event that fires when an invoice is created.
Description
The onInvoiceCreated()
event handler runs when an invoice is created. The received Invoice
object contains information about the invoice that was created.
Note: Backend events don't work when previewing your site.
Syntax
function onInvoiceCreated(event: Invoice): void
onInvoiceCreated Parameters
NAME
TYPE
DESCRIPTION
event
Invoice
The invoice that was created.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event when an invoice is created
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.34export function wixBilling_onInvoiceCreated(event) {5 let invoiceId = event.id.id;6 let email = event.customer.email;7}89/* Full event object:10 *11 * {12 * "id":{13 * "id": "411a5551-b0f6-4826-8a41-ebae2879f857",14 * "version": 2515 * },16 * "status": "Draft",17 * "number": "0000001",18 * "title": "My Invoice",19 * "currency": "USD",20 * "customer": {21 * "contactId": "4f7c6637-0657-4696-a00b-9bc2ae4e035d",22 * "email": "john.doe@somedomain.com",23 * "address": {24 * "country": "USA",25 * "subdivision": "NY",26 * "city": "New York",27 * "postalCode": "10011",28 * "streetAddress": {29 * "value": "235 W 23rd St",30 * "type": "Name"31 * },32 * "addressLine": "someStreet",33 * "formatted": "235 W 23rd St, New York, NY 10011, USA"34 * },35 * "billingAddress": {36 * "country": "USA",37 * "streetAddress": {38 * "value": "235 W 23rd St",39 * "type": "Name"40 * },41 * "addressLine": "235 W 23rd St, New York, NY 10011, USA",42 * "postalCode": "10011",43 * "subdivision": "NY",44 * "city": "New York",45 * "formatted": "235 W 23rd St, New York, NY 10011, USA"46 * },47 * "shippingAddress": {48 * "country": "USA",49 * "streetAddress": {50 * "value": "235 W 23rd St",51 * "type": "Name"52 * },53 * "addressLine": "235 W 23rd St, New York, NY 10011, USA",54 * "postalCode": "10011",55 * "subdivision": "NY",56 * "city": "New York",57 * "formatted": "235 W 23rd St, New York, NY 10011, USA"58 * },59 * "phone": "5555555555",60 * "company": "Some Company",61 * "companyId": "Some Company Id",62 * "fullName": "John Doe",63 * "firstName": "John",64 * "lastName": "Doe"65 * },66 * "dates": {67 * "issueDate": 2019-03-13T00:00:00.000Z,68 * "dueDate": 2019-06-12T00:00:00.000Z,69 * "lastSeenDate": 2019-03-14T00:00:00.000Z70 * },71 * "discount": {72 * "value": 2.5,73 * "type": "Fixed"74 * },75 * "lineItems":[76 * {77 * "id": "00001",78 * "name": "Item 1",79 * "description": "First Item",80 * "price": 10.5,81 * "quantity": 3,82 * "taxes": [83 * {84 * "name": "tax name",85 * "rate": 8.5,86 * "code": "tax code"87 * }88 * ]89 * },90 * {91 * "id": "00002",92 * "name": "Item 2",93 * "description": "Second Item",94 * "price": 50,95 * "quantity": 1,96 * "taxes": [97 * {98 * "name": "tax name",99 * "rate": 8.5,100 * "code": "tax code"101 * }102 * ]103 * }104 * ],105 * "locale": {106 * "language": "en"107 * },108 * "payments": [{109 * "id": "4j9q4o00-4205-8q83-003d-3ofd9d8wmf0w",110 * "type": "offline",111 * "amount": "25.50",112 * "date": 2019-03-23T00:00:00.000Z"113 * }],114 * "totals": {115 * "discountAmount": null,116 * "taxedAmount": 6.93,117 * "fees": [],118 * "subtotal": 81.5,119 * "total": 88.43120 * },121 * "dynamicTotals": {122 * "paidAmount": 25.50,123 * "balance": 62.39124 * },125 * "taxes": [126 * {127 * "name": "tax name",128 * "rate": 8.5,129 * "taxable": 81.5,130 * "taxed": 6.93,131 * "code": "tax code"132 * }133 * ],134 * "metadata": {135 * "notes": "Some note.",136 * "legalTerms": "Some legal terms",137 * "sourceUrl": "http://legalurl.com",138 * "source": "Some source",139 * "sourceRefId": "Some source ref id"140 * }141 * }142 */