On May 5, 2009, at 5:56 PM, Mathew Jones wrote:
> Mark Johnson wrote:
>> Randy Moore wrote:
>>> Hi,
>>>>>> Does anyone know any reason this patch should not be committed? We
>>> have
>>> several customers using USPS International shipping and so we have
>>> to
>>> re-install this patch after each upgrade. It works perfectly for
>>> us.
>>>>>> If it is acceptable, could someone with commit rights, please
>>> commit this?
>>>>>> Thanks and special thanks to Josh Lavin for sharing this.
>>>> This has now been committed.
>>>> If folks could remember to submit patches as attachments instead of
>> inline, that would be really helpful and appreciated.
>>>> Thanks,
>> Mark
>> Hi Mark,
>> I don't have a patch file, but there are some issues with "First-Class
> Mail International". USPS apparently separated out the method to the
> following (note the absence of the - ):
>> First Class Mail International Package
> First Class Mail International Large Envelope
> First Class Mail International Letters
> First Class Mail International Flats
> First Class Mail Int Parcels
>> I can confirm that the first one on the list works, but have not been
> able to get the other 4 to return a shipping rate.
>> Mat
In looking over the latest version of this file (1.9), I realized I
had made some additional adjustments. Attached is a patch for the
latest version to get the service names up to par.
Note that I do not use this tag any longer, due to USPS WebTools being
offline for over a week a few months ago. I made the switch to rate
tables, which I update when new prices are posted.
Below is a Perl script I wrote to grab service names from the XML
response to a rate request. Add your WebTools user and password, then
you can use the output of this script to update the tag. USPS seems to
change service names often, sometimes just adding or removing a
hyphen, and the only documentation of valid service names is found via
a rate request.
#!/usr/bin/perl
require LWP::UserAgent;
$userid = 'your id here';
$passwd = 'your pass here';
$url = 'http://Production.ShippingAPIs.com/ShippingAPI.dll';
$weight = '0';
$ounces = '10';
$mailtype = 'Package';
$country = 'Canada';
$xml = qq{API=IntlRate\&XML=<IntlRateRequest USERID="$userid"
PASSWORD="$passwd">};
$xml .= <<EOXML;
<Package ID="0">
<Pounds>$weight</Pounds>
<Ounces>$ounces</Ounces>
<MailType>$mailtype</MailType>
<Country>$country</Country>
</Package>
</IntlRateRequest>
EOXML
my $ua = new LWP::UserAgent;
my $req = new HTTP::Request 'POST', "$url";
$req->content_type('application/x-www-form-urlencoded');
$req->content($xml);
my $response = $ua->request($req);
$error_msg = 'USPS: ';
if ($response->is_success) {
$resp = $response->content;
}
else {
$error_msg .= 'Error obtaining rate quote from usps.com.';
}
@intl = split /<Service/, $resp;
foreach (@intl) {
m|<SvcDescription>(.+)</SvcDescription>|;
$svc = uc $1;
print "$svc\n";
}
#print $resp;
--
Josh Lavin
Perusion -- Expert Interchange Consulting http://www.perusion.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: usps_query.tag.patch
Type: application/octet-stream
Size: 2610 bytes
Desc: not available
Url : http://www.icdevgroup.org/pipermail/interchange-users/attachments/20090506/b0556c97/attachment.obj