0

Create Customer

by
Published Jun 6, 2022

Creates a customer. [See docs here](https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer#create-a-customer)

Script quickbooks Verified

The script

Submitted by hugo697 Bun
Verified 324 days ago
1
import QuickBooks from "node-quickbooks";
2

3
type Quickbooks = {
4
  realmId: string;
5
  token: string;
6
  isSandBox: boolean;
7
};
8

9
export async function main(
10
  resource: Quickbooks,
11
  customer: {
12
    FullyQualifiedName?: string;
13
    PrimaryEmailAddr?: {
14
      Address: string;
15
    };
16
    DisplayName?: string;
17
    Suffix?: string;
18
    Title?: string;
19
    MiddleName?: string;
20
    Notes?: string;
21
    FamilyName?: string;
22
    PrimaryPhone?: {
23
      FreeFormNumber: string;
24
    };
25
    CompanyName?: string;
26
    BillAddr?: {
27
      CountrySubDivisionCode: string;
28
      City: string;
29
      PostalCode: string;
30
      Line1: string;
31
      Country: string;
32
    };
33
    GivenName?: string;
34
  }
35
) {
36
  const qbo = new QuickBooks("", "", resource.token, false, resource.realmId, resource.isSandBox, true, null, "2.0");
37

38
  return new Promise((resolve, reject) => {
39
    qbo.createCustomer(customer, function (err: any, result: any) {
40
      if (err) {
41
        reject(err);
42
      } else {
43
        resolve(result);
44
      }
45
    });
46
  });
47
}
48