USPS API Patch for Magento Community Edition (CE)

USPS API Patch for Magento Community Edition (CE)

Aug 14

  • Created: Aug 14, 2013 2:00 PM

USPS API Patch for Magento Community Edition (CE)

On July 28, 2013, the United States Postal Service (USPS) rolled-out changes to their API that impact you if your Magento Community Edition store is using USPS Priority or Express shipping methods. If this is the case, it’s important to update your Magento CE store right away with the patch that Magento has made available for versions 1.4.x through 1.7.0.2 at:

http://www.magentocommerce.com/blog/comments/magento-community-edition-alert-important-patch-for-usps-api/

The shipping methods patch will also need to be applied for versions earlier than 1.7 if it hasn’t been applied already. You can download the patch from the above links and then upload it via FTP, but it’s easier to just grab the patch via wget after you have logged in via SSH. If you don’t have shell access on your account with us yet, you’ll need it to run the patch(es) and so please contact support to have it enabled.

Once you are logged in via SSH:

  1. Change directory to the root of your Magento install (yourdomain.com/html)
  2. Right click on link of the patch you need at http://www.magentocommerce.com/blog/comments/magento-community-edition-alert-important-patch-for-usps-api/ and then open it in a new tab or window.
  3. Copy the URL, leaving off the part of the URL following ‘patch’ or ‘sh’, and then run: wget <link> in your SSH terminal.

Example:

for the link: http://info.magento.com/rs/magentocommerce/images/MAGEBP-706_CE_1.6.2.0_v4.patch?icid=BLOG_uspsceapi_sixtwoship

wget http://info.magento.com/rs/magentocommerce/images/MAGEBP-706_CE_1.6.2.0_v4.patch

Then run the .patch files with:

patch –p0 < patch_file_name.patch

and the .sh files with:

sh patch_file_name.sh

Example:

patch -p0 < MAGEBP-706_CE_1.6.2.0_v4.patch
sh PATCH_SUPEE-1868_CE.1.7.0.2_v1.sh

It’s recommended to run the changes by your developer first before applying the patch, and/or test it on a development site first before taking it live.

One issue I’ve seen so far is the API upgrade patch throws an error because the core files it tries to modify were already modified from the original ones for that version*. the patch tries to modify the following files:

app/code/core/Mage/Paypal/Model/Express/Checkout.php
app/code/core/Mage/Usa/Helper/Data.php
app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php
app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps/Source/Method.php
app/code/core/Mage/Usa/etc/config.xml
app/code/core/Mage/Usa/sql/usa_setup/upgrade-1.6.0.1.1.1-1.6.0.1.1.2.php

If you do get an error because these core files were modified, you can download a clean version of the same version of Magento from their site, find the core files you modified, and copy them over to the correct directories so you have the originals back in place before running the patch. This is a good example of why Magento core files in app/code/core shouldn’t be modified, as upgrades and patches can run into errors. If your developer needs to modify core files, it’s a good to first copy them to app/code/local and then make needed changes.

If you need any assistance with running the patch, or need shell access enabled, just let our support team know!

Posted in: Magento, Nexcess, Support