How to add item and items under category in Quickbooks online API || Sample code in Laravel PHP
-
Neel Bhardwaj
-
18-Jan-2022
-
0 comments
-
166
First create connection with quickbook online with oauth2
$dataService = DataService::Configure(array(
'auth_mode' => 'oauth2',
'ClientID' => '****************',
'ClientSecret' => ''****************',
//get the refresh token from session or database
'refreshTokenKey' => '****************',
'QBORealmID' => '****************',
'baseUrl' => "development/production"
));
$OAuth2LoginHelper = $dataService->getOAuth2LoginHelper();
$refreshedAccessTokenObj = $OAuth2LoginHelper->refreshToken();
$this->dataService->updateOAuth2Token($refreshedAccessTokenObj);
To get the new access token and refresh token
$accessToken = $refreshedAccessTokenObj->getAccessToken();
$refreshTokenValue = $refreshedAccessTokenObj->getRefreshToken();
For create item/Product and service under item category
$category_data = [
"SubItem" => false,
"Name" => 'Category Name',
"Type" => "Category",
"IncomeAccountRef"=> [
"value"=> 1
]
];$create_category = Item::create($category_data);
$categoryRequestObj = $this->dataService->Add($create_category);
Sample code For create item under category.
NOTE : In which define ParentRef is category ID and SubItem = true
$item_data = [
"SubItem" => true,
"Name" => 'Item Name',
"Type" => "Service",
"IncomeAccountRef"=> [
"value"=> 1
],
"ParentRef"=> $categoryRequestObj->Id
];$create_category = Item::create($item_data);
$this->dataService->Add($create_category);
"Programming isn't about what you know,
it's about what you can figure out.”
Leave a reply
Fatal error: Cannot declare class Connection, because the name is already in use in /home/d8ouyzxnuef4/public_html/thecoderjob.com/cj_admin/classes/Connection.php on line 3
Recent comments