View file File name : CourierServiceTest.php Content :<?php class CourierService extends Courrier { //Configuration const AccessLicenseNumber = "ED58E56438B88ECC"; const UserID = "MyValue365"; const Password = "hPawha365"; const Operation = "ProcessRate"; const EndPointTracking="https://wwwcie.ups.com/rest/Track"; /* * Production */ //const EndPointURL = 'https://wwwcie.ups.com/rest/Rate'; //const EndPointShippingURL = 'https://onlinetools.ups.com/rest/Ship'; /* * Test */ const EndPointURL = 'https://wwwcie.ups.com/rest/Rate'; //const EndPointURL = 'https://onlinetools.ups.com/rest/Track'; const EndPointShippingURL = 'https://wwwcie.ups.com/ship/v1807/shipments?additionaladdressvalidation=city'; const EndPointUrlTimeInTransit= "https://onlinetools.ups.com/rest/TimeInTransit"; private $DBObject; public function __construct(&$obj) { /** * ounce, pound, gram **/ // print_r($obj); //echo 'asdasd'; $this->DBObject=$obj; $this->setRequestOption("Rate"); $this->setPickupTypeCode("01"); $this->setPickupTypeDescription("Daily Pickup"); $this->setCustomerClassificationCode("01"); $this->setCustomerClassificationDescription("Classfication"); $this->setValidateAddress('no_validation'); /** * Shipper Address */ $this->setShipperNumber("222006"); $this->setShipperName("MyValue365"); $this->setShipperCity("Chicago"); $this->setShipperCountryCode("US"); $this->setShipperStateProvinceCode("IL"); $this->setShipperPostalCode("60610"); $this->setShipperAddressLine("1400 N Lakeshore Drive"); //small medium large $this->setDimensionsUnit("inches"); $this->setDimensionsUnitCode("IN"); $this->setServiceCode("03"); $this->setServiceDesciption("UPS Ground"); $this->setUnit("pounds"); $this->setUnitCode("Lbs"); $this->setPackagingCode("02"); $this->setPackagingDescription("Package"); } public function getRates() { try { $this->ValidateRequest(); if ($this->getCarrier() === 'UPS') { $jsonData = $this->BuildRateRequest(); $header = array( 'Content-type: application/json', 'Content-Length: ' . strlen($jsonData) ); $carrierResponse = $this->CurlRquest($this::EndPointURL, $jsonData, $header); $carrierResponse_array = (json_decode($carrierResponse, true)); $status = false; if (isset($carrierResponse_array['RateResponse']['Response']['ResponseStatus']['Description']) && $carrierResponse_array['RateResponse']['Response']['ResponseStatus']['Description'] == 'Success') $status = true; echo json_encode(Array( 'Status' => array( "result" => $status, "message" => '', "CarrierResponse" => json_decode($carrierResponse) ) )); } } catch (Exception $ex) { $this->setError($ex->getMessage()); } } public function getShippingLabel() { try { $this->ValidateRequest(); if ($this->getCarrier() === 'UPS') { $jsonData = $this->BuildLabelRequest(); $jsonDataBase64= base64_encode($jsonData); // echo "select * from tbl_order where id='".$this->getOrderNumber()."'"; //print_r($this->DBObject); $query="select * from tbl_order_label where order_id='".$this->getOrderNumber()."' and label_parameters='".$jsonDataBase64."' and status='Active'"; $sql = $this->DBObject->query($query); $result = $this->DBObject->fetchNextObject($sql); if(isset($result->id) and $result->id>0 ){ $carrierResponse_array['Status']['CarrierResponse']['ShipmentResponse']['ShipmentResults']['PackageResults']['ShippingLabel']['GraphicImage']=$result->label_file; $carrierResponse_array['Status']['CarrierResponse']['ShipmentResponse']['ShipmentResults']['PackageResults']['TrackingNumber']=$result->label; //$trackingNo = $label->Status->CarrierResponse->ShipmentResponse->ShipmentResults->PackageResults->TrackingNumber; // $print_label = '<img src="data:image/png;base64,' . $label->Status->CarrierResponse->ShipmentResponse->ShipmentResults->PackageResults->ShippingLabel->GraphicImage . '"/>'; //print_r($carrierResponse_array); return json_encode($carrierResponse_array); exit; } //print_r($result); //exit; //echo $jsonData ; // exit; $header = array( 'AccessLicenseNumber: '.$this::AccessLicenseNumber, 'Password: '. $this::Password, 'transId: Transaction123', 'transactionSrc: GG', 'Username: '. $this::UserID, 'Content-type: application/json', 'Content-Length: ' . strlen($jsonData) ); $carrierResponse = $this->CurlRquest($this::EndPointShippingURL, $jsonData, $header); // print_r($carrierResponse); $carrierResponse_array = (json_decode($carrierResponse, true)); $status = false; if (isset($carrierResponse_array['ShipmentResponse']['Response']['ResponseStatus']['Description']) && $carrierResponse_array['ShipmentResponse']['Response']['ResponseStatus']['Description'] == 'Success'){ $status = true; //echo '<pre>'; // print_r($carrierResponse_array['ShipmentResponse']['ShipmentResults']['PackageResults']['ShippingLabel']['GraphicImage']); $GraphicImage=$carrierResponse_array['ShipmentResponse']['ShipmentResults']['PackageResults']['ShippingLabel']['GraphicImage'] ; $TrackingNumber=$carrierResponse_array['ShipmentResponse']['ShipmentResults']['PackageResults']['TrackingNumber'] ; $updateQuery="update tbl_order_label set status='InActive' where order_id='".$this->getOrderNumber()."'"; $this->DBObject->query($updateQuery); $insertQuery="insert into tbl_order_label set order_id='".$this->getOrderNumber()."',label_parameters='".$jsonDataBase64."',label_file='".$GraphicImage."',label='".$TrackingNumber."'"; $this->DBObject->query($insertQuery); } return json_encode(Array( 'Status' => array( "result" => $status, "message" => '', "CarrierResponse" => json_decode($carrierResponse) ) )); } } catch (Exception $ex) { $this->setError($ex->getMessage()); } } function getEstimateDeliveryDate($estmateDArray) { $bodyContent = array( "Security" => array( "UsernameToken" => array( "Username" => $this::UserID, "Password" => $this::Password ), "UPSServiceAccessToken" => array( "AccessLicenseNumber" => $this::AccessLicenseNumber ) ), "TimeInTransitRequest" => array( "Request" => array( "RequestOption" => 'TNT', "TransactionReference" => array( "CustomerContext" => "Test 002" ) ), "ShipFrom" => array( "Address" => array( "StateProvinceCode" => $estmateDArray['StateProvinceCodeShipper'], "CountryCode" => $estmateDArray['CountryCodeShipper'], "PostalCode" => $estmateDArray['PostalCodeShipper'] ) ), "ShipTo" => array( "Address" => array( "StateProvinceCode" => $estmateDArray['StateProvinceCodeShipTo'], "CountryCode" => $estmateDArray['CountryCodeShipTo'], "PostalCode" => $estmateDArray['PostalCodeShipTo'] ) ), "Pickup" => array( "Date" => $estmateDArray['PickupDate'], "Time" => "120221" ), "ShipmentWeight" => array( "UnitOfMeasurement" => array( "Code" => $estmateDArray['UnitOfMeasurement'], "Description" => "Description" ), "Weight" => $estmateDArray['Weight'] ), "MaximumListSize" => '50' ) ); $params = json_encode($bodyContent); //print_r($params); $headers = array(); $headers[] = 'Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'; $headers[] = 'Access-Control-Allow-Methods: POST'; $headers[] = 'Access-Control-Allow-Origin: *'; $headers[] = 'Content-Type: application/json'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 45); curl_setopt($ch, CURLOPT_URL, $this::EndPointUrlTimeInTransit ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $response = curl_exec($ch); // CHECK TO SEE IF WE GOT AN ERROR // IF SO, FORMAT IT LIKE THIS ::28::Operation timed out afterseconds if ((curl_errno($ch)) && (curl_errno($ch) != 0)) { $response = "::" . curl_errno($ch) . "::" . curl_error($ch); } //echo '<pre>'; $responseJson = json_decode($response); //print_r(json_decode($response)); if (isset($responseJson->Fault)) { // echo 'Error'; } else { if (isset($responseJson->TimeInTransitResponse->Response->ResponseStatus)) { if ($responseJson->TimeInTransitResponse->Response->ResponseStatus->Code == '1' && $responseJson->TimeInTransitResponse->Response->ResponseStatus->Description == 'Success') { //print_r($responseJson); if (isset($responseJson->TimeInTransitResponse->TransitResponse->ServiceSummary)) { foreach ($responseJson->TimeInTransitResponse->TransitResponse->ServiceSummary as $Summary) { // print_r($Summary->Service->Description); if (isset($Summary->Service->Description) && strtoupper($Summary->Service->Description) == strtoupper($estmateDArray['ServiceDescription'])) { //echo $estmateDArray['ServiceDescription']; return $Summary->EstimatedArrival->Arrival->Date; } } } } } } } public function getTrackingDetail() { $query="select * from tbl_order_label where label='".$this->getTrackingNumber()."'"; $sql = $this->DBObject->query($query); $result = $this->DBObject->fetchNextObject($sql); if(isset($result->delivery_date) and $result->delivery_date!=''){ $originalDate = $result->delivery_date; $delivery_date = date("d/m/Y", strtotime($originalDate)); echo json_encode(array('PickupDate' => '', 'Delivery' => array('Status' => '0', 'Date' =>$delivery_date, 'Description' => 'DELIVERED'))); exit; } // echo 'Start'; $PostalCodeShipper = $StateProvinceCodeShipper = $CountryCodeShipper = $PostalCodeShipTo = $StateProvinceCodeShipTo = $CountryCodeShipTo = ''; $UnitOfMeasurement = $Weight = $ServiceCode = $ServiceDescription = $PickupDate = $EstimateDeliveryDate = $DeliveryDate = $DeliveryDescription = ''; $DeliveredToCustomer = '0'; try { $bodyContent = array( "Security" => array( "UsernameToken" => array( "Username" => $this::UserID, "Password" => $this::Password ), "UPSServiceAccessToken" => array( "AccessLicenseNumber" => $this::AccessLicenseNumber ) ), "TrackRequest" => array( "Request" => array( "RequestOption" => 1, "TransactionReference" => array( "CustomerContext" => "Test 002" ) ), "InquiryNumber" => $this->getTrackingNumber() ) ); $params = json_encode($bodyContent); // echo $params; $headers = array(); $headers[] = 'Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'; $headers[] = 'Access-Control-Allow-Methods: POST'; $headers[] = 'Access-Control-Allow-Origin: *'; $headers[] = 'Content-Type: application/json'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 45); curl_setopt($ch, CURLOPT_URL, self::EndPointTracking); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $response = curl_exec($ch); // print_r($response); if ((curl_errno($ch)) && (curl_errno($ch) != 0)) { echo json_encode(array('PickupDate' => $PickupDate, 'Delivery' => array('Status' => $DeliveredToCustomer, 'Date' => $DeliveryDate, 'Description' => $DeliveryDescription))); // echo 'Error'; exit; } $responseJson = json_decode($response); if (isset($responseJson->Fault)) { echo json_encode(array('PickupDate' => $PickupDate, 'Delivery' => array('Status' => $DeliveredToCustomer, 'Date' => $DeliveryDate, 'Description' => $DeliveryDescription))); // echo 'Error'; exit; } else { if (isset($responseJson->TrackResponse->Response->ResponseStatus)) { if ($responseJson->TrackResponse->Response->ResponseStatus->Code == '1' && $responseJson->TrackResponse->Response->ResponseStatus->Description == 'Success') { if ($responseJson->TrackResponse->Shipment->ShipmentAddress[0]->Type->Code == '01' && $responseJson->TrackResponse->Shipment->ShipmentAddress[0]->Type->Description == 'Shipper Address') { $PostalCodeShipper = $responseJson->TrackResponse->Shipment->ShipmentAddress[0]->Address->PostalCode; $StateProvinceCodeShipper = $responseJson->TrackResponse->Shipment->ShipmentAddress[0]->Address->StateProvinceCode; $CountryCodeShipper = $responseJson->TrackResponse->Shipment->ShipmentAddress[0]->Address->CountryCode; } if ($responseJson->TrackResponse->Shipment->ShipmentAddress[1]->Type->Code == '02' && $responseJson->TrackResponse->Shipment->ShipmentAddress[1]->Type->Description == 'ShipTo Address') { $PostalCodeShipTo = $responseJson->TrackResponse->Shipment->ShipmentAddress[1]->Address->PostalCode; $StateProvinceCodeShipTo = $responseJson->TrackResponse->Shipment->ShipmentAddress[1]->Address->StateProvinceCode; $CountryCodeShipTo = $responseJson->TrackResponse->Shipment->ShipmentAddress[1]->Address->CountryCode; } if ($responseJson->TrackResponse->Shipment->ShipmentWeight) { $UnitOfMeasurement = $responseJson->TrackResponse->Shipment->ShipmentWeight->UnitOfMeasurement->Code; $Weight = $responseJson->TrackResponse->Shipment->ShipmentWeight->Weight; } if ($responseJson->TrackResponse->Shipment->Service) { $ServiceCode = $responseJson->TrackResponse->Shipment->Service->Code; $ServiceDescription = $responseJson->TrackResponse->Shipment->Service->Description; } if ($responseJson->TrackResponse->Shipment->PickupDate) { $PDate = $responseJson->TrackResponse->Shipment->PickupDate; $PickupDate = $PDate; } //print_r($response); if (isset($responseJson->TrackResponse->Shipment->Package->Activity)) { foreach ($responseJson->TrackResponse->Shipment->Package->Activity as $activity) { // print_r($activity); if (isset($activity->Status->Type) && $activity->Status->Type == 'D') { $DeliveryDate = $activity->Date; $DeliveryDescription = $activity->Status->Description; if ($activity->Status->Code == 'KB' || $activity->Status->Code == 'KM' || $activity->Status->Code == '2W' || $activity->Status->Code == 'F4') $DeliveredToCustomer = '1'; if ($activity->Status->Code == 'ZP' || $activity->Status->Code == 'LZ' || $activity->Status->Code == 'S7' || $activity->Status->Code == 'VE' || $activity->Status->Code == 'VF' || $activity->Status->Code == '5E' || $activity->Status->Code == '6B' || $activity->Status->Code == '5R') $DeliveredToCustomer = '2'; } elseif (isset($activity->Status->Type) && $activity->Status->Type == 'X') { if ($activity->Status->Code == '5R') { $DeliveredToCustomer = '2'; $DeliveryDate = $activity->Date; $DeliveryDescription = $activity->Status->Description; } } } } if ($DeliveryDate == '') { if (isset($responseJson->TrackResponse->Shipment->DeliveryDetail->Type->Code) && $responseJson->TrackResponse->Shipment->DeliveryDetail->Type->Code == "03") { $EstimateDeliveryDate = $responseJson->TrackResponse->Shipment->DeliveryDetail->Date; } if (isset($responseJson->TrackResponse->Shipment->Package->DeliveryDetail->Type->Code) && $responseJson->TrackResponse->Shipment->Package->DeliveryDetail->Type->Code == "04") { $EstimateDeliveryDate = $responseJson->TrackResponse->Shipment->Package->DeliveryDetail->Date; } if ($EstimateDeliveryDate == '') { $estmateDArray = array('PostalCodeShipper' => $PostalCodeShipper, 'StateProvinceCodeShipper' => $StateProvinceCodeShipper, 'CountryCodeShipper' => $CountryCodeShipper, 'PostalCodeShipTo' => $PostalCodeShipTo, 'StateProvinceCodeShipTo' => $StateProvinceCodeShipTo, 'CountryCodeShipTo' => $CountryCodeShipTo , 'UnitOfMeasurement' => $UnitOfMeasurement, 'Weight' => $Weight , 'ServiceCode' => $ServiceCode, 'ServiceDescription' => $ServiceDescription, 'PickupDate' => $PickupDate); $EstimateDeliveryDate = $this->getEstimateDeliveryDate($estmateDArray); } } } } } if ($EstimateDeliveryDate != ''){ $EstimateDeliveryDate1 =substr($EstimateDeliveryDate, 0, 4) . '/' . substr($EstimateDeliveryDate, 4, 2) . '/' . substr($EstimateDeliveryDate, 6, 2); $EstimateDeliveryDate = substr($EstimateDeliveryDate, 4, 2) . '/' . substr($EstimateDeliveryDate, 6, 2) . '/' . substr($EstimateDeliveryDate, 0, 4); $updateQuery="update tbl_order_label set estimate_delivery_date='".$EstimateDeliveryDate1."' where label='".$this->getTrackingNumber()."'"; $this->DBObject->query($updateQuery); } if ($PickupDate != '') { $PickupDate1 =substr($PickupDate, 0, 4) . '/' . substr($PickupDate, 4, 2) . '/' . substr($PickupDate, 6, 2); $PickupDate = substr($PickupDate, 4, 2) . '/' . substr($PickupDate, 6, 2) . '/' . substr($PickupDate, 0, 4); $updateQuery="update tbl_order_label set pick_up_date='".$PickupDate1."' where label='".$this->getTrackingNumber()."'"; $this->DBObject->query($updateQuery); } if ($DeliveryDate != '') { $DeliveryDate1 =substr($DeliveryDate, 0, 4) . '/' . substr($DeliveryDate, 4, 2) . '/' . substr($DeliveryDate, 6, 2); $DeliveryDate = substr($DeliveryDate, 4, 2) . '/' . substr($DeliveryDate, 6, 2) . '/' . substr($DeliveryDate, 0, 4); $updateQuery="update tbl_order_label set delivery_date='".$DeliveryDate1."' where label='".$this->getTrackingNumber()."'"; $this->DBObject->query($updateQuery); } if ($DeliveredToCustomer == '0' && $DeliveryDate == '') $DeliveryDate = $EstimateDeliveryDate; echo json_encode(array('PickupDate' => $PickupDate, 'Delivery' => array('Status' => $DeliveredToCustomer, 'Date' => $DeliveryDate, 'Description' => $DeliveryDescription))); exit; } catch (Exception $ex) { //echo $ex->getMessage(); $this->setError($ex->getMessage()); } } public function getZone(){ try { $this->ValidateZoneRequest(); //echo 'asdasdasd'; $query_zone="select * from tbl_zipe_to_zone where zipe_code=LEFT('".$this->getShipToPostalCode()."' , 3) and store_id='".$this->getStoreID()."' and status='Active'"; $sql_zone = $this->DBObject->query($query_zone); $result_zone = $this->DBObject->fetchNextObject($sql_zone); if(isset($result_zone->store_id) and $result_zone->store_id>0 ){ $query_zipcodes="select * from tbl_us_zipcodes where zipCode='".$this->getShipToPostalCode()."'"; $sql_zipcodes = $this->DBObject->query($query_zipcodes); $result = $this->DBObject->fetchNextObject($sql_zipcodes); if(isset($result->id) and $result->id>0 ) { $carrierResponse_array['Status']['result'] = true; $carrierResponse_array['Status']['message'] = 'Sucess'; $carrierResponse_array['Status']['ZoneResponse']['id'] = $result->id; $carrierResponse_array['Status']['ZoneResponse']['zone'] = $result_zone->zone; $carrierResponse_array['Status']['ZoneResponse']['zipCode'] = $result->zipCode; $carrierResponse_array['Status']['ZoneResponse']['zipType'] = $result->zipType; $carrierResponse_array['Status']['ZoneResponse']['postOfficeCity'] = $result->postOfficeCity; $carrierResponse_array['Status']['ZoneResponse']['state'] = $result->state; $carrierResponse_array['Status']['ZoneResponse']['stateCode'] = $result->stateCode; $carrierResponse_array['Status']['ZoneResponse']['county'] = $result->county; $carrierResponse_array['Status']['ZoneResponse']['areaCode'] = $result->areaCode; $carrierResponse_array['Status']['ZoneResponse']['longitude'] = $result->longitude; $carrierResponse_array['Status']['ZoneResponse']['latitude'] = $result->latitude; $carrierResponse_array['Status']['ZoneResponse']['population'] = $result->population; $carrierResponse_array['Status']['ZoneResponse']['populationDensity'] = $result->populationDensity; $carrierResponse_array['Status']['ZoneResponse']['housingUnits'] = $result->housingUnits; $carrierResponse_array['Status']['ZoneResponse']['medianHomeValue'] = $result->medianHomeValue; $carrierResponse_array['Status']['ZoneResponse']['occupiedHousingUnits'] = $result->occupiedHousingUnits; $carrierResponse_array['Status']['ZoneResponse']['medianHouseholdIncome'] = $result->medianHouseholdIncome; $carrierResponse_array['Status']['ZoneResponse']['waterArea'] = $result->waterArea; $carrierResponse_array['Status']['ZoneResponse']['landArea'] = $result->landArea; $carrierResponse_array['Status']['ZoneResponse']['timezone'] = $result->timezone; return json_encode($carrierResponse_array); exit; } } echo json_encode(Array( 'Status' => array( "result" => false, "message" => '', "ZoneResponse" => '' ) )); } catch (Exception $ex) { $this->setError($ex->getMessage()); } } } class Courrier { /*********** Variables ************************/ const Error_101 = 'Invalid or empty Ship To Name'; const Error_102 = 'Invalid or empty Ship To Phone'; const Error_103 = 'Invalid or empty Ship To Company Name'; const Error_104 = 'Invalid or empty Ship To Address line'; const Error_105 = 'Invalid or empty Ship To City'; const Error_106 = 'Invalid or empty Ship To State'; const Error_107 = 'Invalid or empty Ship To Postal Code'; const Error_108 = 'Invalid or empty Ship From Name'; const Error_109 = 'Invalid or empty Ship From Phone'; const Error_110 = 'Invalid or empty Ship From Company Name'; const Error_111 = 'Invalid or empty Ship From Address line'; const Error_112 = 'Invalid or empty Ship From City'; const Error_113 = 'Invalid or empty Ship From State'; const Error_114 = 'Invalid or empty Ship From Postal Code'; const Error_115 = 'Invalid or empty Weight'; const Error_116 = 'Invalid or empty Carrier'; const Error_117 = 'Request is not well formated'; const Error_118 = 'Method Not Allowed'; const Error_119 = 'Error in Request'; const Error_120 = 'Validate Address is not valid'; const Error_121 = 'Invalid or empty Order Number'; const Error_122 = 'Invalid or empty Store ID'; private $Error = ''; private $is_Error = false; private $Validate_Address = ""; private $Ship_To_Name = ""; private $Ship_To_Phone = ""; private $Ship_To_Company_Name = ""; private $Ship_To_Address_Line1 = ""; private $Ship_To_Address_Line2 = ""; private $Ship_To_City_Locality = ""; private $Ship_To_State_Province = ""; private $Ship_To_Postal_Code = ""; private $Ship_To_Country_Code = ""; private $Ship_From_Name = ""; private $Ship_From_Phone = ""; private $Ship_From_Company_Name = ""; private $Ship_From_Address_Line1 = ""; private $Ship_From_Address_Line2 = ""; private $Ship_From_City_Locality = ""; private $Ship_From_State_Province = ""; private $Ship_From_Postal_Code = ""; private $Ship_From_Country_Code = ""; private $Ship_From__Tax_Identification_Number = ""; private $Weight = ""; private $Unit = ""; private $DimensionsUnit = ""; private $Dimensions_Length = ""; private $Dimensions_Width = ""; private $Dimensions_Height = ""; private $Carrier = ""; private $Service_Code = ""; private $Service_Desciption = ""; private $ShipperNumber = ""; private $Shipper_AddressLine = ""; private $Shipper_City = ""; private $Shipper_StateProvinceCode = ""; private $Shipper_PostalCode = ""; private $Shipper_CountryCode = ""; /** * @var string */ private $Shipper_Name = ""; private $Request_Option = ""; private $Pickup_Type_Code = ""; private $Pickup_Type_Description = ""; private $Customer_Classification_Code = ""; private $Customer_Classification_Description = ""; private $Dimensions_Unit_Code = ""; private $Unit_Code = ""; private $Packaging_Code = ""; private $Packaging_Description = ""; private $Transaction_Reference = ""; private $Box_Type = ""; private $Shipper_Attention_Name = ""; private $Shipper_Tax_Identification_Number = ""; private $Shipper_Phone_Number = ""; private $Shipper_Fax_Number = ""; private $trackingNumber=""; private $orderNumber = ""; private $storeID = ""; /** * @return string */ public function getStoreID() { return $this->storeID; } /** * @param string $storeID */ public function setStoreID($storeID) { $this->storeID = $storeID; } /** * @return string */ public function getOrderNumber() { return $this->orderNumber; } /** * @param string $orderNumber */ public function setOrderNumber($orderNumber) { $this->orderNumber = $orderNumber; } /** * @return string */ public function getShipFromTaxIdentificationNumber() { return $this->Ship_From__Tax_Identification_Number; } /*********** Variables ************************/ /** * @return string */ public function getTrackingNumber() { return $this->trackingNumber; } /** * @param string $trackingNumber */ public function setTrackingNumber($trackingNumber) { $this->trackingNumber = $trackingNumber; } /** * @param string $Ship_From__Tax_Identification_Number */ public function setShipFromTaxIdentificationNumber($Ship_From__Tax_Identification_Number) { $this->Ship_From__Tax_Identification_Number = $Ship_From__Tax_Identification_Number; } /** * @return string */ public function getShipperFaxNumber() { return $this->Shipper_Fax_Number; } /** * @param string $Shipper_Fax_Number */ public function setShipperFaxNumber($Shipper_Fax_Number) { $this->Shipper_Fax_Number = $Shipper_Fax_Number; } /** * @return string */ public function getBoxType() { return $this->Box_Type; } /** * @param string $Box_Type */ public function setBoxType($Box_Type) { $this->Box_Type = $Box_Type; if ($Box_Type == "Small") { $this->setDimensionsHeight("10"); $this->setDimensionsLength("10"); $this->setDimensionsWidth("12"); } if ($Box_Type == "Medium") { $this->setDimensionsHeight("16"); $this->setDimensionsLength("18"); $this->setDimensionsWidth("18"); } if ($Box_Type == "Large") { $this->setDimensionsHeight("24"); $this->setDimensionsLength("18"); $this->setDimensionsWidth("18"); } } /** * @param string $Dimensions_Height */ private function setDimensionsHeight($Dimensions_Height) { $this->Dimensions_Height = $Dimensions_Height; } /** * @param string $Dimensions_Length */ private function setDimensionsLength($Dimensions_Length) { $this->Dimensions_Length = $Dimensions_Length; } /** * @param string $Dimensions_Width */ private function setDimensionsWidth($Dimensions_Width) { $this->Dimensions_Width = $Dimensions_Width; } /** * @return string */ public function getPickupTypeCode() { return $this->Pickup_Type_Code; } /** * @param string $Pickup_Type_Code */ public function setPickupTypeCode($Pickup_Type_Code) { $this->Pickup_Type_Code = $Pickup_Type_Code; } /** * @return string */ public function getPickupTypeDescription() { return $this->Pickup_Type_Description; } /** * @param string $Pickup_Type_Description */ public function setPickupTypeDescription($Pickup_Type_Description) { $this->Pickup_Type_Description = $Pickup_Type_Description; } /** * @return string */ public function getCustomerClassificationCode() { return $this->Customer_Classification_Code; } /** * @param string $Customer_Classification_Code */ public function setCustomerClassificationCode($Customer_Classification_Code) { $this->Customer_Classification_Code = $Customer_Classification_Code; } /** * @return string */ public function getCustomerClassificationDescription() { return $this->Customer_Classification_Description; } /** * @param string $Customer_Classification_Description */ public function setCustomerClassificationDescription($Customer_Classification_Description) { $this->Customer_Classification_Description = $Customer_Classification_Description; } /** * @return string */ public function getError() { return $this->Error; } /** * @param string $Error */ public function setError($Error) { $this->is_Error = true; $this->Error = json_encode(Array( 'Status' => array( "result" => false, "message" => $Error ) )); } /** * @return string */ public function getShipToAddressLine2() { return $this->Ship_To_Address_Line2; } /** * @param string $Ship_To_Address_Line2 */ public function setShipToAddressLine2($Ship_To_Address_Line2) { $this->Ship_To_Address_Line2 = $Ship_To_Address_Line2; } /** * @return string */ public function getShipFromAddressLine2() { return $this->Ship_From_Address_Line2; } /** * @param string $Ship_From_Address_Line2 */ public function setShipFromAddressLine2($Ship_From_Address_Line2) { $this->Ship_From_Address_Line2 = $Ship_From_Address_Line2; } public function ValidateZoneRequest(){ if ($this->getStoreID() === "") { throw new Exception(self::Error_122); } elseif ($this->getShipToPostalCode() === "") { throw new Exception(self::Error_107); } } public function ValidateRequest() { if ($this->getValidateAddress() === "" || ($this->getValidateAddress() !== "no_validation" && $this->getValidateAddress() !== "validate_only" && $this->getValidateAddress() !== "validate_and_clean")) { // $this->setError(self::Error_120); throw new Exception(self::Error_120); } elseif ($this->getShipToName() === "") { //$this->setError(self::Error_101); throw new Exception(self::Error_101); } /*elseif ($this->getShipToPhone() === "") { $this->setError(self::Error_102); } elseif ($this->getShipToCompanyName() === "") { $this->setError(self::Error_103); } */ elseif ($this->getShipToAddressLine1() === "") { // $this->setError(self::Error_104); throw new Exception(self::Error_104); } elseif ($this->getShipToCityLocality() === "") { throw new Exception(self::Error_105); //$this->setError(self::Error_105); } elseif ($this->getShipToStateProvince() === "") { //$this->setError(self::Error_106); throw new Exception(self::Error_106); } elseif ($this->getShipToPostalCode() === "") { //$this->setError(self::Error_107); throw new Exception(self::Error_107); } elseif ($this->getShipFromName() === "") { //$this->setError(self::Error_108); throw new Exception(self::Error_108); } /*elseif ($this->getShipFromPhone() === "") { $this->setError(self::Error_109); } elseif ($this->getShipFromCompanyName() === "") { $this->setError(self::Error_110); }*/ elseif ($this->getShipFromAddressLine1() === "") { //$this->setError(self::Error_111); throw new Exception(self::Error_111); } elseif ($this->getShipFromCityLocality() === "") { //$this->setError(self::Error_112); throw new Exception(self::Error_112); } elseif ($this->getShipFromStateProvince() === "") { //$this->setError(self::Error_113); throw new Exception(self::Error_113); } elseif ($this->getShipFromPostalCode() === "") { //$this->setError(self::Error_114); throw new Exception(self::Error_114); } elseif ($this->getWeight() === "") { //$this->setError(self::Error_115); throw new Exception(self::Error_115); } elseif ($this->getCarrier() === "") { //$this->setError(self::Error_116); throw new Exception(self::Error_116); } elseif ($this->getOrderNumber() === "") { //$this->setError(self::Error_116); throw new Exception(self::Error_121); } } /** * @return string */ public function getValidateAddress() { return $this->Validate_Address; } /** * @param string $Validate_Address */ public function setValidateAddress($Validate_Address) { $this->Validate_Address = $Validate_Address; } /** * @return string */ public function getShipToName() { return $this->Ship_To_Name; } /** * @param string $Ship_To_Name */ public function setShipToName($Ship_To_Name) { $this->Ship_To_Name = $Ship_To_Name; } /** * @return string */ public function getShipToAddressLine1() { return $this->Ship_To_Address_Line1; } /** * @param string $Ship_To_Address_Line1 */ public function setShipToAddressLine1($Ship_To_Address_Line1) { $this->Ship_To_Address_Line1 = $Ship_To_Address_Line1; } /** * @return string */ public function getShipToCityLocality() { return $this->Ship_To_City_Locality; } /** * @param string $Ship_To_City_Locality */ public function setShipToCityLocality($Ship_To_City_Locality) { $this->Ship_To_City_Locality = $Ship_To_City_Locality; } /** * @return string */ public function getShipToStateProvince() { return $this->Ship_To_State_Province; } /** * @param string $Ship_To_State_Province */ public function setShipToStateProvince($Ship_To_State_Province) { $this->Ship_To_State_Province = $Ship_To_State_Province; } /** * @return string */ public function getShipToPostalCode() { return $this->Ship_To_Postal_Code; } /** * @param string $Ship_To_Postal_Code */ public function setShipToPostalCode($Ship_To_Postal_Code) { $this->Ship_To_Postal_Code = $Ship_To_Postal_Code; } /** * @return string */ public function getShipFromName() { return $this->Ship_From_Name; } /** * @param string $Ship_From_Name */ public function setShipFromName($Ship_From_Name) { $this->Ship_From_Name = $Ship_From_Name; } /** * @return string */ public function getShipFromAddressLine1() { return $this->Ship_From_Address_Line1; } /** * @param string $Ship_From_Address_Line1 */ public function setShipFromAddressLine1($Ship_From_Address_Line1) { $this->Ship_From_Address_Line1 = $Ship_From_Address_Line1; } /** * @return string */ public function getShipFromCityLocality() { return $this->Ship_From_City_Locality; } /** * @param string $Ship_From_City_Locality */ public function setShipFromCityLocality($Ship_From_City_Locality) { $this->Ship_From_City_Locality = $Ship_From_City_Locality; } /** * @return string */ public function getShipFromStateProvince() { return $this->Ship_From_State_Province; } /** * @param string $Ship_From_State_Province */ public function setShipFromStateProvince($Ship_From_State_Province) { $this->Ship_From_State_Province = $Ship_From_State_Province; } /** * @return string */ public function getShipFromPostalCode() { return $this->Ship_From_Postal_Code; } /** * @param string $Ship_From_Postal_Code */ public function setShipFromPostalCode($Ship_From_Postal_Code) { $this->Ship_From_Postal_Code = $Ship_From_Postal_Code; } /** * @return string */ public function getWeight() { return $this->Weight; } /** * @param string $Weight */ public function setWeight($Weight) { $this->Weight = $Weight; } /** * @return string */ public function getCarrier() { return $this->Carrier; } /** * @param string $Carrier */ public function setCarrier($Carrier) { $this->Carrier = $Carrier; } public function BuildLabelRequest() { //create soap request $Shipper['Name'] = $this->getShipperName(); $Shipper['AttentionName'] = $this->getShipperAttentionName(); $Shipper['TaxIdentificationNumber'] = $this->getShipper_Tax_Identification_Number(); $Shipper['Phone'] = array('Number' => $this->getShipperPhoneNumber()); $Shipper['ShipperNumber'] = $this->getShipperNumber(); $Address['AddressLine'] = $this->getShipperAddressLine(); $Address['City'] = $this->getShipperCity(); $Address['StateProvinceCode'] = $this->getShipperStateProvinceCode(); $Address['PostalCode'] = $this->getShipperPostalCode(); $Address['CountryCode'] = $this->getShipperCountryCode(); $Shipper['Address'] = $Address; $Shipment['Description'] = 'MyValue365 Grocery'; $Shipment['Shipper'] = $Shipper; $ShipTo['Name'] = $this->getShipToName(); $ShipTo['Phone'] = array('Number' => $this->getShipToPhone()); $AddressTo['AddressLine'] = $this->getShipToAddressLine1(); $AddressTo['City'] = $this->getShipToCityLocality(); $AddressTo['StateProvinceCode'] = $this->getShipToStateProvince(); $AddressTo['PostalCode'] = $this->getShipToPostalCode(); $AddressTo['CountryCode'] = $this->getShipToCountryCode(); $AddressTo['ResidentialAddressIndicator'] = ''; $ShipTo['Address'] = $AddressTo; $Shipment['ShipTo'] = $ShipTo; $ShipFrom['Name'] = $this->getShipFromName(); $ShipFrom['TaxIdentificationNumber'] = $this->getShipper_Tax_Identification_Number(); $ShipFrom['Phone'] = array('Number' => $this->getShipFromPhone()); $AddressFrom['AddressLine'] = $this->getShipFromAddressLine1(); $AddressFrom['City'] = $this->getShipFromCityLocality(); $AddressFrom['StateProvinceCode'] = $this->getShipFromStateProvince(); $AddressFrom['PostalCode'] = $this->getShipFromPostalCode(); $AddressFrom['CountryCode'] = $this->getShipFromCountryCode(); $ShipFrom['Address'] = $AddressFrom; $Shipment['ShipFrom'] = $ShipFrom; $Shipment['PaymentInformation'] = array('ShipmentCharge' => array('Type' => '01', 'BillShipper' => array('AccountNumber' => $this->getShipperNumber()))); $service['Code'] = $this->getServiceCode(); $service['Description'] = $this->getServiceDesciption(); $Shipment['Service'] = $service; $packaging1['Code'] = $this->getPackagingCode(); //$packaging1['Description'] = $this->getPackagingDescription(); $package1['Packaging'] = $packaging1; $dunit1['Code'] = $this->getDimensionsUnitCode(); $dunit1['Description'] = $this->getDimensionsUnit(); $dimensions1['UnitOfMeasurement'] = $dunit1; $dimensions1['Length'] = $this->getDimensionsLength(); $dimensions1['Width'] = $this->getDimensionsWidth(); $dimensions1['Height'] = $this->getDimensionsHeight(); //$package1['Dimensions'] = $dimensions1; $punit1['Code'] = $this->getUnitCode(); //$punit1['Description'] = $this->getUnit(); $packageweight1['Weight'] = $this->getWeight(); $packageweight1['UnitOfMeasurement'] = $punit1; $package1['PackageWeight'] = $packageweight1; $Shipment['Package'] = array($package1); $Shipment['ShipmentServiceOptions'] = ''; $Shipment['LargePackageIndicator'] = ''; $Request['Shipment'] = $Shipment; $Request['LabelSpecification'] = array('LabelImageFormat' => array('Code' => 'GIF')); $RateRequest["ShipmentRequest"] = $Request; //echo "Request.......\n"; //print_r(json_encode($RateRequest)); //echo "\n\n"; return json_encode($RateRequest); } /** * @return string */ public function getShipperName() { return $this->Shipper_Name; } /** * @param string $Shipper_Name */ public function setShipperName($Shipper_Name) { $this->Shipper_Name = $Shipper_Name; } /** * @return string */ public function getShipperAttentionName() { return $this->Shipper_Attention_Name; } /** * @param string $Shipper_Attention_Name */ public function setShipperAttentionName($Shipper_Attention_Name) { $this->Shipper_Attention_Name = $Shipper_Attention_Name; } /** * @return string */ public function getShipper_Tax_Identification_Number() { return $this->Shipper_Tax_Identification_Number; } /** * @param string $Shipper_Tax_Identification_Number */ public function setShipper_Tax_Identification_Number($Shipper_Tax_Identification_Number) { $this->Shipper_Tax_Identification_Number = $Shipper_Tax_Identification_Number; } /** * @return string */ public function getShipperPhoneNumber() { return $this->Shipper_Phone_Number; } /** * @param string $Shipper_Phone_Number */ public function setShipperPhoneNumber($Shipper_Phone_Number) { $this->Shipper_Phone_Number = $Shipper_Phone_Number; } /** * @return string */ public function getShipperNumber() { return $this->ShipperNumber; } /** * @param string $ShipperNumber */ public function setShipperNumber($ShipperNumber) { $this->ShipperNumber = $ShipperNumber; } /** * @return string */ public function getShipperAddressLine() { return $this->Shipper_AddressLine; } /** * @param string $Shipper_AddressLine */ public function setShipperAddressLine($Shipper_AddressLine) { $this->Shipper_AddressLine = $Shipper_AddressLine; } /** * @return string */ public function getShipperCity() { return $this->Shipper_City; } /** * @param string $Shipper_City */ public function setShipperCity($Shipper_City) { $this->Shipper_City = $Shipper_City; } /** * @return string */ public function getShipperStateProvinceCode() { return $this->Shipper_StateProvinceCode; } /** * @param string $Shipper_StateProvinceCode */ public function setShipperStateProvinceCode($Shipper_StateProvinceCode) { $this->Shipper_StateProvinceCode = $Shipper_StateProvinceCode; } /** * @return string */ public function getShipperPostalCode() { return $this->Shipper_PostalCode; } /** * @param string $Shipper_PostalCode */ public function setShipperPostalCode($Shipper_PostalCode) { $this->Shipper_PostalCode = $Shipper_PostalCode; } /** * @return string */ public function getShipperCountryCode() { return $this->Shipper_CountryCode; } /** * @param string $Shipper_CountryCode */ public function setShipperCountryCode($Shipper_CountryCode) { $this->Shipper_CountryCode = $Shipper_CountryCode; } /** * @return string */ public function getShipToPhone() { return $this->Ship_To_Phone; } /** * @param string $Ship_To_Phone */ public function setShipToPhone($Ship_To_Phone) { $this->Ship_To_Phone = $Ship_To_Phone; } /** * @return string */ public function getShipToCountryCode() { return $this->Ship_To_Country_Code; } /** * @param string $Ship_To_Country_Code */ public function setShipToCountryCode($Ship_To_Country_Code) { $this->Ship_To_Country_Code = $Ship_To_Country_Code; } /** * @return string */ public function getShipFromPhone() { return $this->Ship_From_Phone; } /** * @param string $Ship_From_Phone */ public function setShipFromPhone($Ship_From_Phone) { $this->Ship_From_Phone = $Ship_From_Phone; } /** * @return string */ public function getShipFromCountryCode() { return $this->Ship_From_Country_Code; } /** * @param string $Ship_From_Country_Code */ public function setShipFromCountryCode($Ship_From_Country_Code) { $this->Ship_From_Country_Code = $Ship_From_Country_Code; } /** * @return string */ public function getServiceCode() { return $this->Service_Code; } /** * @param string $Service_Code */ public function setServiceCode($Service_Code) { $this->Service_Code = $Service_Code; } /** * @return string */ public function getServiceDesciption() { return $this->Service_Desciption; } /** * @param string $Service_Desciption */ public function setServiceDesciption($Service_Desciption) { $this->Service_Desciption = $Service_Desciption; } /** * @return string */ public function getPackagingCode() { return $this->Packaging_Code; } /** * @param string $Packaging_Code */ public function setPackagingCode($Packaging_Code) { $this->Packaging_Code = $Packaging_Code; } /** * @return string */ public function getDimensionsUnitCode() { return $this->Dimensions_Unit_Code; } /** * @param string $Dimensions_Unit_Code */ public function setDimensionsUnitCode($Dimensions_Unit_Code) { $this->Dimensions_Unit_Code = $Dimensions_Unit_Code; } /** * @return string */ public function getDimensionsUnit() { return $this->DimensionsUnit; } /** * @param string $DimensionsUnit */ public function setDimensionsUnit($DimensionsUnit) { $this->DimensionsUnit = $DimensionsUnit; } /** * @return string */ public function getDimensionsLength() { return $this->Dimensions_Length; } /** * @return string */ public function getDimensionsWidth() { return $this->Dimensions_Width; } /** * @return string */ public function getDimensionsHeight() { return $this->Dimensions_Height; } /** * @return string */ public function getUnitCode() { return $this->Unit_Code; } /** * @param string $Unit_Code */ public function setUnitCode($Unit_Code) { $this->Unit_Code = $Unit_Code; } public function BuildRateRequest() { //create soap request $UsernameToken['Username'] = $this::UserID; $UsernameToken['Password'] = $this::Password; $ServiceAccessToken['AccessLicenseNumber'] = $this::AccessLicenseNumber; $UPSSecurity['UsernameToken'] = $UsernameToken; $UPSSecurity['ServiceAccessToken'] = $ServiceAccessToken; $Option['RequestOption'] = $this->getRequestOption(); $TransactionReference['CustomerContext'] = $this->getTransactionReference(); $Option['TransactionReference'] = $TransactionReference; $Request['Request'] = $Option; // $PickupType['Code'] = $this->getPickupTypeCode(); // $PickupType['Description'] = $this->getPickupTypeDescription(); // $Request['PickupType'] = $PickupType; //$CustomerClassification['Code'] = $this->getCustomerClassificationCode(); //$CustomerClassification['Description'] = $this->getCustomerClassificationDescription(); //$Request['CustomerClassification'] = $CustomerClassification; $Shipper['Name'] = $this->getShipperName(); $Shipper['ShipperNumber'] = $this->getShipperNumber(); $Address['AddressLine'] = array($this->getShipperAddressLine()); $Address['City'] = $this->getShipperCity(); $Address['StateProvinceCode'] = $this->getShipperStateProvinceCode(); $Address['PostalCode'] = $this->getShipperPostalCode(); $Address['CountryCode'] = $this->getShipperCountryCode(); $Shipper['Address'] = $Address; $Shipment['Shipper'] = $Shipper; $ShipFrom['Name'] = $this->getShipFromName(); $AddressFrom['AddressLine'] = array($this->getShipFromAddressLine1()); $AddressFrom['City'] = $this->getShipFromCityLocality(); $AddressFrom['StateProvinceCode'] = $this->getShipFromStateProvince(); $AddressFrom['PostalCode'] = $this->getShipFromPostalCode(); $AddressFrom['CountryCode'] = $this->getShipFromCountryCode(); $ShipFrom['Address'] = $AddressFrom; $Shipment['ShipFrom'] = $ShipFrom; $ShipTo['Name'] = $this->getShipToName(); $AddressTo['AddressLine'] = array($this->getShipToAddressLine1()); $AddressTo['City'] = $this->getShipToCityLocality(); $AddressTo['StateProvinceCode'] = $this->getShipToStateProvince(); $AddressTo['PostalCode'] = $this->getShipToPostalCode(); $AddressTo['CountryCode'] = $this->getShipToCountryCode(); $AddressTo['ResidentialAddressIndicator'] = ''; $ShipTo['Address'] = $AddressTo; $Shipment['ShipTo'] = $ShipTo; $service['Code'] = $this->getServiceCode(); $service['Description'] = $this->getServiceDesciption(); $Shipment['Service'] = $service; $packaging1['Code'] = $this->getPackagingCode(); $packaging1['Description'] = $this->getPackagingDescription(); $package1['PackagingType'] = $packaging1; $dunit1['Code'] = $this->getDimensionsUnitCode(); $dunit1['Description'] = $this->getDimensionsUnit(); $dimensions1['UnitOfMeasurement'] = $dunit1; $dimensions1['Length'] = $this->getDimensionsLength(); $dimensions1['Width'] = $this->getDimensionsWidth(); $dimensions1['Height'] = $this->getDimensionsHeight(); $package1['Dimensions'] = $dimensions1; $punit1['Code'] = $this->getUnitCode(); $punit1['Description'] = $this->getUnit(); $packageweight1['Weight'] = $this->getWeight(); $packageweight1['UnitOfMeasurement'] = $punit1; $package1['PackageWeight'] = $packageweight1; $Shipment['Package'] = array($package1); $Shipment['ShipmentServiceOptions'] = ''; $Shipment['LargePackageIndicator'] = ''; $Request['Shipment'] = $Shipment; $RateRequest["UPSSecurity"] = $UPSSecurity; $RateRequest["RateRequest"] = $Request; //echo "Request.......\n"; //print_r(json_encode($RateRequest)); // echo "\n\n"; return json_encode($RateRequest); } /** * @return string */ public function getRequestOption() { return $this->Request_Option; } /** * @param string $Request_Option */ public function setRequestOption($Request_Option) { $this->Request_Option = $Request_Option; } /** * @return string */ public function getTransactionReference() { return $this->Transaction_Reference; } /** * @param string $Transaction_Reference */ public function setTransactionReference($Transaction_Reference) { $this->Transaction_Reference = $Transaction_Reference; } /** * @return string */ public function getPackagingDescription() { return $this->Packaging_Description; } /** * @param string $Packaging_Description */ public function setPackagingDescription($Packaging_Description) { $this->Packaging_Description = $Packaging_Description; } /** * @return string */ public function getUnit() { return $this->Unit; } /** * @param string $Unit */ public function setUnit($Unit) { $this->Unit = $Unit; } public function CurlRquest($urlEndpoint, $jsonData, $header) { $curl_options = array( CURLOPT_URL => $urlEndpoint, CURLOPT_SSL_VERIFYPEER => false, //implemented to perform a TRUST on the server certificate CURLOPT_FRESH_CONNECT => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $header, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $jsonData ); //print_r($curl_options); $ch = curl_init(); curl_setopt_array($ch, $curl_options); $result = curl_exec($ch); //Log Response or Error if ($result !== false) { // Error; } else { // Error; } //Close the handle curl_close($ch); //echo "<pre>"; //print_r($result); return ($result); } /** * @return string */ public function getShipToCompanyName() { return $this->Ship_To_Company_Name; } /** * @param string $Ship_To_Company_Name */ public function setShipToCompanyName($Ship_To_Company_Name) { $this->Ship_To_Company_Name = $Ship_To_Company_Name; } /** * @return string */ public function getShipFromCompanyName() { return $this->Ship_From_Company_Name; } /** * @param string $Ship_From_Company_Name */ public function setShipFromCompanyName($Ship_From_Company_Name) { $this->Ship_From_Company_Name = $Ship_From_Company_Name; } /** * @return bool */ public function isError() { return $this->is_Error; } } ?>