<?php
$apiID = '265C8E80';
$apiKey = 'D537CC92-8F71-4B08-91C7-B9602FE6988F';
// TaxCloud webservice
$tcURL = 'https://api.taxcloud.net/1.0/Taxcloud/';
$customerID = 9;
$cartItems = array(array('Index' => 0,
'ItemID' => '61',
'Price' => 123.00,
'Qty' => 1));
// set the cart id
$cartID = '15';
$origin = array('Address1' => '1437 Minnesota Ave',
'City' => 'Duluth',
'State' => 'MN',
'Zip5' => '55802');
$dest = array('Address1' => '1145 Amarillo Ave',
'City' => 'Palo Alto',
'State' => 'CA',
'Zip5' => '94303',);
$origin = array('Address1' => '333 place St.',
'City' => 'City',
'State' => 'AL',
'Zip5' => '36000');
$dest = array('Address1' => '111 someplace St.',
'City' => 'Seattle',
'State' => 'WA',
'Zip5' => '98101');
$exemptCert = null;
$ch = curl_init($tcURL.'Lookup');
$params = array('apiLoginID' => $apiID,
'apiKey' => $apiKey,
'customerID' => $customerID,
'cartID' => $cartID,
'cartItems' => $cartItems,
'origin' => $origin,
'destination' => $dest,
'deliveredBySeller' => FALSE,
'exemptCert' => $exemptCert);
curl_setopt_array($ch, array(CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
// Calculate sales tax for cart
CURLOPT_POSTFIELDS => json_encode($params)));
$response = (curl_exec($ch));
//var_dump($params);
$response = json_decode(curl_exec($ch));
//var_dump($response);
if($response->ResponseType == 0){
foreach($response->Messages as $message){
echo '<br>Error : '.$message->ResponseType.' - '.$message->Message;
} }else{
foreach($response->CartItemsResponse as $cartItem){
echo '<br>Cart Item '.$cartItem->CartItemIndex.' : Tax Amount
'.$cartItem->TaxAmount;
}
}
curl_close($ch);
preferences:
56.18 ms | 402 KiB | 5 Q