Search.../

createPriceQuote( )

Creates a new price quote.

Description

The createPriceQuote() function returns a Promise that resolves to the created price quote's ID and version when the price quote is created.

Note: The customer ID and email address listed on the price quote must match an existing contact in the site's contact list.

Authorization

Request

This endpoint does not take any parameters

Response Object

Fulfilled - ID and version of the created price quote.

NAME
TYPE
DESCRIPTION
id
IdAndVersion

ID and version information.

Status/Error Codes

Was this helpful?

Create a new price quote

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { priceQuotes } from 'wix-billing-backend';
3
4const now = new Date();
5const dueDate = new Date();
6dueDate.setDate(now.getDate() + 30);
7
8let customer = {
9 // contact ID and email address must match an
10 // existing contact in the site's contact list
11 "contactId": "4f7c6637-0657-4696-a00b-9bc2ae4e035d",
12 "email": "john.doe@somedomain.com",
13 "address": {
14 "city": "New York",
15 "subdivision": "NY",
16 "postalCode": "10011",
17 "country": "USA",
18 "addressLine": "235 W 23rd St"
19 },
20 "billingAddress": {
21 "country": "USA",
22 "streetAddress": {
23 "value": "235 W 23rd St",
24 "type": "Name"
25 },
26 "addressLine": "235 W 23rd St, New York, NY 10011, USA",
27 "addressLine2": "secondary address",
28 "postalCode": "10011",
29 "subdivision": "NY",
30 "city": "New York"
31 },
32 "shippingAddress": {
33 "country": "USA",
34 "streetAddress": {
35 "value": "235 W 23rd St",
36 "type": "Name"
37 },
38 "addressLine": "235 W 23rd St, New York, NY 10011, USA",
39 "addressLine2": "secondary address",
40 "postalCode": "10011",
41 "subdivision": "NY",
42 "city": "New York"
43 },
44 "phone": "5555555555",
45 "company": "Some Company",
46 "companyId": "Some Company Id",
47 "fullName": "John Doe",
48 "firstName": "John",
49 "lastName": "Doe"
50};
51
52let lineItems = [
53 {
54 "id": "00001",
55 "name": "Item 1",
56 "description": "First Item",
57 "price": 10.50,
58 "quantity": 3,
59 "taxes": [{
60 "name": "tax name",
61 "rate": 8.5,
62 "code": "tax code"
63 }]
64 },
65 {
66 "id": "00002",
67 "name": "Item 2",
68 "description": "Second Item",
69 "price": 50,
70 "quantity": 1,
71 "taxes": [{
72 "name": "tax name",
73 "rate": 8.5,
74 "code": "tax code"
75 }]
76 }
77];
78
79let discount = {
80 "value": 2.5,
81 "type": "Fixed"
82};
83
84let paymentTerms = {
85 "termData": "some term data",
86 "termType": "DueOnReceipt"
87};
88
89let metadata = {
90 "notes": "Some note.",
91 "legalTerms": "Some legal terms",
92 "sourceUrl": "http://legalurl.com",
93 "source": "Some source",
94 "sourceRefId": "Some source ref id"
95};
96
97let dates = {
98 "issueDate": now,
99 "validThroughDate": dueDate
100};
101
102export const createPriceQuote = webMethod(Permissions.Anyone, () => {
103 let createPriceQuoteFields = {
104 "title": "My Price Quote",
105 "customer": customer,
106 "currency": "USD",
107 "lineItems": lineItems,
108 "discount": discount,
109 "paymentTerms": paymentTerms,
110 "metadata": metadata,
111 "dates": dates
112 };
113
114 return priceQuotes.createPriceQuote(createPriceQuoteFields);
115});
116
117/* Promise resolves to:
118 * {
119 * "id": {
120 * "id": "411a5551-b0f6-4826-8a41-ebae2879f857"
121 * "version": 25
122 * }
123 * }
124*/