ups interview questions
Top ups frequently asked interview questions
I recently purchased a 2D Barcode reader. When scanning a U.P.S. barcode, I get about half of the information I want, and about half of it looks to be encrypted in some way. I have heard there is a UPS DLL.
Example - Everything in bold seems to be encrypted, while the non-bold text contains valuable, legitimate data.
[)>01961163522424800031Z50978063UPSN12312307G:%"6*AH537&M9&QXP2E:)16(E&539R'64O
In other words, this text seems OK - and I can parse the information
[)>01961163522424800031Z50978063UPSN123123 ...
While, this data seems to be encrypted
... 07G:%"6*AH537&M9&QXP2E:)16(E&539R'64O
Any Ideas???
Everything I read on the internet says I should be able to read this thing. I'm just not finding any information on specifics. The "encrypted" info contains street address, package number (like 1/2), weight, and several other items Im dying to get my hands on. I suppose I will contact UPS directly. Thanks.
Source: (StackOverflow)
I know that UPS has some APIs they make available for doing shipping calculations. Is it possible to create a shipment and PDF shipping label using the UPS APIs with PHP? Does anyone have any working sample code?
Source: (StackOverflow)
I'm trying to create a small web service for a larger application that handles some common shipping operations (rates, package creation, labels), so I'm pretty flexible when it comes to picking a language to write it in (Python, Ruby, Java, Perl, even PHP if necessary). But I've yet to find any library or module that supports even a decent subset of that wish list. Active Shipping from shopify only supports tracking and getting rates. Most CPAN modules are pretty ancient… I can probably do the label printing myself, just a case of ZPL templating. But something that actually creates the shipments would be really, really helpful. Lots of different API calls, differences between shipping methods etc.
Maybe there's something that could be taken out of some webshop software, if it's flexible enough. I can't quite believe that nobody ever wrote a comprehensive wrapper for that.
Source: (StackOverflow)
I have managed to get a UPS Shipping calculator working in PHP. I now found out that the standard shipping from UPS is capped at 150lbs. For anything over 150lbs, I need to ship via freight.
Has anyone ever coded a Freight Calculator with UPS? The calculator I wrote for anything under 150lbs does not require a UPS account. I was hoping to do the same for the freight calculator, however, I am unable to find any information on how to accomplish this.
Any help will be greatly appreciated.
EDIT
As per request by Nicolaesse, I have added some code snippets that I wrote in 2009 to solve my problem.
Demo can be seen here:
http://cart.jgallant.com (Add product to cart, checkout, and enter zipcode for shipping estimate)
Core UPS class:
<?php
class ups {
function getMethod() {
$method= array(
'1DA' => 'Next Day Air',
'2DA' => '2nd Day Air',
'3DS' => '3 Day Select',
'GND' => 'Ground',
);
return $method;
}
function get_item_shipping($weight, $zipcode)
{
unset($_SESSION['zipcode_error']);
if($weight > 150) {
$_SESSION['zipcode_error'] = "A cart item requires freight.";
}
if (!isset($_SESSION['zipcode_error'])) {
$services = $this->getMethod();
$ch = curl_init();
foreach ($services as $key => $service) {
$Url = join("&", array("http://www.ups.com/using/services/rave/qcostcgi.cgi?accept_UPS_license_agreement=yes",
"10_action=3",
"13_product=".$key,
"14_origCountry=US",
"15_origPostal=90210",
"19_destPostal=" . $zipcode,
"22_destCountry=US",
"23_weight=" . $weight,
"47_rate_chart=Regular+Daily+Pickup",
"48_container=00",
"49_residential=2",
"billToUPS=no")
);
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$Results[]=curl_exec($ch);
}
curl_close($ch);
$pre = "";
$shipping_list = array();
foreach($Results as $result) {
$result = explode("%", $result);
if ($services[$result[1]] != ''){
if ((($result[1]=='XPR') && ($pre == 'XPR')) || (($result[1]=='XDM') && ($pre == 'XDM')) || (($result[1]=='1DP') && ($pre == '1DP')) || (($result[1]=='1DM') && ($pre == '1DM')) || (($result[1]=='1DA') && ($pre == '1DA')) || (($result[1]=='2DA') && ($pre == '2DA')))
$shipping_list += array($services[$result[1]."L"] => $result[8]);
else if (($result[1]=='GND') && ($pre == 'GND'))
$shipping_list += array($services[$result[1]."RES"] => $result[8]);
else
$shipping_list += array($services[$result[1]] => $result[8]);
$pre = $result[1];
}
}
}
$shipping_list = array_reverse($shipping_list);
return $shipping_list;
}
}
?>
WEIGHT Calculator Helper:
<?php
//UPS calculator - Divides packages into 150lbs max packages, and requests multiple quotes if needed
//Returns a sum of all the quotes added together.
private function calculate_per_item_shipping() {
$currWeight = 0;
$packageCount = 0;
//Loop thru cart items - adding weights to packages
foreach($this->get_contents() as $item) {
for ($i = 0; $i < $item["qty"]; $i++) {
$itemWeight = $item["weight"];
if ($itemWeight > 150) { // A single item cannot be more than 150lbs
$_SESSION['zipcode_error'] = $item['name'] . " weighs more than 150lbs.";
return false;
}
else {
$currWeight += $itemWeight; //Add item weight to active package
if ($currWeight > 150) { //Max weight reached for active package
$currWeight -= $itemWeight; //Remove item from current package, too heavy
$loopPack = 0;
$itemUsed = false;
//Check if an existing package can take the item
while (($loopPack != $packageCount) or ($itemUsed = false)) {
if ($packages[$loopPack] + $itemWeight < 150) {
$packages[$loopPack] += $itemWeight;
$itemUsed = true;
}
$loopPack++;
}
//if the item didn't fit in an existing package, create a new package for it
if ($itemUsed == false) {
$packageCount++;
$packages[$packageCount-1] = $currWeight;
$currWeight = $item["weight"]; //Put unused item back in active package
}
}
}
}
}
//The remainder becomes a package
$packageCount++;
$packages[$packageCount-1] = $currWeight;
for ($i = 0; $i < $packageCount; $i++) {
$temptotal = $this->calc_package_shipping($packages[$i]);
if ($temptotal['Ground'] != 0) { $total['Ground'] += $temptotal['Ground']; }
if ($temptotal['3 Day Select'] != 0) { $total['3 Day Select'] += $temptotal['3 Day Select']; }
if ($temptotal['2nd Day Air'] != 0) { $total['2nd Day Air'] += $temptotal['2nd Day Air']; }
if ($temptotal['Next Day Air Saver'] != 0) { $total['Next Day Air Saver'] += $temptotal['Next Day Air Saver']; }
if ($temptotal['Next Day Air Early AM'] != 0) { $total['Next Day Air Early AM'] += $temptotal['Next Day Air Early AM']; }
if ($temptotal['Next Day Air'] != 0) { $total['Next Day Air'] += $temptotal['Next Day Air']; }
}
$this->selectedQuoteAmount = $total['Ground'];
return $total;
}
private function calc_package_shipping($weight) {
$ups = new ups();
$shipping = $ups->get_item_shipping($weight, $this->zipcode);
return $shipping;
}
?>
Source: (StackOverflow)
I'm trying to use PHP and SoapClient to utilize the UPS Ratings web service. I found a nice tool called WSDLInterpreter to create a starting point library for creating the service requests, but regardless what I try I keep getting the same (non-descriptive) error:
EXCEPTION=SoapFault::__set_state(array(
'message' => 'An exception has been raised as a result of client data.',
'string' => '',
'code' => 0,
Um ok, what the hell does this mean?
Unlike some of the other web service tools I have implemented, the UPS Soap wants a security block put into the header. I tried doing raw associative array data but I wasn't sure 100% if I was injecting the header part correctly.
Using the WSDLInterpreter, it pulls out a RateService class with a ProcessRate method that excepts it's own (instance) datastructure for the RateRequest and UPSSecurity portions, but all of the above generates that same error.
Here's a sample of the code that I'm using that calls classes defined by the interpreter:
require_once "Shipping/UPS/RateService.php"; // WSDLInterpreter class library
class Query
{
// constants removed for stackoverflow that define (proprietary) security items
private $_upss;
private $_shpr;
// use Interpreter code's RateRequest class to send with ProcessRate
public function soapRateRequest(RateRequest $req, UPSSecurity $upss = null)
{
$res = false;
if (!isset($upss)) {
$upss = $this->__getUPSS();
}
echo "SECURITY:\n" . var_export($upss, 1) . "\n";
$upsrs = new RateService(self::UPS_WSDL);
try {
$res = $upsrs->ProcessRate($req, $upss);
} catch (SoapFault $exception) {
echo 'EXCEPTION=' . var_export($exception, 1) . "\n";
}
return $res;
}
// create a soap data structure to send to web service from shipment
public function getRequestSoap(Shipment $shpmnt)
{
$qs = new RateRequest();
// pickup information
$qs->PickupType->Code = '01';
$qs->Shipment->Shipper = $this->__getAcctInfo();
// Ship To address
$qs->Shipment->ShipTo->Address->AddressLine = $this->__getAddressArray($shpmnt->destAddress->address1, $shpmnt->destAddress->address2);
$qs->Shipment->ShipTo->Address->City = $shpmnt->destAddress->city;
$qs->Shipment->ShipTo->Address->StateProvinceCode = $shpmnt->destAddress->state;
$qs->Shipment->ShipTo->Address->PostalCode = $shpmnt->destAddress->zip;
$qs->Shipment->ShipTo->Address->CountryCode = $shpmnt->destAddress->country;
$qs->Shipment->ShipTo->Name = $shpmnt->destAddress->name;
// Ship From address
$qs->Shipment->ShipFrom->Address->AddressLine = $this->__getAddressArray($shpmnt->origAddress->address1, $shpmnt->origAddress->address2);
$qs->Shipment->ShipFrom->Address->City = $shpmnt->origAddress->city;
$qs->Shipment->ShipFrom->Address->StateProvinceCode = $shpmnt->origAddress->state;
$qs->Shipment->ShipFrom->Address->PostalCode = $shpmnt->origAddress->zip;
$qs->Shipment->ShipFrom->Address->CountryCode = $shpmnt->origAddress->country;
$qs->Shipment->ShipFrom->Name = $shpmnt->origAddress->name;
// Service type
// TODO cycle through available services
$qs->Shipment->Service->Code = "03";
$qs->Shipment->Service->Description = "UPS Ground";
// Package information
$pkg = new PackageType();
$pkg->PackagingType->Code = "02";
$pkg->PackagingType->Description = "Package/customer supplied";
// dimensions
$pkg->Dimensions->UnitOfMeasurement->Code = $shpmnt->dimensions->dimensionsUnit;
$pkg->Dimensions->Length = $shpmnt->dimensions->length;
$pkg->Dimensions->Width = $shpmnt->dimensions->width;
$pkg->Dimensions->Height = $shpmnt->dimensions->height;
$pkg->PackageServiceOptions->DeclaredValue->CurrencyCode = "USD";
$pkg->PackageServiceOptions->DeclaredValue->MonetaryValue = $shpmnt->dimensions->value;
$pkg->PackageServiceOptions->DeclaredValue->CurrencyCode = "USD";
$pkg->PackageWeight->UnitOfMeasurement = $this->__getWeightUnit($shpmnt->dimensions->weightUnit);
$pkg->PackageWeight->Weight = $shpmnt->dimensions->weight;
$qs->Shipment->Package = $pkg;
$qs->CustomerClassification->Code = 123456;
$qs->CustomerClassification->Description = "test_rate_request";
return $qs;
}
// fill out and return a UPSSecurity data structure
private function __getUPSS()
{
if (!isset($this->_upss)) {
$unmt = new UsernameToken();
$unmt->Username = self::UPSS_USERNAME;
$unmt->Password = self::UPSS_PASSWORD;
$sat = new ServiceAccessToken();
$sat->AccessLicenseNumber = self::UPSS_ACCESS_LICENSE_NUMBER;
$upss = new UPSSecurity();
$upss->UsernameToken = $unmt;
$upss->ServiceAccessToken = $sat;
$this->_upss = $upss;
}
return $this->_upss;
}
// get our shipper/account info (some items blanked for stackoverflow)
private function __getAcctInfo()
{
if (!isset($this->_shpr)) {
$shpr = new ShipperType();
$shpr->Address->AddressLine = array(
"CONTACT",
"STREET ADDRESS"
);
$shpr->Address->City = "CITY";
$shpr->Address->StateProvinceCode = "MI";
$shpr->Address->PostalCode = "ZIPCODE";
$shpr->Address->CountryCode = "US";
$shpr = new ShipperType();
$shpr->Name = "COMPANY NAME";
$shpr->ShipperNumber = self::UPS_ACCOUNT_NUMBER;
$shpr->Address = $addr;
$this->_shpr = $shpr;
}
return $this->_shpr;
}
private function __getAddressArray($adr1, $adr2 = null)
{
if (isset($adr2) && $adr2 !== '') {
return array($adr1, $adr2);
} else {
return array($adr1);
}
}
}
It doesn't even seem to be getting to the point of sending anything over the Soap so I am assuming it is dying as a result of something not matching the WSDL info. (keep in mind, I've tried sending just a properly seeded array of key/value details to a manually created SoapClient using the same WSDL file with the same error resulting)
It would just be nice to get an error to let me know what about the 'client data' is a problem. This PHP soap implementation isn't impressing me!
Source: (StackOverflow)
I have a client asking if their web application (PHP) can easily print to a UPS / Fedex thermal label printer.
So for instance, I can get back a PDF from UPS/Fedex with the shipping label. I just need to print that.
Does anyone know if you can print directly to these printers or, if not, if there's another way to do it?
EDIT: To clarify, all I want to accomplish is to be able to print to these printers, without having to make my client ALT-TAB to some third-party application like UPS Worldship or ShipRush or QuickBooks Shipping Manager and clicking 'Print' within that application. Do-able?
Source: (StackOverflow)
I have downloaded the UPS apis for both shipping and rates. The zips contain multiple docs some of which are hundreds of pages long. The zips also contain sample code, however, they are missing information needed to run successfully, i.e. Url endpoints, location of wsdl files... etc.
I have found enough information looking through stackoverflow posts to make the sample code work, though I am at a loss as to how I would build out my own soap calls needed for my business logic.
I have looked through the .wsdl files and cannot determine what parameters need to be sent and what options/methods are available to call.
For example, in the sample code there is the following:
$option['RequestOption'] = 'Shop';
$request['Request'] = $option;
If I change Shop
to another value I receive an error saying invalid request. Is this the only request that can be made for the Rate service? Where do I find the available requests to choose from and the data expected / returned?
Another example is the operation
value: $operation = "ProcessRate";
In the wsdl I have found ProcessRate
though there is very little information about input/output... unless im missing something
<wsdl:operation name="ProcessRate"><soap:operation soapAction="http://onlinetools.ups.com/webservices/RateBinding/v1.1" style="document"/><wsdl:input name="RateRequest"><soap:body parts="Body" use="literal"/><soap:header message="tns:RateRequestMessage" part="UPSSecurity" use="literal"><soap:headerfault message="tns:RateErrorMessage" part="RateError" use="literal"/></soap:header></wsdl:input><wsdl:output name="RateResponse"><soap:body parts="Body" use="literal"/></wsdl:output><wsdl:fault name="RateError"><soap:fault name="RateError" use="literal"/></wsdl:fault></wsdl:operation>
My goal is to make a call to determine shipping costs based on the amount of items a user has purchased. Any info / direction would be greatly appreciated!
Source: (StackOverflow)
I am building a shipping rates calculator and I need the service code, description and price from the API response. I have noticed that I never get a response for:
/RatingServiceSelectionResponse/RatedShipment/Service/Description - but I get a response for the price and service code.
I contacted support about this and they said, " Unfortunately, the description for the service (inside of the response) is only available in our Time in Transit API"
This seems very strange to have an Rates API that does not provide the service descriptions, it seems a bit useless without this info.
Does anyone know if there any way to do a lookup for the service description using the service code that is brought back from the Rates API?
Any help with this would be much appreciated.
Source: (StackOverflow)
I am using Mark Sanborn UPS Function to calculate UPS shipping rates with php
In this function you have to change some values of variables already defined
// ========== CHANGE THESE VALUES TO MATCH YOUR OWN ===========
$AccessLicenseNumber = '12345678910'; // Your license number
$UserId = 'username'; // Username
$Password = 'password'; // Password
$PostalCode = '12345'; // Zipcode you are shipping FROM
$ShipperNumber = '98765'; // Your UPS shipper number
but I could not figure out my $AccessLicenseNumber for UPS account also my $ShipperNumber.
Please any one used this API give me a start.
Thanks in Advance.
Source: (StackOverflow)
I am new to using WSDL's. I have used REST before but not this. I am trying to run the sample code file that is included on the UPS developer site. Page 23 of this guide is the API I am using. The file you can download includes like ten guides which I have perused, but I just initally want to figure out how to fill out the top configuration part below (I am using php example code file SoapRateClient.php). What do I put for WSDL? What do I put for end point url? The file you download on their site has several wsdl files and I'm not sure which one I am supposed to choose. Guidance appreciated.
<?php
//Configuration
$access = "secret";//I have this no problem
$userid = "";//I have this as well
$passwd = "";//I have this
$wsdl = " Add Wsdl File Here ";//What the heck do I put here!?
$operation = "ProcessRate";
$endpointurl = ' Add URL Here';//Also what do I put here?
$outputFileName = "XOLTResult.xml";
Source: (StackOverflow)
In Magento if the origin address (Shipping Settings) is Canada, FedEx & UPS modules will not be able to retrieve rates to the USA and Canada. If the origin address is changed to any US address, FedEx and UPS pull rates instantly. The problem is with CANADA as the origin address.
Has anyone encountered this or possibly have a fix?
ShipSync (FedEx Module community) can pull the rates, however it crashes the shopping cart.
Any help would be greatly appreciated!
Source: (StackOverflow)
I've been looking for days for the correct way to read the XML that UPS API returns to me. I finally found how to make a petition for a rate from a package to send, and now I got the XML with the response.
I'm not very familiar with XML, but I can understand how it works with simple examples.
The XML response is:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<rate:RateResponse xmlns:rate="http://www.ups.com/XMLSchema/XOLTWS/Rate/v1.1">
<common:Response xmlns:common="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
<common:ResponseStatus>
<common:Code>1</common:Code>
<common:Description>Success</common:Description>
</common:ResponseStatus>
<common:Alert>
<common:Code>110971</common:Code>
<common:Description>Your invoice may vary from the displayed reference rates</common:Description>
</common:Alert>
<common:TransactionReference/>
</common:Response>
<rate:RatedShipment>
<rate:Service>
<rate:Code>11</rate:Code>
<rate:Description/>
</rate:Service>
<rate:RatedShipmentAlert>
<rate:Code>110971</rate:Code>
<rate:Description>Your invoice may vary from the displayed reference rates</rate:Description>
</rate:RatedShipmentAlert>
<rate:BillingWeight>
<rate:UnitOfMeasurement>
<rate:Code>KGS</rate:Code>
<rate:Description>Kilograms</rate:Description>
</rate:UnitOfMeasurement>
<rate:Weight>3.0</rate:Weight>
</rate:BillingWeight>
<rate:TransportationCharges>
<rate:CurrencyCode>EUR</rate:CurrencyCode>
<rate:MonetaryValue>21.85</rate:MonetaryValue>
</rate:TransportationCharges>
<rate:ServiceOptionsCharges>
<rate:CurrencyCode>EUR</rate:CurrencyCode>
<rate:MonetaryValue>1.40</rate:MonetaryValue>
</rate:ServiceOptionsCharges>
<rate:TotalCharges>
<rate:CurrencyCode>EUR</rate:CurrencyCode>
<rate:MonetaryValue>23.25</rate:MonetaryValue>
</rate:TotalCharges>
<rate:RatedPackage>
<rate:Weight>1.0</rate:Weight>
</rate:RatedPackage>
<rate:RatedPackage>
<rate:Weight>2.0</rate:Weight>
</rate:RatedPackage>
</rate:RatedShipment>
</rate:RateResponse>
</soapenv:Body>
</soapenv:Envelope>
I tried an example to get the values with simplexml_load_file();
and I could get the values from a tag (a very simple example). But when I try it with that one, I can't get anything, because it says an error of beign non an object-type.
I'd be very grateful if someone knows how to read that XML and teach me how to do it.
Thanks for your time reading this!
P.S:
When I tried a simple example, I tried this and worked:
$school = simplexml_load_file('XOLTResult.xml'); //where is the xml
echo $school->students->student[0]; //finding the first student nam
This worked properly, but when I'm trying to get, for example, Response->RatedShipment[0]->Service->Code; */to get the first one/*, the error appears.
Source: (StackOverflow)
I finally got the UPS tracking API to work. Or atleast I think I do. It is giving me a 'invalid tracking number' response. My problem right now is I have no packages to track. Does anyone know of any resources that allow me to test fake orders from UPS, or anything that will give a response ? Thanks
I am using the UPS Tracking Developers Kit and need package resposnes.
Source: (StackOverflow)
Has anyone successfully configured the ship UPS under sales/orders/ship. We are trying to pass the Certification process for UPS which you have to create 5 shipments one of which produces a High Value Report?
Void any four of the UPS-defined “VOID” cases.
If you are producing GIF images, please e-mail the following 39 files along with your UPS User ID and Access key to uoltects@ups.com:
- The requests and responses of the ShipConfirm and ShipAccept XML documents from all five shipments (20 files).
- The resulting GIF images of the label from all five shipments (5 files).
- The resulting images of the High Value Report for at least one shipment (1 file).
- The HTML pages containing the scaling information for the label from all five shipments (5 files).
- The requests and responses of all the Void XML documents (8 files).
If you are printing labels via a Thermal Printer, the labels must be sent to UPS. Please send an email with your pickup address to labelverify@ups.com requesting a label via a provided label from the UPS Developer APIs support group. Include a High Value Report for at least one shipment with the thermal labels. Email the following 28 files along with your UPS User ID and Access Key to uoltects@ups.com:
- The requests and responses of the ShipConfirm and ShipAccept XML documents from all five shipments (20 files).
- The requests and responses of all the Void XML documents (8 files).
UPS will contact you via email within 2 business days to inform you of your approval status. Once granted, point your software to the following Production URL’s,
https:// pre-seeds the following links
onlinetools.ups.com/ups.app/xml/ShipConfirm
onlinetools.ups.com/ups.app/xml/ShipAccept
onlinetools.ups.com/ups.app/xml/Void
onlinetools.ups.com/ups.app/xml/LabelRecovery
This obviously is not very user friendly, but UPS says they have to have this in order to proceed. Can anyone please help?
Source: (StackOverflow)
What would cause ups shipping methods that are selected in magento's shipping method admin page to not show up as shipping options to customers. Specifically I'm trying to get the ground commercial option to show up on the frontend.
I've done some research on this, it seems like this questions been asked a before and never answered (that i can find) so I'll ask it again and throw in my research on the subject.
I've traced the source code from the shipping cost estimations in the shopping cart and found that when you enter a zip code it creates an entry in the 'sales_flat_quote_address' table with basically just the postcode and id fields filled.
It also creates rows in 'sales_flat_quote_shipping_rate'. one for each applicable shipping method for that quote/address pair.
When magento lists the shipping options it references this table.
Somewhere between the shipping methods admin and this database table some of the shipping methods are filtered out.
I think it has something to do with residential/commercial addresses. However ups's rating api cant determine if an address is residential/commercial if only given a zip code. Also changing the destination type in the admin page does not have an effect on which methods are displayed on the frontend.
For reference if all ups shipping methods are selected in the back end, the following are the only ones that show up on the front end:
ground
3 Day Select
2nd Day Air
Next Day Air Saver
Next Day Air
Next Day Air Early AM
This is out of 22 options selected in the backend.
Source: (StackOverflow)