Search code examples
phpquickbooksquickbooks-online

Quickbooks Exceptions & Errors (How to tell what they are?)


I'm using the Quickbooks PHP SDK.

I'm currently trying to run a command below:

$res = $dataService->Add($customerObj);

I know the command is throwing an exception right now, but I can't tell what the exception is or how to tell what went wrong?

How do I do this?

Note:: I will figure out what is wrong with customerObj on my own to save you guys time, just need to figure out how to find out what the errors are that are being returned back to me.

Update:: Its an Ids Exception Error, but do not know what this means?

As Requested here is the rest of the code:

$requestValidator = new OAuthRequestValidator(              
                    gdizDecrypt($qbkeys->oauthtoken),
                    gdizDecrypt($qbkeys->oauthtokensecret), 
                    OAUTH_CONSUMER_KEY, 
                    OAUTH_CONSUMER_SECRET
                );

                $serviceContext     = new ServiceContext($qbkeys->realmid, $qbkeys->datasource, $requestValidator); 
                $dataService        = new DataService($serviceContext);

                $customerObj = new IPPCustomer(); 

                $customerObj->GivenName     = $client->contactfirstname.' '.$client->contactlastname;
                $customerObj->FamilyName    = $client->contactlastname;
                $customerObj->DisplayName   = $client->contactfirstname.' '.$client->contactlastname;   
                $customerObj->PreferredDeliveryMethod   = 'Print';
                $customerObj->BillWithParent            = 'false';
                if($client->active == '')
                {
                    $customerObj->Active                    = (bool)false;
                }
                else
                {
                    $customerObj->Active                    = 'true';
                }

                $phoneObj = new IPPTelephoneNumber();
                $phoneObj->FreeFormNumber = $client->contactphonenumber;

                $emailObj = new IPPEmailAddress();
                $emailObj->Address = $client->contactemail;

                $addrObj = new IPPPhysicalAddress();
                $addrObj->Line1 = $client->contactaddress;

                $customerObj->PrimaryPhone      = $phoneObj;
                $customerObj->PrimaryEmailAddr  = $emailObj;
                $customerObj->BillAddr          = $addrObj;

Solution

  • Ok I finally figured out the problem. After much hunting I found an article here.

    https://intuitdeveloper.lc.intuit.com/questions/1016393-checknullresponseandthrowexception-response-null-or-empty

    You need to modify your sdk.config file to the following XML

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <intuit>
        <ipp>
          <!--Json serialization not supported in PHP SDK v2.0.5 -->
          <message>
            <request serializationFormat="Xml" compressionFormat="None"/>
            <response serializationFormat="Xml" compressionFormat="None"/>
          </message>
          <service>
            <baseUrl qbd="https://sandbox-quickbooks.api.intuit.com/" qbo="https://sandbox-quickbooks.api.intuit.com/" ipp="https://appcenter.intuit.com/api/" />
          </service>
          <logger>
            <!-- To enable/disable Request and Response log-->
            <requestLog enableRequestResponseLogging="false" requestResponseLoggingDirectory="/IdsLogs" />
          </logger>
        </ipp>
      </intuit>
    </configuration>
    

    My code that worked before was on production, and if you are using development sandboxes which I was, you need to change the correct references.

    Hope this information helps someone.