### Example GET Query with Date Filter Source: https://developer.intuit.com/app/developer/qbo/docs/learn/explore-the-quickbooks-online-api/data-queries Demonstrates a GET request to query customers updated after a specific date and time. Ensure the date format is correct for the query. ```http GET https://quickbooks.api.intuit.com/v3/company/1234/query?query=SELECT%20FROM%20Customer%20WHERE%20Metadata.LastUpdatedTime%20%3E+%272011-08-10T10%3A20%3A30-0700%27 ``` -------------------------------- ### Sample Query for Vendor Balance Detail Report Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/vendorbalancedetail Example of a GET request to retrieve the Vendor Balance Detail report for a specific vendor and date range. This sample includes filtering by vendor, specifying columns, and using a date macro. ```bash BaseURL/v3/company/1386066315/reports/VendorBalanceDetail?vendor=31&columns=tx_date,subt_neg_amount,subt_neg_open_bal&date_macro=Last Fiscal Year ``` -------------------------------- ### Install Composer Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/php/install-the-php-sdk Use this command to download and run the Composer installer script. ```bash curl -sS https://getcomposer.org/installer | php ``` -------------------------------- ### Clone Hello World PHP Repository and Install Dependencies Source: https://developer.intuit.com/app/developer/qbo/docs/get-started/build-your-first-app Clones the 'Hello World' PHP repository and installs necessary dependencies using Composer. Ensure PHP version 5.6 or higher, Composer, and Git Client are installed. ```bash git clone https://github.com/IntuitDeveloper/HelloWorld-PHP.git cd HelloWorld-PHP curl -sS https://getcomposer.org/installer | php composer install ``` -------------------------------- ### Example Execution Log Content Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/php/logging This snippet shows an example of the content found in the `executionlog.txt` file, which records SDK execution details. ```text 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ``` -------------------------------- ### Example Webhook Implementation in Java Source: https://developer.intuit.com/app/developer/qbo/docs/develop/webhooks/configure-webhooks This is an example of how to implement webhooks in Java. It demonstrates the basic structure for receiving and processing webhook notifications. ```java import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Base64; public class WebhookReceiver { private static final String HMAC_SHA256_ALGORITHM = "HmacSHA256"; public static void main(String[] args) { // Example usage: Replace with your actual verifier token and payload String verifierToken = "YOUR_VERIFIER_TOKEN"; String payload = "{\"event_type\":\"CUSTOMER_CREATE\", \"event_data\": { \"id\": \"12345\" }}"; String signature = "YOUR_INTUIT_SIGNATURE"; try { boolean isValid = validateSignature(verifierToken, payload, signature); if (isValid) { System.out.println("Webhook signature is valid."); // Process the webhook event } else { System.out.println("Webhook signature is invalid."); } } catch (NoSuchAlgorithmException | InvalidKeyException e) { System.err.println("Error validating signature: " + e.getMessage()); } } /** * Validates the webhook signature. * * @param verifierToken The verifier token from your app configuration. * @param payload The raw payload of the webhook notification. * @param signature The value of the "intuit-signature" header. * @return true if the signature is valid, false otherwise. * @throws NoSuchAlgorithmException If the HMAC-SHA256 algorithm is not available. * @throws InvalidKeyException If the verifier token is invalid. */ public static boolean validateSignature(String verifierToken, String payload, String signature) throws NoSuchAlgorithmException, InvalidKeyException { SecretKeySpec keySpec = new SecretKeySpec(verifierToken.getBytes(StandardCharsets.UTF_8), HMAC_SHA256_ALGORITHM); Mac mac = Mac.getInstance(HMAC_SHA256_ALGORITHM); mac.init(keySpec); byte[] hmacBytes = mac.doFinal(payload.getBytes(StandardCharsets.UTF_8)); String calculatedSignature = Base64.encodeBase64String(hmacBytes); return calculatedSignature.equals(signature); } // Placeholder for sending a POST request (e.g., to acknowledge receipt) public static void sendAcknowledge(String url) { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString("{ \"status\": \"acknowledged\" }")) .build(); try { HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println("Acknowledge response status: " + response.statusCode()); } catch (IOException | InterruptedException e) { System.err.println("Error sending acknowledge: " + e.getMessage()); } } } ``` -------------------------------- ### Example CDC GET Request Source: https://developer.intuit.com/app/developer/qbo/docs/learn/explore-the-quickbooks-online-api/change-data-capture This example demonstrates a GET request to the CDC endpoint to retrieve changes for 'estimate' and 'customer' entities since a specific date and time. ```HTTP GET https://quickbooks.api.intuit.com/v3/company//cdc?entities=estimate,customer&changedSince=2015-12-23T10:00:00-07:00 ``` -------------------------------- ### Configure Sample App Environment Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/nodejs/oauth-nodejs-client Copy the example environment file to .env for configuration. This step is necessary before running the sample app. ```bash cp .env.example .env ``` -------------------------------- ### Start Sample App Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/nodejs/oauth-nodejs-client Start the Intuit Node.js OAuth 2.0 Client sample application. Ensure you have completed the configuration steps before running this command. ```bash npm start ``` -------------------------------- ### Sample Tax Summary Report Query Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/taxsummary An example of a GET request to retrieve the Tax Summary report for a specific agency and date range. ```http BaseURL/v3/company/1386066315/reports/TaxSummary ?agency_id=1&start_date=2015-04-26&end_date=2015 -04-26 ``` -------------------------------- ### Clone and Install Sample App Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/nodejs/oauth-nodejs-client Clone the Intuit OAuth JS Client sample app from GitHub and install its dependencies. This is the recommended method for using the sample app. ```bash git clone https://github.com/intuit/oauth-jsclient.git cd sample npm install ``` -------------------------------- ### Set Report Query Parameters Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/java/reports Includes desired query parameters to the ReportService object. Examples include start date, end date, and accounting method. ```Java service.setStart_date("2020-01-01"); service.setEnd_date("2020-03-20"); service.setAccounting_method("Accrual"); ``` -------------------------------- ### Configure Web.config for Demo App (.NET) Source: https://developer.intuit.com/app/developer/qbo/docs/get-started/build-your-first-app Edit the Web.config file in the root directory of the cloned 'Hello World' repo to configure your demo app. Enter your app's Client ID and Client secret, and review the Redirect URI. ```xml ``` -------------------------------- ### Count all customers Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/java/query-filters Include the `Count` keyword in your query to get the total number of entities that match the query. This example shows how to count all customers in the QuickBooks company. ```java String query = selectCount(customer).generate(); ``` -------------------------------- ### Install QuickBooks Online .NET SDK using NuGet Source: https://developer.intuit.com/app/developer/qbo/docs/develop/sdks-and-samples-collections/net Install the IppDotNetSdkForQuickBooksApiV3 package using the NuGet Package Manager Console in Visual Studio. ```powershell Install-Package IppDotNetSdkForQuickBooksApiV3 ``` -------------------------------- ### Clone Hello World Repository (.NET) Source: https://developer.intuit.com/app/developer/qbo/docs/get-started/build-your-first-app Clone the 'Hello World' repository to get basic code for building a demo app. This repository sets up your development environment, includes an SDK, handles OAuth 2.0 authorization, and simplifies logging. ```bash git clone https://github.com/IntuitDeveloper/HelloWorldApp-MVC5-Dotnet cd HelloWorldApp-MVC5-Dotnet ``` -------------------------------- ### Get CompanyInfo Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo Retrieves the primary information for a company. This includes details like the company name, addresses, contact information, and fiscal year start month. ```APIDOC ## GET /companyinfo ### Description Retrieves the primary information for a company. This includes details like the company name, addresses, contact information, and fiscal year start month. ### Method GET ### Endpoint /companyinfo ### Response #### Success Response (200) - **CompanyInfo** (object) - Contains detailed company information. - **SyncToken** (string) - Synchronization token for the company. - **domain** (string) - The domain of the company (e.g., 'QBO'). - **LegalAddr** (object) - Legal address details. - **City** (string) - **Country** (string) - **Line1** (string) - **PostalCode** (string) - **CountrySubDivisionCode** (string) - **Id** (string) - **SupportedLanguages** (string) - Languages supported by the company. - **CompanyName** (string) - The name of the company. - **Country** (string) - The country of the company. - **CompanyAddr** (object) - Company address details. - **City** (string) - **Country** (string) - **Line1** (string) - **PostalCode** (string) - **CountrySubDivisionCode** (string) - **Id** (string) - **sparse** (boolean) - Indicates if the object is sparse. - **Id** (string) - The unique identifier for the company. - **WebAddr** (object) - Website address details. - **FiscalYearStartMonth** (string) - The starting month of the fiscal year. - **CustomerCommunicationAddr** (object) - Customer communication address details. - **City** (string) - **Country** (string) - **Line1** (string) - **PostalCode** (string) - **CountrySubDivisionCode** (string) - **Id** (string) - **PrimaryPhone** (object) - Primary phone number details. - **FreeFormNumber** (string) - **LegalName** (string) - The legal name of the company. - **CompanyStartDate** (string) - The start date of the company's operations. - **EmployerId** (string) - The employer identification number. - **Email** (object) - Email address details. - **Address** (string) - **NameValue** (array) - Array of key-value pairs for additional company attributes. - **Name** (string) - **Value** (string) - **MetaData** (object) - Metadata about the company record. - **CreateTime** (string) - The creation timestamp. - **LastUpdatedTime** (string) - The last updated timestamp. - **time** (string) - Timestamp of the response. #### Response Example ```json { "CompanyInfo": { "SyncToken": "4", "domain": "QBO", "LegalAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "SupportedLanguages": "en", "CompanyName": "Larry's Bakery", "Country": "USA", "CompanyAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "sparse": false, "Id": "1", "WebAddr": {}, "FiscalYearStartMonth": "January", "CustomerCommunicationAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "PrimaryPhone": { "FreeFormNumber": "(650)944-4444" }, "LegalName": "Larry's Bakery", "CompanyStartDate": "2015-06-05", "EmployerId": "123456789", "Email": { "Address": "donotreply@intuit.com" }, "NameValue": [ { "Name": "NeoEnabled", "Value": "true" }, { "Name": "IndustryType", "Value": "Bread and Bakery Product Manufacturing" }, { "Name": "IndustryCode", "Value": "31181" }, { "Name": "SubscriptionStatus", "Value": "PAID" }, { "Name": "OfferingSku", "Value": "QuickBooks Online Plus" }, { "Name": "PayrollFeature", "Value": "true" }, { "Name": "AccountantFeature", "Value": "false" }, { "Name": "IsQbdtMigrated", "Value": "true" }, { "Name": "MigrationDate", "Value": "2024-09-14T01:47:34-07:00" }, { "Name": "QBOIndustryType", "Value": "Manufacturing Businesses" }, { "Name": "AssignedTime", "Value": "2024-09-14T01:47:34-07:00" } ], "MetaData": { "CreateTime": "2015-06-05T13:55:54-07:00", "LastUpdatedTime": "2015-07-06T08:51:50-07:00" } }, "time": "2015-07-10T09:38:58.155-07:00" } ``` ``` -------------------------------- ### Response Body for Company Info Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/companyinfo This is an example of the JSON response received when querying company information. It includes various details about the company's setup and metadata. ```JSON { "CompanyInfo": { "SyncToken": "4", "domain": "QBO", "LegalAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "SupportedLanguages": "en", "CompanyName": "Larry's Bakery", "Country": "USA", "CompanyAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "sparse": false, "Id": "1", "WebAddr": {}, "FiscalYearStartMonth": "January", "CustomerCommunicationAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "PrimaryPhone": { "FreeFormNumber": "(650)944-4444" }, "LegalName": "Larry Smith's Bakery" , "CompanyStartDate": "2015-06-05", "EmployerId": "123456789", "Email": { "Address": "donotreply@intuit .com" }, "NameValue": [ { "Name": "NeoEnabled", "Value": "true" }, { "Name": "IndustryType", "Value": "Bread and Bakery Product Manufacturing" }, { "Name": "IndustryCode", "Value": "31181" }, { "Name": "SubscriptionStatus", "Value": "PAID" }, { "Name": "OfferingSku", "Value": "QuickBooks Online Plus" }, { "Name": "PayrollFeature", "Value": "true" }, { "Name": "AccountantFeature", "Value": "false" }, { "Name": "IsQbdtMigrated", "Value": "true" }, { "Name": "MigrationDate", "Value": "2024-09-14T01:47:34 -07:00" }, { "Name": "QBOIndustryType", "Value": "Manufacturing Businesses" }, { "Name": "AssignedTime", "Value": "2024-09-14T01:47:34 -07:00" } ], "MetaData": { "CreateTime": "2015-06-05T13:55 :54-07:00", "LastUpdatedTime": "2015-07-06T08 :51:50-07:00" } }, "time": "2015-07-10T09:38:58.155-07 :00" } ``` -------------------------------- ### Company Info Response Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo This is an example of the response body when retrieving company information. It includes details like company name, addresses, fiscal year start, and various metadata. ```json { "CompanyInfo": { "SyncToken": "4", "domain": "QBO", "LegalAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "SupportedLanguages": "en", "CompanyName": "Larry's Bakery", "Country": "USA", "CompanyAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "sparse": false, "Id": "1", "WebAddr": {}, "FiscalYearStartMonth": "January", "CustomerCommunicationAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "PrimaryPhone": { "FreeFormNumber": "(650)944-4444" }, "LegalName": "Larry Smith's Bakery" , "CompanyStartDate": "2015-06-05", "EmployerId": "123456789", "Email": { "Address": "donotreply@intuit.com" }, "NameValue": [ { "Name": "NeoEnabled", "Value": "true" }, { "Name": "IndustryType", "Value": "Bread and Bakery Product Manufacturing" }, { "Name": "IndustryCode", "Value": "31181" }, { "Name": "SubscriptionStatus", "Value": "PAID" }, { "Name": "OfferingSku", "Value": "QuickBooks Online Plus" }, { "Name": "PayrollFeature", "Value": "true" }, { "Name": "AccountantFeature", "Value": "false" }, { "Name": "IsQbdtMigrated", "Value": "true" }, { "Name": "MigrationDate", "Value": "2024-09-14T01:47:34-07:00" }, { "Name": "QBOIndustryType", "Value": "Manufacturing Businesses" }, { "Name": "AssignedTime", "Value": "2024-09-14T01:47:34-07:00" } ], "MetaData": { "CreateTime": "2015-06-05T13:55:54-07:00", "LastUpdatedTime": "2015-07-06T08:51:50-07:00" } }, "time": "2015-07-10T09:38:58.155-07:00" } ``` -------------------------------- ### Retrieve Linked Transaction Details Source: https://developer.intuit.com/app/developer/qbo/docs/workflows/manage-linked-transactions To get the complete details of a linked transaction, you must traverse the link to retrieve the object. This example shows how to retrieve a payment linked to an invoice. ```HTTP https://quickbooks.api.intuit.com/v3/company/1386066315/payment/190 ``` -------------------------------- ### GET CompanyInfo Response Body Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo This is an example of the JSON response body when retrieving company information. It contains detailed company data, including addresses, contact information, and metadata. ```json { "CompanyInfo": { "SyncToken": "4", "domain": "QBO", "LegalAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "SupportedLanguages": "en", "CompanyName": "Larry's Bakery", "Country": "USA", "CompanyAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "sparse": false, "Id": "1", "WebAddr": {}, "FiscalYearStartMonth": "January", "CustomerCommunicationAddr": { "City": "Mountain View", "Country": "USA", "Line1": "2500 Garcia Ave", "PostalCode": "94043", "CountrySubDivisionCode": "CA", "Id": "1" }, "PrimaryPhone": { "FreeFormNumber": "(650)944-4444" }, "LegalName": "Larry's Bakery", "CompanyStartDate": "2015-06-05", "EmployerId": "123456789", "Email": { "Address": "donotreply@intuit .com" }, "NameValue": [ { "Name": "NeoEnabled", "Value": "true" }, { "Name": "IndustryType", "Value": "Bread and Bakery Product Manufacturing" }, { "Name": "IndustryCode", "Value": "31181" }, { "Name": "SubscriptionStatus", "Value": "PAID" }, { "Name": "OfferingSku", "Value": "QuickBooks Online Plus" }, { "Name": "PayrollFeature", "Value": "true" }, { "Name": "AccountantFeature", "Value": "false" }, { "Name": "IsQbdtMigrated", "Value": "true" }, { "Name": "MigrationDate", "Value": "2024-09-14T01:47:34 -07:00" }, { "Name": "QBOIndustryType", "Value": "Manufacturing Businesses" }, { "Name": "AssignedTime", "Value": "2024-09-14T01:47:34 -07:00" } ], "MetaData": { "CreateTime": "2015-06-05T13:55 :54-07:00", "LastUpdatedTime": "2015-07-06T08 :51:50-07:00" } }, "time": "2015-07-10T09:38:58.155-07 :00" } ``` -------------------------------- ### Clone Hello World Java Repository Source: https://developer.intuit.com/app/developer/qbo/docs/get-started/build-your-first-app Clone the 'Hello World' Java repository to get a basic code structure for your demo app. This repository simplifies authorization setup and logging. ```bash git clone https://github.com/IntuitDeveloper/HelloWorld-Java.git cd HelloWorld-Java ``` -------------------------------- ### Sample Account Query Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/most-commonly-used/account An example of a query to retrieve accounts created after a specific date. ```sql select * from Account where Metadata.CreateTime > '2014-12-31' ``` -------------------------------- ### Example Authorize URL for OpenID Connect Source: https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/faq Use this URL to initiate the authorization process for OpenID Connect scopes, allowing your app to get user profile information. Ensure your user is signed in to QuickBooks Online for the realmId to be presented. ```url https://appcenter.intuit.com/connect/oauth2? client_id=& scope=openid%20email%20address& redirect_uri=& response_type=code& state=138r5719ru3e1& claims=%7B%22id_token%22%3A%7B%22realmId%22%3Anull%7D%7D ``` -------------------------------- ### Query Account Example Source: https://developer.intuit.com/app/developer/qbo/docs/workflows/manage-inventory/inventory-adjustment This example demonstrates how to query for valid account IDs, which is useful for resolving business validation errors related to account references. Use this to find valid account IDs for your company realm. ```http GET /v3/company//query?query=Select * from Account where Name='Inventory Shrinkage' ``` -------------------------------- ### Sample Class Query Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/class A basic example of a query to retrieve all class entities. ```sql select * from Class ``` -------------------------------- ### Get Entitlements Source: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/entitlements Retrieves the features available to a company, identified by the company's realmID. The features available are determined by the type of company established during QuickBooks Online setup. Note: This resource does not accept an application/json header. Use application/xml as the accept header. ```APIDOC ## GET /Entitlements ### Description Retrieves the features available to a company, identified by the company's realmID. The features available are determined by the type of company established during QuickBooks Online setup. ### Method GET ### Endpoint /Entitlements ### Headers - **Accept**: application/xml ### Response #### Success Response (200) - **QboCompany** (Boolean) - Indicates if the company is a QuickBooks Online company. - **PlanName** (String) - Billing plan associated with this company. - **MaxUsers** (Integer) - Maximum billable users allowed in the company. - **CurrentUsers** (Integer) - Billable users currently in the company. - **DaysRemainingTrial** (Integer) - Remaining trial period days. - **Entitlement** (Array of Entitlement objects) - Details about each entitlement. - **id** (Integer) - The ID of the entitlement. - **name** (String) - The name of the entitlement. - **term** (Boolean) - Availability of entitlement: On or Off. ### Response Example ```xml true QBWEBPLUSPAYROLLMONTHLY 10 4 0 PayPal Off Merchant Service Off Class Tracking On ``` ``` -------------------------------- ### Create Customer, Item, Invoice, Send Email, and Receive Payment Source: https://developer.intuit.com/app/developer/qbo/docs/develop/basic-implementations/basic-invoicing-implementation Demonstrates the complete workflow of creating a customer, an item, an invoice, sending the invoice email, and receiving a payment for the invoice. ```java //create oauth object OAuth2Authorizer oauth = new OAuth2Authorizer(accessToken); //create context Context context = new Context(oauth, ServiceType.QBO, realmId); //create DataService DataService service = new DataService(context); //add customer Customer customer = new Customer(); customer.setDisplayName(RandomStringUtils.randomAlphanumeric(6)); EmailAddress emailAddr = new EmailAddress(); emailAddr.setAddress("testconceptsample@mailinator.com"); customer.setPrimaryEmailAddr(emailAddr); Customer savedCustomer = service.add(customer); //add item Item item = new Item(); item.setName("Item" + RandomStringUtils.randomAlphanumeric(5)); item.setUnitPrice(new BigDecimal("200")); item.setType(ItemTypeEnum.SERVICE); Account incomeAccount = getIncomeBankAccount(service); //query or income account item.setIncomeAccountRef(createRef(incomeAccount)); Item savedItem = service.add(item); //create invoice using customer and item created above Invoice invoice = new Invoice(); invoice.setCustomerRef(createRef(savedCustomer)); Line line1 = new Line(); line1.setAmount(new BigDecimal("300.00")); line1.setDetailType(LineDetailTypeEnum.SALES_ITEM_LINE_DETAIL); SalesItemLineDetail salesItemLineDetail1 = new SalesItemLineDetail(); salesItemLineDetail1.setItemRef(createRef(savedItem)); line1.setSalesItemLineDetail(salesItemLineDetail1); List lines1 = new ArrayList<>(); lines1.add(line1); invoice.setLine(lines1); Invoice savedInvoice = service.add(invoice); //send invoice email to customer service.sendEmail(savedInvoice, customer.getPrimaryEmailAddr().getAddress()); //receive payment for the invoice Payment payment = new Payment(); payment.setCustomerRef(createRef(customer)); payment.setTotalAmt(invoice.getTotalAmt()); List linkedTxnList = new ArrayList(); LinkedTxn linkedTxn = new LinkedTxn(); linkedTxn.setTxnId(savedInvoice.getId()); linkedTxn.setTxnType(TxnTypeEnum.TxnTypeEnum.INVOICE.value()); linkedTxnList.add(linkedTxn); Line line1 = new Line(); line1.setAmount(invoice.getTotalAmt()); line1.setLinkedTxn(linkedTxnList); List lineList = new ArrayList(); lineList.add(line1); payment.setLine(lineList); service.add(payment); ``` -------------------------------- ### Initialize DataService and Get Authorization URL (PHP) Source: https://developer.intuit.com/app/developer/qbo/docs/get-started/build-your-first-app This PHP code initializes the DataService object with necessary OAuth2 credentials and generates the authorization URL required to start the OAuth 2.0 flow. It also handles retrieving company info if an access token is already available. ```php 'oauth2', 'ClientID' => $config['client_id'], 'ClientSecret' => $config['client_secret'], 'RedirectURI' => $config['oauth_redirect_uri'], 'scope' => $config['oauth_scope'], 'baseUrl' => "development" )); $OAuth2LoginHelper = $dataService->getOAuth2LoginHelper(); $authUrl = $OAuth2LoginHelper->getAuthorizationCodeURL(); // Store the url in PHP Session Object; $_SESSION['authUrl'] = $authUrl; //set the access token using the auth object if (isset($_SESSION['sessionAccessToken'])) { $accessToken = $_SESSION['sessionAccessToken']; $accessTokenJson = array('token_type' => 'bearer', 'access_token' => $accessToken->getAccessToken(), 'refresh_token' => $accessToken->getRefreshToken(), 'x_refresh_token_expires_in' => $accessToken->getRefreshTokenExpiresAt(), 'expires_in' => $accessToken->getAccessTokenExpiresAt() ); $dataService->updateOAuth2Token($accessToken); $oauthLoginHelper = $dataService -> getOAuth2LoginHelper(); $CompanyInfo = $dataService->getCompanyInfo(); } ?> ``` -------------------------------- ### Create an Invoice with Bundle, Description, and Discount Source: https://developer.intuit.com/app/developer/qbo/docs/workflows/create-an-invoice This example shows how to add a bundle of items, a description, and a percentage-based discount to an invoice. The 'GroupItemRef' identifies the bundle, and 'DiscountLineDetail' specifies the discount percentage. ```json { "Line": [ { "DetailType": "GroupLineDetail", "GroupLineDetail": { "GroupItemRef": { "value": "19", "name": "Bundle One" }, "Quantity": 2 } }, { "Description": "Additional info here", "DetailType": "DescriptionOnly" }, { "DetailType": "DiscountLineDetail", "DiscountLineDetail": { "PercentBased": true, "DiscountPercent": 10 } } ], "CustomerRef": { "value": "1" } } ``` -------------------------------- ### Named Query Operation Example Source: https://developer.intuit.com/app/developer/qbo/docs/develop/develop-with-graphql/graphql-api An example of a named query operation to explicitly request the company ID. ```APIDOC ## query ReadCompanyId ### Description An example of a named query operation to explicitly request the company ID. ### Method POST ### Endpoint https://api.intuit.com/graphql ### Request Body - **query** (string) - The GraphQL query with an explicit operation name. ### Request Example ```graphql query ReadCompanyId { company { id } } ``` ```