markTestSkipped('No need to run this test on Travis'); } elseif(Company::whereNotNull('quickbooks')->count() == 0){ $this->markTestSkipped('No need to run this test on Travis'); } $this->makeTestData(); } public function testCreateCustomerInQb() { $c = Company::whereNotNull('quickbooks')->first(); $qb = new QuickbooksService($c); $customerData = [ "DisplayName" => $this->client->present()->name(), // Required and must be unique "PrimaryEmailAddr" => [ "Address" => $this->client->present()->email(), ], "PrimaryPhone" => [ "FreeFormNumber" => $this->client->present()->phone() ], "CompanyName" => $this->client->present()->name(), "BillAddr" => [ "Line1" => $this->client->address1 ?? '', "City" => $this->client->city ?? '', "CountrySubDivisionCode" => $this->client->state ?? '', "PostalCode" => $this->client->postal_code ?? '', "Country" => $this->client->country->iso_3166_3 ], "ShipAddr" => [ "Line1" => $this->client->shipping_address1 ?? '', "City" => $this->client->shipping_city ?? '', "CountrySubDivisionCode" => $this->client->shipping_state ?? '', "PostalCode" => $this->client->shipping_postal_code ?? '', "Country" => $this->client->shipping_country->iso_3166_3 ], "GivenName" => $this->client->present()->first_name(), "FamilyName" => $this->client->present()->last_name(), "PrintOnCheckName" => $this->client->present()->primary_contact_name(), "Notes" => $this->client->public_notes, // "TaxIdentifier" => $this->client->vat_number ?? '', // Federal Employer Identification Number (EIN) "BusinessNumber" => $this->client->id_number ?? '', "Active" => $this->client->deleted_at ? false : true, "V4IDPseudonym" => $this->client->client_hash, "WebAddr" => $this->client->website ?? '', ]; $customer = \QuickBooksOnline\API\Facades\Customer::create($customerData); // $customer = $qb->sdk->createCustomer($customerData); $this->assertNotNull($customer); nlog($customer); // Send the create request to QuickBooks $resultingCustomerObj = $qb->sdk->Add($customer); // Check for errors $error = $qb->sdk->getLastError(); if ($error) { $this->fail("The Customer could not be created: " . $error->getResponseBody()); } nlog($resultingCustomerObj); } // public function testCreateInvoiceInQb() // { // $c = Company::whereNotNull('quickbooks')->first(); // $qb = new QuickbooksService($c); // //create QB customer // //create ninja invoice // //create QB invoice // } public function stubData() { // Inside the create method $lineItems = [ [ "Amount" => 100.00, "DetailType" => "SalesItemLineDetail", "SalesItemLineDetail" => [ "ItemRef" => [ "value" => "1", // Replace with actual Item ID from QuickBooks "name" => "Services" ] ] ] ]; $invoiceData = [ "Line" => $lineItems, "CustomerRef" => [ "value" => "1", // Replace with actual Customer ID from QuickBooks ], "BillEmail" => [ "Address" => "customer@example.com" ], "DueDate" => "2023-12-31", "TotalAmt" => 100.00, "DocNumber" => "INV-001" ]; $invoice = QbInvoice::create($invoiceData); } }