2014-05-02 72 views
0

我正在使用quickbooks sdk連接快速在線帳戶。我可以連接一個像客戶和發票一樣的數據,而不會出現問題。但我無法使用sdk創建發票。這裏是我的代碼:quickbooks在線sdk創建發票

$token = unserialize($_SESSION['token']); 
    $requestValidator = new OAuthRequestValidator(
     $token['oauth_token'], $token['oauth_token_secret'], OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET); 
    $realmId = $_SESSION['realmId']; 
    $serviceType = $_SESSION['dataSource']; 
    $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); 

    $dataService = new DataService($serviceContext); 

    //create an invoice 
    $invoiceObj = new IPPInvoice(); 
    $invoiceObj->CustomerRef = 5; 
    $invoiceObj->Amount = 12.00; 
    $invoiceObj->DocNumber = 9999; 
    $invoiceObj->TaxnDate = "2014-05-01"; 
    $Line = new IPPline(); 
    $Line->DetailType ='SalesItemLineDetail'; 
    //$Line->Amount = 10; 
    $Line->setDescription = 'Test description goes here.'; 
    $saleItemLineDetail = new IPPSalesItemLineDetail(); 
    $saleItemLineDetail->ItemRef = 1; 
    $saleItemLineDetail->Quantity = 1; 
    $saleItemLineDetail->UnitPrice = 10.00; 
    $line->SalesItemLineDetail = $saleItemLineDetail; 
    $invoiceObj->Line = $line; 
    $resultingInvoiceObj = $dataService->Add($invoiceObj); 

當運行不創建此發票,我得到這個錯誤:

Fatal error: Uncaught IdsException: [0]: 2014-05-02 17:26:08 - /home/randy/test_apps/v3-php-sdk-2.0.4/DataService/DataService.php - 340 - CheckNullResponseAndThrowException - Response Null or Empty thrown in /home/randy/test_apps/v3-php-sdk-2.0.4/Core/CoreHelper.php on line 95 

我不認爲行數據得到正確添加。如何正確添加行數據或者是其他內容?

感謝

回答

0

你要通過客戶ID字符串如下

$invoiceObj->CustomerRef = 5; 

以下工作示例代碼

Sample Code