Page 1 of 1

Problems with USPS Integrated Carrier Module

Posted: Tue May 20, 2008 4:23 pm
by nborelli
It seems that USPS changed their API as of May 14, 2008. The changes seem to effect Priority International Flat-Rate options. Is their a patch available for build 9381 to handle this API change? If not, is the source code for the CommerceBuilder.USPS.dll assembly available? I will also do some additional research and see if I can get more specifics about what exactly changed.

Thanks,
Neal

Re: Problems with USPS Integrated Carrier Module

Posted: Tue May 20, 2008 4:42 pm
by nborelli
I see that since the assembly is not obfuscated, I can disassemble the code ands read it. I do notice that the the code contains a large number of hard coded values. It might be nice to break some of this into a separate configuration file so that the names of services and other options can be easily changed. For example, the static constructor of the USPS class reads as follows:

Code: Select all

static USPS()
{
      _services.Add("Express Mail", "USPS Express Mail");
      _services.Add("Express Mail Flat-Rate Envelope", "USPS Express Mail Flat Rate Envelope (12.5\" x 9.5\")");
      _services.Add("Priority Mail", "USPS Priority Mail");
      _services.Add("Priority Mail Flat-Rate Envelope", "USPS Priority Mail Flat Rate Envelope (12.5\" x 9.5\")");
      _services.Add("Priority Mail Flat-Rate Box", "USPS Priority Mail Flat Rate Box");
      _services.Add("First-Class Mail", "USPS First-Class Mail");
      _services.Add("Parcel Post", "USPS Parcel Post");
      _services.Add("Bound Printed Matter", "USPS Bound Printed Matter");
      _services.Add("Library Mail", "USPS Library Mail");
      _services.Add("Media Mail", "USPS Media Mail");
      _services.Add("Global Express Guaranteed", "USPS Global Express Guaranteed");
      _services.Add("Global Express Guaranteed Non-Document Rectangular", "USPS Global Express Guaranteed Non-Document Rectangular");
      _services.Add("Global Express Guaranteed Non-Document Non-Rectangular", "USPS Global Express Guaranteed Non-Document Non-Rectangular");
      _services.Add("Express Mail International (EMS)", "USPS Express Mail International (EMS)");
      _services.Add("Express Mail International (EMS) Flat Rate Envelope", "USPS Express Mail International (EMS) Flat Rate Envelope");
      _services.Add("Priority Mail International", "USPS Priority Mail International");
      _services.Add("Priority Mail International Flat Rate Envelope", "USPS Priority Mail International Flat Rate Envelope");
      _services.Add("Priority Mail International Flat Rate Box", "USPS Priority Mail International Flat Rate Box");
      _services.Add("First-Class Mail International", "USPS First-Class Mail International");
}
Couldn't this be driven by an XML config file? Also things like the default URLs, etc. are also hard-coded. Finally, methods like BuildProviderRequest and BuildProviderRequestIntl are very hard-coded. It might be possible to make this more data driven and configurable.

Of course, if we had the source, we could make our own changes.

Just my two cents,
Neal

Re: Problems with USPS Integrated Carrier Module

Posted: Tue May 20, 2008 6:26 pm
by jmestep
The xml would be a great idea. grzyweasel had made a custom shipping wrapper to use with Able 5.5 and he used an xml file for settings and it was great- we could change it when we needed to.