You need to call taxcloud: If you are signed up for automated compliance, you should not be, being charged. 1-877-TAXCLOUD keep calling til you get someone.
Printable View
Ok so after the upgrade to 1.5.6 I was comparing my the Developer's Tool Kit logs between my live site and the test site and realized that there were entire parts of the module missing. So after backing up everything in the test site, I removed and reinstalled the Taxcloud 16b module. The store side works well but I am getting an issue in the admin area, I am looking at the log and I know there is something I am not understanding?
The log shows:
The file includes/classes/order.php on line 34 simply says:Code:
myDEBUG-adm-1545852159-733497.log ( ASCII text )
[26-Dec-2018 14:22:40 America/Detroit] Request URI: /webstore2/zcadmin/orders.php?oID=144&origin=index, IP address: 23.243.5.141
#1 require_once() called at [/home/sammirah/public_html/webstore2/includes/classes/order.php:34]
#2 include(/home/sammirah/public_html/webstore2/includes/classes/order.php) called at [/home/sammirah/public_html/webstore2/zcadmin/orders.php:32]
[26-Dec-2018 14:22:40 America/Detroit] PHP Warning: require_once(includes/modules/TaxCloud/func.taxcloud.php): failed to open stream: No such file or directory in /home/sammirah/public_html/webstore2/includes/classes/order.php on line 34
[26-Dec-2018 14:22:40 America/Detroit] PHP Fatal error: require_once(): Failed opening required 'includes/modules/TaxCloud/func.taxcloud.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/php56/lib/php') in /home/sammirah/public_html/webstore2/includes/classes/order.php on line 34
I think this means there is a missing phrase that makes the module do something but I have no idea how to write it to make it do what it is supposed to do, I appreciate any help with this please.Code:require_once DIR_WS_MODULES . 'TaxCloud/func.taxcloud.php';
it is complaining about a file not being there OR the file could have the incorrect ownership/permissions.
is the file:
/home/sammirah/public_html/webstore2/includes/modules/TaxCloud/func.taxcloud.php
there? and is the ownership and permissions similar to the other files in that directory?
Yes the file is thereHow do I determine the ownership and permissions?PHP Code:
<?php
/**
* TaxCloud v1.5
* @license https://taxcloud.net/ftpsl.pdf
*/
require("classes.php");
define('TAXCLOUD_VERSION', 'v1.5');
define('FILENAME_TAXCLOUD', 'taxcloud');
define('BOX_TAXES_TAXCLOUD', 'TaxCloud Tax Calculation');
function func_taxcloud_get_client() {
if ( isset($client) ) {
return $client;
} else {
$client = new SoapClient("https://api.taxcloud.net/1.0/TaxCloud.asmx?wsdl");
return $client;
}
}
function func_taxcloud_is_enabled($country_code='') {
if ($country_code != '223') {
return false;
}
$configuration_query = "select c.configuration_value from " . TABLE_CONFIGURATION . " c, " . TABLE_CONFIGURATION_GROUP . " cg where cg.configuration_group_title = 'TaxCloud Configuration Settings' and c.configuration_key = 'TAXCLOUD_ENABLED' and c.configuration_group_id = cg.configuration_group_id";
global $db;
$results = $db->Execute($configuration_query);
$isEnabled = $results->fields['configuration_value'];
return $isEnabled;
}
/**
* Verify an address using TaxCloud service
*/
function func_taxcloud_verify_address($address, &$err) {
global $client;
// Verify the address through the TaxCloud verify address service
$params = array( "uspsUserID" => TAXCLOUD_USPS_ID,
"address1" => $address->getAddress1(),
"address2" => $address->getAddress2(),
"city" => $address->getCity(),
"state" => $address->getState(),
"zip5" => $address->getZip5(),
"zip4" => $address->getZip4());
try {
$client = func_taxcloud_get_client();
$verifyaddressresponse = $client->verifyAddress( $params );
} catch (Exception $e) {
//retry in case of timeout
try {
$verifyaddressresponse = $client->verifyAddress( $params );
} catch (Exception $e) {
// $err[] = "Error encountered while verifying address ".$address->getAddress1().
// " ".$address->getState()." ".$address->getCity()." "." ".$address->getZip5().
// " ".$e->getMessage();
// //irreparable, return
return null;
}
}
if($verifyaddressresponse->{'VerifyAddressResult'}->ErrNumber == 0) {
// Use the verified address values
$address->setAddress1($verifyaddressresponse->{'VerifyAddressResult'}->Address1);
$address->setAddress2($verifyaddressresponse->{'VerifyAddressResult'}->Address2);
$address->setCity($verifyaddressresponse->{'VerifyAddressResult'}->City);
$address->setState($verifyaddressresponse->{'VerifyAddressResult'}->State);
$address->setZip5($verifyaddressresponse->{'VerifyAddressResult'}->Zip5);
$address->setZip4($verifyaddressresponse->{'VerifyAddressResult'}->Zip4);
} else {
// $err[] = "Error encountered while verifying address ".$address->getAddress1().
// " ".$address->getState()." ".$address->getCity()." "." ".$address->getZip5().
// " ".$verifyaddressresponse->{'VerifyAddressResult'}->ErrDescription;
return null;
}
return $address;
}
function func_taxcloud_get_customer_address($delivery) {
// Customer's address
$destination = new Address();
$destination->setAddress1($delivery['street_address']);
$destination->setAddress2('');
$destination->setCity($delivery['city']);
$destination->setState($delivery['state']); // Two character state appreviation
$destination->setZip5($delivery['postcode']);
$destination->setZip4('');
return $destination;
}
/**
* Get the store's location
*/
function func_taxcloud_get_company_address() {
$origin = new Address();
$origin->setAddress1(TAXCLOUD_STORE_ADDR);
$origin->setZip5(TAXCLOUD_STORE_ZIP);
return $origin;
}
/**
* Retrieves a product's TIC ID.
* @param $product_id
*/
function func_taxcloud_get_tic($product_id) {
global $db;
$query = "select tax_class_title from ".TABLE_PRODUCTS .", ".TABLE_TAX_CLASS." where products_tax_class_id = tax_class_id and products_id = ".$product_id;
$result = $db->Execute($query);
$tic = $result->fields['tax_class_title'];
$i = preg_match("/^(\d+)/", $tic);
if($i != 0)
return $tic;
else
return $i;
}
/**
* Look up tax cost using TaxCloud web services
* @param $product
* @param $customer
*/
function func_taxcloud_lookup_tax($products,$customerAddress,&$errMsg,$shipping, $exemptionCertificate) {
global $client;
$origin = func_taxcloud_get_company_address();
$origin = func_taxcloud_verify_address($origin, $errMsg);
if(is_null($origin)) return -1;
//Verify Customer's destination
$destination = func_taxcloud_get_customer_address($customerAddress);
$verified_destination = func_taxcloud_verify_address($destination, $errMsg);
if(!is_null($verified_destination)) {
$destination = $verified_destination;
}
if(!is_null($origin) && !is_null($destination)) {
$cartItems = Array();
$index = 0;
foreach ($products as $k => $product) {
$cartItem = new CartItem();
preg_match("/^(\d+)/", $product['id'], $match);
$cartItem->setItemID($match[0]);
$cartItem->setIndex($index); // Each cart item must have a unique index
$tic = func_taxcloud_get_tic($match[0]);
if(!$tic) {
//no TIC has been assigned to this product, use default
$tic = null;
}
$cartItem->setTIC($tic);
$price = $product['final_price'];
$cartItem->setPrice($price); // Price of each item
$cartItem->setQty($product['qty']); // Quantity
$cartItems[$index] = $cartItem;
$index++;
}
//Shipping as a cart item
$cartItem = new CartItem();
$cartItem->setItemID('shipping');
$cartItem->setIndex($index);
$cartItem->setTIC(11010);
$cartItem->setPrice($shipping);
$cartItem->setQty(1);
$cartItems[$index] = $cartItem;
$params = array( "apiLoginID" => TAXCLOUD_API_ID,
"apiKey" => TAXCLOUD_API_KEY,
"customerID" => $_SESSION['customer_id'],
"cartID" => $_SESSION['cartID'],
"cartItems" => $cartItems,
"origin" => $origin,
"destination" => $destination,
"deliveredBySeller" => false,
"exemptCert" => $exemptionCertificate
);
$client = func_taxcloud_get_client();
try {
$lookupResponse = $client->lookup( $params );
} catch (Exception $e) {
//retry
try {
$lookupResponse = $client->lookup( $params );
} catch (Exception $e) {
$errMsg[] = "Error encountered looking up tax amount ".$e->getMessage();
//irreparable, return
return -1;
}
}
$lookupResult = $lookupResponse->{'LookupResult'};
if($lookupResult->ResponseType == 'OK' || $lookupResult->ResponseType == 'Informational') {
$cartItemsResponse = $lookupResult->{'CartItemsResponse'};
$cartItemResponse = $cartItemsResponse->{'CartItemResponse'};
$taxes = Array();
$index = 0;
//response may be an array
if ( is_array($cartItemResponse) ) {
foreach ($cartItemResponse as $c) {
$amount = ($c->TaxAmount);
$taxes[$index] = $amount;
$index++;
}
} else {
$amount = ($cartItemResponse->TaxAmount);
$taxes[0] = $amount;
}
$cartID = $lookupResult->CartID;
if ( isset($cartID) ) {
$_SESSION['cartID'] = $cartID;
}
$taxTotal = 0;
//Calculate tax totals
foreach( $taxes as $tax ) {
$taxTotal = $taxTotal + round($tax,2);
}
$_SESSION['taxcloudTaxTotal'] = $taxTotal;
return array('name' => 'Sales Tax', 'tax' => $taxTotal);
} else {
$errMsgs = $lookupResult->{'Messages'};
foreach($errMsgs as $err) {
$errMsg[] = "Error encountered looking up tax amount ".$err->{'Message'};
}
return -1;
}
} else {
return -1;
}
}
/**
* Authorized with Capture
* @param $orderID
*/
function func_taxcloud_authorized_with_capture($orderID, &$errMsg) {
global $client;
$result = 0;
$dup = "This purchase has already been marked as authorized";
// Current date - example of format: '2010-09-08T00:00:00';
$dateAuthorized = date("Y-m-d");
$dateAuthorized = $dateAuthorized . "T00:00:00";
$params = array( "apiLoginID" => TAXCLOUD_API_ID,
"apiKey" => TAXCLOUD_API_KEY,
"customerID" => $_SESSION['customer_id'],
"cartID" => $_SESSION['cartID'],
"orderID" => $orderID,
"dateAuthorized" => $dateAuthorized,
"dateCaptured" => $dateAuthorized);
$client = func_taxcloud_get_client();
// The authorizedResponse array contains the response verification (Error, OK, ...)
$authorizedResponse = null;
try {
$authorizedResponse = $client->authorizedWithCapture( $params );
} catch (Exception $e) {
//infrastructure error, try again
try {
$authorizedResponse = $client->authorizedWithCapture( $params );
$authorizedResult = $authorizedResponse->{'AuthorizedWithCaptureResult'};
if ($authorizedResult->ResponseType != 'OK') {
$msgs = $authorizedResult->{'Messages'};
$respMsg = $msgs->{'ResponseMessage'};
//duplicate means the the previous called was good. Therefore, consider this to be good
if (trim ($respMsg->Message) == $dup) {
return 1;
}
} else if ($authorizedResult->ResponseType == 'Error') {
$msgs = $authorizedResult->{'Messages'};
$respMsg = $msgs->{'ResponseMessage'};
//duplicate means the the previous called was good. Therefore, consider this to be good
if (trim ($respMsg->Message) == $dup) {
return 1;
} else {
$errMsg[] = "Error encountered looking up tax amount ".$respMsg;
return -1;
}
} else {
return -1;
}
} catch (Exception $e) {
//give up
$errMsg[] = $e->getMessage();
return 0;
}
}
$authorizedResult = $authorizedResponse->{'AuthorizedWithCaptureResult'};
if ($authorizedResult->ResponseType == 'OK') {
$_SESSION['singlePurchase'] = null; //one-time certificate
$_SESSION['selectedCertID'] = null; //saved certificate
// $_SESSION['taxcloudTaxTotal'] = null;
return 1;
} else {
$msgs = $authorizedResult->{'Messages'};
$respMsg = $msgs->{'ResponseMessage'};
$errMsg [] = $respMsg->Message;
return 0;
}
return $result;
}
function func_taxcloud_add_exemption_certificate($exemptionCertificate,$customerID) {
global $client;
$params = array( "apiLoginID" => TAXCLOUD_API_ID,
"apiKey" => TAXCLOUD_API_KEY,
"customerID" => $customerID,
"exemptCert" => $exemptionCertificate
);
try {
$client = func_taxcloud_get_client();
$addExemptionResponse = $client->addExemptCertificate( $params );
} catch (Exception $e) {
return -1;
}
}
function func_taxcloud_get_exemption_certificates($customerID) {
global $client;
$params = array( "apiLoginID" => TAXCLOUD_API_ID,
"apiKey" => TAXCLOUD_API_KEY,
"customerID" => $customerID
);
try {
$client = func_taxcloud_get_client();
$getExemptCertificatesResponse = $client->getExemptCertificates( $params );
$getCertificatesRsp = $getExemptCertificatesResponse->{'GetExemptCertificatesResult'};
$exemptCertificatesArray = $getCertificatesRsp->{'ExemptCertificates'};
$exemptCertificates = $exemptCertificatesArray->{'ExemptionCertificate'};
if (is_array($exemptCertificates)) {
return $exemptCertificates;
} else {
return $exemptCertificatesArray;
}
} catch (Exception $e) {
return Array();
}
return Array();
}
function func_taxcloud_delete_exemption_certificate($certID) {
global $client;
$params = array(
"apiLoginID" => TAXCLOUD_API_ID,
"apiKey" => TAXCLOUD_API_KEY,
"certificateID" => $certID
);
try {
$client = func_taxcloud_get_client();
$deleteExemptCertificateResponse = $client->deleteExemptCertificate( $params );
} catch (Exception $e) {
return -1;
}
}
function func_taxcloud_return_order($order_id) {
global $client;
global $db;
$results = $db->Execute("select products_id, products_quantity, final_price
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "'");
$cartItems = Array();
$index = 0;
while ( !$results->EOF ) {
$fields = $results->fields;
$cartItem = new CartItem();
$cartItem->setItemID($fields['products_id']);
$cartItem->setIndex($index);
$cartItem->setTIC(func_taxcloud_get_tic($fields['products_id']));
$cartItem->setPrice($fields['final_price']);
$cartItem->setQty($fields['products_quantity']);
$cartItems[$index] = $cartItem;
$index++;
$results->MoveNext();
}
//Reverse the order shipping
$results = $db->Execute("select value
from " . TABLE_ORDERS_TOTAL . "
where orders_id = '" . (int)$order_id . "'
and class = 'ot_shipping'");
while ( !$results->EOF ) {
$fields = $results->fields;
//Shipping as a cart item
$cartItem = new CartItem();
$cartItem->setItemID('shipping');
$cartItem->setIndex($index);
$cartItem->setTIC(11010);
$cartItem->setPrice($fields['value']);
$cartItem->setQty(1);
$cartItems[$index] = $cartItem;
$index++;
$results->MoveNext();
}
$returnDate = date("Y-m-d");
$returnDate = $returnDate . "T00:00:00";
$params = array(
"apiLoginID" => TAXCLOUD_API_ID,
"apiKey" => TAXCLOUD_API_KEY,
"orderID" => $order_id,
"cartItems" => $cartItems,
"returnedDate" => $returnDate);
try {
$client = func_taxcloud_get_client();
$returnResponse = $client->Returned($params);
} catch (Exception $e) {
return -1;
}
}
?>
most ftp clients should show the permissions as well as the owner and group. you can try right clicking the filename from within the ftp client that you are using to possibly access the data. its not too hard to see, but you need to look.
i'm thinking that most of these should be 644; but the proper owner/group combo is something that your host can help you with. else you should compare it to other files in a similar tree, ie:
includes/modules/order_total/ot_total.php
as this looks to be a new directory, you would also need to check the ownership/permissions of
includes/modules/TaxCloud
i find it highly unlikely that line 34 of includes/classes/order.php is incorrect; as i see that line as part of the download, but we could look at changing that line as a last resort. it is more likely a permissions issue.
again, you can ask your host if the permissions are correct for this file. depending on the host, they may be able to help you.
best.
So, I found out that the permissions were correct 640. Unfortunately I am going to have to let go of this module. I really like taxcloud as it makes my tax collection and filings easier. So I deleted all of the files and replaced the core files with copies from a fresh ZC 1.5.6 installation. Everything is back to normal.
I guess I am just not cut out for all the extra stuff anymore, code makes my head hurt, and I have a small business to run so my time is limited more than ever now.
Oddly TaxCloud 16b installed once on a clean Zen Cart 1.55f but only recorded the first configuration setting - 'TaxCloud Configuration Settings'.
That resulted in the lookup code for the other configuration settings to fail to fire.
There was no error message but the problem behaviour was that I could enter in all of my TaxCloud data in Admin > Locations/Taxes > TaxCloud Tax Calculation
and...
It would 'update' and show the data again on-screen - but the data wouldn't commit to the database and TaxCloud Enabled would remain 'false'.
Reload the page and it would all be blank again.
Because the code could see - 'TaxCloud Configuration Settings' it failed to load these tables into the db:
'TaxCloud API ID', 'TaxCloud API Key', 'USPS_ID', 'Store Street Address', 'Store Zip Code', 'TaxCloud Enabled'
The Fix:
- Remove all entries of TaxCloud in the configuration and configuration_group
- Log into Zen Admin
- Navigate to Admin > Locations/Taxes > TaxCloud Tax Calculation
- Enter Data
Success!
The code then fires correctly and installs the tables correctly.
I've installed a lot of modules over the years and occasionally 'removing and reinstalling' the files doesn't work and some modules do not have SQL database removal codes - in this case manually removing everything from the SQL database and reinstalling it DID work.
Important to note that the TaxCloud 16b fileset was intact, complete and merged properly on the server and - remains intact.
Problem - TaxCloud is using full names for state zones, Zen is using 2 digits.
Zen posted this on-screen error in checkout_payment page during checkout:
Error encountered looking up tax amount The Ship To zip code (89128) is not valid for this state (Ne)
The fix:
This works and was a necessary update after install and testing failed to load the 2 digit state codes correctly out of the TaxCloud 16b box:
https://www.zen-cart.com/showthread....03#post1343603
I am catching my 2nd wind on this mod. :laugh: It truly pisses me off every time it comes times to upgrade Zen Cart...I had to go back to zc 1.5.5f when I ran into issues with one of the most vital plug-ins used on my site. Anyhow, I digress, I keep noticing that the admin//includes/auto_loaders/config.taxcloud.php keeps disappearing. I upload it again, leave that area of cPanel and when I come back it is just gone. But the plug in is working fine. Is there a reason why a file would just disappear like that?Quote:
Important to note that the TaxCloud 16b fileset was intact, complete and merged properly on the server and - remains intact.
This cute little code:
// Now that the menu item has been created/registered, can stop the wasteful process of having
// this script run again by removing it from the auto-loader array
@unlink(DIR_FS_ADMIN . DIR_WS_INCLUDES . 'auto_loaders/config.taxcloud.php');
in YOUR_ADMIN/includes/init_includes/init_taxcloud_config.php
The interweb says this:
unlink
(PHP 4, PHP 5, PHP 7)
unlink — Deletes a file
It prevents the installer from looping or installing every time you load an admin page.
Though it may not help with site upgrades... it should be included in the newest source module/plugin files always (if we continue to code it in this manner).