function testPostTax()
 {
     global $getTaxRequest, $getTaxResult, $client, $postResult;
     //Post tax
     $postRequest = new PostTaxRequest();
     $postRequest->setCompanyCode($getTaxRequest->getCompanyCode());
     $postRequest->setDocId($getTaxResult->getDocId());
     $postRequest->setDocType($getTaxRequest->getDocType());
     $postRequest->setDocCode($getTaxRequest->getDocCode());
     $postRequest->setDocDate($getTaxRequest->getDocDate());
     $postRequest->setTotalAmount($getTaxResult->getTotalAmount());
     $postRequest->setTotalTax($getTaxResult->getTotalTax());
     $postResult = $client->postTax($postRequest);
     $this->assertEqual($getTaxResult->getDocId(), $postResult->getDocId());
     $this->assertEqual(SeverityLevel::$Success, $postResult->getResultCode());
 }
 public function tax($type, $params = array())
 {
     $this->_connectToAvalara();
     $client = new TaxServiceSoap(Configuration::get('AVALARATAX_MODE'));
     if ($type == 'commit') {
         $request = new CommitTaxRequest();
     } elseif ($type == 'post') {
         $request = new PostTaxRequest();
         $request->setDocDate($params['DocDate']);
         $request->setTotalAmount($params['TotalAmount']);
         $request->setTotalTax($params['TotalTax']);
     } elseif ($type == 'cancel') {
         $request = new CancelTaxRequest();
         if ($params['CancelCode'] == 'D') {
             $code = CancelCode::$DocDeleted;
         } elseif ($params['CancelCode'] == 'P') {
             $code = CancelCode::$PostFailed;
         } elseif ($params['CancelCode'] == 'V') {
             $code = CancelCode::$DocVoided;
         } else {
             die('Invalid cancel code.');
         }
         $request->setCancelCode($code);
     } elseif ($type == 'history') {
         $request = new GetTaxHistoryRequest();
         $request->setDetailLevel(DetailLevel::$Document);
     }
     if ($type != 'isAuthorized') {
         $request->setDocCode('Order ' . (int) $params['DocCode']);
         $request->setDocType(DocumentType::$SalesInvoice);
         $request->setCompanyCode(Configuration::get('AVALARATAX_COMPANY_CODE'));
     }
     $buffer = array();
     try {
         if ($type == 'commit') {
             $result = $client->commitTax($request);
         } elseif ($type == 'post') {
             $result = $client->postTax($request);
         } elseif ($type == 'cancel') {
             $result = $client->cancelTax($request);
         } elseif ($type == 'isAuthorized') {
             $result = $client->isAuthorized('GetTax');
         } elseif ($type == 'history') {
             $result = $client->getTaxHistory($request);
             $buffer['Invoice'] = $result->getGetTaxRequest()->getDocCode();
             $buffer['Status'] = $result->getGetTaxResult()->getDocStatus();
         }
         $buffer['ResultCode'] = $result->getResultCode();
         if ($result->getResultCode() != SeverityLevel::$Success) {
             foreach ($result->getMessages() as $msg) {
                 $buffer['Messages']['Name'] = Tools::safeOutput($msg->getName());
                 $buffer['Messages']['Summary'] = Tools::safeOutput($msg->getSummary());
             }
         }
     } catch (SoapFault $exception) {
         $buffer['Exception']['FaultString'] = Tools::safeOutput($exception->faultstring);
         $buffer['Exception']['LastRequest'] = Tools::safeOutput($client->__getLastRequest());
         $buffer['Exception']['LastResponse'] = Tools::safeOutput($client->__getLastResponse());
     }
     return $buffer;
 }
<?php

require '../../AvaTax4PHP/AvaTax.php';
// include in all Avalara Scripts
require '../Credentials.php';
// where service URL, account, license key are set
$STDIN = fopen('php://stdin', 'r');
$client = new TaxServiceSoap('Development');
$request = new PostTaxRequest();
$input = "bogus";
// Locate Document by Invoice Number
echo "Enter Invoice Number(Document Code): ";
$input = rtrim(fgets($STDIN));
$request->setDocCode($input);
$request->setDocDate($input);
$request->setDocType('SalesInvoice');
$request->setCompanyCode('DEFAULT');
//<Your Dashboard Company Code Here>');
echo "Enter Total Invoice Amount: ";
$input = rtrim(fgets($STDIN));
$request->setTotalAmount($input);
echo "Enter Total Invoice Tax: ";
$input = rtrim(fgets($STDIN));
$request->setTotalTax($input);
echo "Enter Doc Date (yyyy-mm-dd): ";
$input = rtrim(fgets($STDIN));
$request->setDocDate($input);
try {
    $result = $client->postTax($request);
    echo 'PostTax ResultCode is: ' . $result->getResultCode() . "\n";
    if ($result->getResultCode() != SeverityLevel::$Success) {