2017 © Pedro Peláez
 

yii2-extension yii2-quickbooks

quickbooks online oauth2 and API wrapper for Yii2

image

omcrn/yii2-quickbooks

quickbooks online oauth2 and API wrapper for Yii2

  • Friday, December 15, 2017
  • by arboshiki
  • Repository
  • 1 Watchers
  • 0 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 9 % Grown

The README.md

Yii2 Extension for Quickbooks

quickbooks online oauth2 and API wrapper for Yii2, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist omcrn/yii2-quickbooks "*"

or add, (*4)

"omcrn/yii2-quickbooks": "*"

to the require section of your composer.json file., (*5)

Usage

Save the following values in .env file:, (*6)

QB_BASE_URL                 = https://quickbooks.api.intuit.com/
QB_DISCOVERY_DOCUMENT       = https://developer.intuit.com/.well-known/openid_sandbox_configuration/
QB_CLIENT_ID                = ****************************************
QB_CLIENT_SECRET            = ****************************************
QB_OAUTH_SCOPE              = com.intuit.quickbooks.accounting
QB_REALM_ID                 = ****************************************

You must have Yii::$app->keyStorage configured, because the extension uses KeyStorage to save quickbooks authorization tokens. Also you need to save your redirect-url in KeyStorage as a key quickbooks.redirect-url, (*7)

Now you can initialize the extensions like this:, (*8)

$qb = new Quickbooks([
   'authMode' => "oauth2",
   'clientId' => getenv("QB_CLIENT_ID"),
   'clientSecret' => getenv("QB_CLIENT_SECRET"),
   'baseUrl' => getenv("QB_BASE_URL"),
   'realmId' => getenv("QB_REALM_ID"),
   'discoveryDocumentUrl' => getenv("QB_DISCOVERY_DOCUMENT"),
   'oauthScope' => getenv("QB_OAUTH_SCOPE")
]);

Implement the 'Connect to Quickbooks' button as in Intuit's Docs:, (*9)

https://developer.intuit.com/docs/00_quickbooks_online/2_build/10_authentication_and_authorization/40_oauth_1.0a/widgets

Basically you need to include their .js file and run the following script:, (*10)

intuit.ipp.anywhere.setup({
    grantUrl: '/redirect-url', //the one you saved in KeyStorage
    datasources: {
        quickbooks : true,
        payments : true
    },
    paymentOptions:{
        intuitReferred : true
    }
});

You need to implement your redirect-url handler action, initialize Quickbooks extension there and call the connect method:, (*11)

$qb->connect();

Now you need to click that button, to obtain auth tokens. Tokens are automatically refreshed each request, so this is one time operation., (*12)

When the configuration is done, you can create your custom action, initialize the extension there and call required methods, e.g. for creating a customer you can do the following in your action:, (*13)

$newCustomer = $qb->createCustomer([
   "BillAddr" => [
       "Line1" => $address->address,
       "Line2" => $address->address2,
       "City" => $address->town,
       "Country" => $address->country->name,
       "CountrySubDivisionCode" => $address->country->iso_code_2,
       "PostalCode" => $address->postcode
   ],
   "Notes" => $notes,
   "Title" => $title,
   "GivenName" => $name,
   "MiddleName" => "",
   "FamilyName" => $surname,
   "Suffix" => $suffix,
   "FullyQualifiedName" => $this->name . " " . $this->surname,
   "CompanyName" => $companyName,
   "DisplayName" => $displayName,
   "PrimaryPhone" => [
       "FreeFormNumber" => $mobile
   ],
   "PrimaryEmailAddr" => [
       "Address" => $email
   ]
]);

The Versions

15/12 2017

dev-master

9999999-dev

quickbooks online oauth2 and API wrapper for Yii2

  Sources   Download

MIT

The Requires

 

yii2 extension quickbooks

10/12 2017

0.0.3

0.0.3.0

quickbooks online oauth2 and API wrapper for Yii2

  Sources   Download

MIT

The Requires

 

yii2 extension quickbooks

21/11 2017

0.0.2

0.0.2.0

quickbooks online oauth2 and API wrapper for Yii2

  Sources   Download

MIT

The Requires

 

yii2 extension quickbooks

13/11 2017

v0.0.1

0.0.1.0

quickbooks online oauth2 and API wrapper for Yii2

  Sources   Download

MIT

The Requires

 

yii2 extension quickbooks