USPS®
Shipping with OAuth
Table of Contents ShowHide

Migrating to USPS Shipping with OAuth
5/08/2024
UPDATE - The plugin is
currently in BETA. Do not use for production use.
USPS has implemented an OAuth 2.0 security model for all its
APIs to enhance the overall security of its customers, to reduce
fraud and provide enhanced API capabilities. To enhance the commercial
customer experience, the United States Postal Service® has deployed
a new API Gateway and API Developer Portal to provide leading-edge,
scalable API management. The AbleCommerce integration with USPS's
version 3 API's replaces the legacy UPS OnLine® Tools at a future
date.
If you are currently using the "USPS
Web Tools " integration with AbleCommerce, then follow
the migration steps below to use the new USPS Shipping integration
which supports the OAuth 2.0 security model.
What is OAuth?
OAuth 2.0 is a protocol used for authentication and authorization
between two or more web applications. The OAuth 2.0 security model
involves the use of access tokens, which are issued to a client
application by an authorization server.
The access token is a string of characters that represents the
authorization granted to a client application by a resource owner
(typically, a user). This token is used to authenticate the client
application and authorize access to specific resources on behalf
of the resource owner and is passed in a secure API request.
Steps for Migration
The new USPS with OAuth is a built-in feature, available in
AbleCommerce 9.0.9 and later. If you are using AbleCommerce 9.0.x,
and are currently using USPS as your shipping carrier, then follow
these instructions for a seamless transition.
Login to your AbleCommerce Merchant Admin.
Using the menu, go to the Plugins
page.
Find and install
the new Plugin name "USPS®
OAuth"
If needed, follow step-by-step instructions HERE
Signup for
a Business Customer Gateway account to login
to the USPS Developer Portal and create
an App.
If you need help, follow the instructions HERE
Retrieve your new Consumer
Key and Secret
(OAuth security credentials) to configure
the new plugin.
If you need help, follow the configuration steps HERE
Complete all steps above before continuing.
Copy Over Configuration Settings
While stilled logged into the admin, open
the configuration pages for both U.S.
Postal Service and USPS®
OAuth with each in a separate browser window,
side by side.
Match your configuration settings from U.S.
Postal Service to the new USPS®
OAuth.
Some configuration settings have changed with the upgrade to
USPS v3 Shipping Rates API. These are noted below. Carefully
check the configuration settings and update
only the following to match U.S. Postal Service:
Price Type (new setting;
choose retail or commercial - replaces "Use Online
Rates")
International Mail
Class (new setting; replaces "International Mail
Type")
Enable Package Breakup
Maximum Weight (default
70)
Minimum Weight (default
0.10)
Enable Address Validation
DO
NOT CHANGE: Live URL, Test Server URL, or Tracking URL
fields as these are now different than the old integration.
When finished, Save the settings
for the new USPS OAuth configuration.
Assign Shipping Methods
Select and Assign
the same Shipping Methods for the new
USPS OAuth integration so they are the same
as the existing ones you are using in U.S. Postal Service
configuration.
Now check (edit) each of these active shipping
methods in use for the existing
U.S. Postal Service integration and make sure the corresponding
ones in the new USPS OAuth integration have the same
configuration as the corresponding one in use.
If you don't have any custom shipping methods,
or you have finished carrying over the changes for each, then
you can test before deactivating
the old existing
U.S. Postal Service carrier.
To test, go to the storefront and add
a shippable item to the cart.
Proceed through the checkout and stop
on the Select Shipping Method page.
If you see two entries for each of USPS
shipping methods, then it is working.
If you don't see two entries, then go back to the new USPS
OAuth configuration page and re-check all the settings
by comparing to the original U.S. Postal Service configurations.
(Some names and services have changed with the upgrade
to USPS v3 Shipping Rates API)
After a successful test, use the Remove
button from the configuration page for the old existing
U.S. Postal Service integration being replaced and
remove all the active shipping methods from the Configure
> Shipping > Carriers page.
The migration is complete.
USPS®
Features and Requirements
To enhance the commercial customer experience, the United States
Postal Service® has deployed a new API Gateway and API Developer
Portal to provide leading-edge, scalable API management. This
will replace legacy Web Tools® eCommerce interfaces at a
future date.
The AbleCommerce integration with USPS® OAuth includes:
Domestic Prices 3.0
This API provides USPS product pricing based on the characteristics
of what is being shipped for Priority Mail, Priority Mail Express,
Ground Advantage, Library Mail, and Media Mail. AbleCommerce
sends your product's weight and dimensions to USPS and they calculate
the most accurate rates possible.
International Prices 3.0
This API provides International USPS product pricing based on
the characteristics of what is being shipped for Global Express
Guaranteed®, Priority Mail Express Mail International®, Priority
Mail® International, First-Class Mail® Package International.
Any unique mailing restrictions or declaration forms are the responsibility
of the merchant.
Other Information to know...
USPS expects all product measurements to be
in pounds. This is a change from the previous version where
pounds and ounces were both used.
Measurements are converted before being sent to USPS for the
rate request.
Shipping API will support shipping from U.S.
states only.
Shipping to international destinations is
available.
Shipment tracking features are built-into
AbleCommerce. Tracking services are provided by USPS.
Installing the USPS Plug-in for AbleCommerce
Login to your AbleCommerce installation.
Using the menu, go to the Plugins
page.
Use the Filter
Plugins option and select the type "Shipping".
Note:
USPS OAuth plugin will be available in the list as shown in
the screenshot below.

Click the green Install
button in the far right column.
When the confirmation popup appears, click
the green Yes, install it
button.
Upon completion, click the orange Configure
button.

NOTE: Version shown may be
different depending on the release of AbleCommerce you are
using.
Create an App with USPS®
In order to use USPS® API's, you must have an active business
account with them.
After installing, go to the Configure
> Shipping > Carriers page from the admin menu.
Any installed shipping carriers will be available
from this page. Click the blue plus (+) button or linked name
to continue to the registration page.

Carefully read the on-screen instructions before continuing.
Follow these steps to use USPS APIs
Step 1. You will need
a Business Customer Gateway
account using your USPS business account credentials.
Signup
here before continuing.
Step 2. Log in to the
USPS Developer
Portal using the account credentials from step 1.
https://developer.usps.com/
Step 3. Create
an App in the USPS Developer Portal by clicking the Apps
link in the top Menu Bar.
Complete the following steps:
Click "Add app" button

Enter any "App Name" for your application
(e.g. USPS Shipping)
Do not enter a "Callback URL"
Check the box to accept Terms and Conditions, and Privacy
Policy
Enter "Description" if you want.
Select the APIs available: Shipping
Version 3
Click the ADD APP button.
After adding, the new App appears on the Apps page.
Click on it to view the Details page.
Step 4. Retrieve
your Consumer Key and Secret
View or Edit the App and the first page shows a Details section
and below that, the credentials section.
These credentials are required for generating the OAuth token.
You can view the information using the eye icon, or copy the information
using the copy icon. Both of these are highlighted in the above
image.
Save this information. You will need it for the USPS registration
page in AbleCommerce.
Step 5. Authorize
Application to Access Protected Information Resources
Login to the USPS Customer Onboarding Portal
to authorize the client application you registered in step 3 above.
This is required to access all version 3 APIs.
Confirm your account information.
Select Your Service. Choose USPS
APIs

Enter the number of shipping locations.
Company setup - Do you need USPS Returns? No is default.
AbleCommerce does not support USPS return labels at this time.
In the step before last, your Customer Registration
ID (CRID) and Mailer Identifier (MID) will be shown. Save
this information.
The last step requires a stored credit card to be on
file.
When complete, continue to AbleCommerce for the final
registration and setup of USPS.
Configure USPS®
After registration, the next and last section is the USPS configuration
page. You can get to this page directly by going to Configure
> Shipping > Carriers page, and then editing the USPS OAuth
shipping integration.
View the configuration page below:

The USPS Consumer
Key and Consumer Secret
fields should already be populated after registration.
Enable Address
Validation is an optional service that can be used
when a customer enters an address during checkout. If
a better address can be suggested to the customer, they will
see an alternate address and be allowed to use the suggested
one, or keep the address as entered. Check the box to enable
this feature.
- For USPS, you will need to have your account enabled for
this feature, and you can only use it in conjunction with
USPS shipping services.
- You may not
use USPS for Address Validation while using a different provider
for shipping rates.
- You should not
activate more than one Address Validation Service within AbleCommerce.
If you will be using USPS to send mail to
locations outside of the U.S., then choose the International
Mail Class option to calculate rates for the different
types of shipping services selected. The default value is
'Null' or you can specify a single mailClass to improve performance.
The four mail class types for international shipping:
FIRST CLASS PACKAGE INTERNATIONAL SERVICE
PRIORITY MAIL INTERNATIONAL
PRIORITY MAIL EXPRESS INTERNATIONAL
GLOBAL EXPRESS GUARANTEED
The Maximum
Weight is this carriers limit for a package. The
default value is 70 lbs.
The Minimum
Weight is the amount used when the order weight does
not meet the minimum.
The Enable
Package Breakup option is checked by default. This
allows a shipment to be split into multiple parts if the total
order weight exceeds the maximum amount. This will not
change the number of shipments in the order, only the calculation
to determine the most accurate shipping costs.
The URL settings come pre-configured when
you create the shipping account through AbleCommerce. These
URL's can change so the fields are available for modification.
It is not advisable to modify the URL's here unless
specifically instructed to do so.
Live Server URL: The URL to which requests are posted
in Live mode.
Test Server URL: The URL to which requests are
posted when Test mode
is enabled.
Tracking URL: The
URL to which requests are sent for package tracking. {0} is
substituted with the tracking number at the time of request.
The Mode
settings are used to enable/disable rates from the
test server. Debugging can also be enabled which can
help with any communication problems.
Test Mode: When Test Mode is enabled, rate requests
are sent to test server using the Test Mode URL.
Debug Mode: When debug mode is enabled, all messages
sent to and received from USPS are logged. This should only
be enabled at the direction of qualified support personnel.
Default Log File Location:
..\App_Data\Logs\[gatewayname].log
After making any changes, click the SAVE button. To complete
the shipping carrier setup, see Adding
or Removing Shipping Methods in the next section. Or,
click the SAVE AND CLOSE button to return to the Shipping
Carriers page.
Adding or Removing Shipping Methods
Configuring Shipping Services for USPS®
You must select the services you want to be available to your
customers. Each service (shipping method) is configured
separately once it's added.
NOTE: The USPS
service names are stored in the \app_data\uspsOAmethods.csv
file and can be changed any time the USPS updates their service
names.
In the bottom section of the page, you will
see the Shipping Method
menu. This is a list of all services offered by the
provider. You should review the entire list of shipping
services offered and decide which ones you want to make available
as shipping options in your store.
You can use the buttons from the Action
column to individually Add or Edit the shipping method.
Check the box next to one or more shipping methods,
or check the box at the top of the first column to quickly
select all methods.
This will activate the Update
button, which will drop-down to provide 2 options: either
Add or Remove
the selected methods.
The update will take place immediately after selection.

In this example, we will add and configure
the "USPS Priority Mail Express" service, and a
few others using the multi-add feature. Check the box next
to all others you want to offer as a shipping service.
Using the Update
button, select the option Add
selected methods.
The selected shipping services now appear
at the top of the list and each will be linked for configuration.

To remove an individual shipping method, use
the Remove button
in the Action column, or you can select multiple methods by
checking the box in the first column and activating the Update button which will
give you the option to select Remove
selected methods. The update will take place immediately
after selection.
Configure a Shipping Method
Each shipping method will use its own configuration
settings. To configure a shipping service, click the
EDIT button to view
the Configure page.

The above example shows the default
configuration values for all shipping services that
are added.
Change the Shipping
Method Name if needed. This is the name that
will be displayed to the customer and the merchant on all
invoices and receipts.
Note: Most third-party
carriers do not want the names of their shipping methods changed.
If these shipping charges are taxable, then
select a Shipping Tax Code.
Make sure you understand the tax laws according to your
local tax authority.
Taxes on shipping charges are combined with any other taxes
calculated for the shipment.
Use the Handling
Fee field to include a charge for handling or processing.
The handling fee can be a fixed amount, percent of the
shipping charge, or a percentage of the shipment total. After
entering the amount, select one of these three options available.
There is a display option to either show the
Handing Fee included in
the shipping cost, which will hide the amount in the
shipping cost. Or to show
the handling fee separately, where it will be displayed
as a separate line item on the invoice. If you show
the handling fee separately, you may then select a Handling
Tax Code if you are required to collect tax on this
type of charge.
The Minimum
Purchase field is the designated minimum value of a
shipment before this shipping method will be available. Until
this limit is met, the shipping method will not display.
A minimum purchase value applies to the total of each shipment,
not the total of the order.
The Maximum
Purchase field is the designated maximum value of a
shipment before this shipping method will be available. If
this limit is exceeded, the shipping method will not display.
A maximum purchase value applies to the total of each shipment,
not the total of the order.
When finished making changes, be sure to Save.
Additional Settings
There are three optional configurations which can be used to
filter shipping methods that are shown to the customer.

These additional settings allow you to display available shipping
methods according to the shipping groups (used for custom shipping
conditions and locations where products are shipped from), the
zones (regions the products are shipped to), and/or any groups
that a customer is assigned to. By default, every new method added
will use all available destinations, special shipping conditions,
and user groups. To make shipping methods explicit to any of these
criteria, follow the steps given below.
Shipping with Ship Groups
Ship Groups are typically used for products that have special
shipping requirements, such as perishables, oversized, or overweight.
You can also define the shipping origin.
To setup Ship Groups, go to Configure
> Shipping > Ship Groups using the menu.
If this shipping service needs to be applied
to a specific warehouse(s), then you will need to setup Ship
Groups first. The warehouse determines the origin of shipping,
and ship groups allows you to choose specific warehouses and
define which shipping methods and products will be available
to them.
A warehouse determines the shipping origin. All USPS services
must use a warehouse with an address in the United States.

If this shipping method will be allowed from
all locations and types, then keep the default All
Ship Groups option selected.
Shipping with Zones
Zones allow you to configure specific places for use with many
features, including shipping methods.
To setup Zones, go to Configure
> Regions > Zones using the menu.
If the shipping service applies to a specific
Zone(s), select it from the Selected
Zones list.
A zone determines the shipping destination.

If the shipping service applies to all ship
to locations, then keep the default All
Zones option selected.
Shipping with User Groups
When you apply a shipping service to a user group, then it will
only appear for the users who are logged in as members of that
group.
To setup User Groups, go to People > Users > User Groups
for regular customers. To setup User Groups for administrators
only, go to People > Admins > Admin Groups.
If the shipping service applies to a
specific User Group or Admin Group, select it from the Selected
Groups list.

If the shipping service applies to everyone,
admin and customers alike, then keep the default All
Groups option selected.
When finished configuring this shipping method,
press the Save button
to continue.
Configuring Additional Services for the USPS
At the bottom of the Configure Shipping Carrier
page, there will be a list of service names for the selected
carrier.

When finished configuring a shipping method
service, you may want to Save
and then select another service type to configure.
After you have completed all configurations,
press the Save and Close
button to return to the list of all methods. This will include
all shipping methods for all carriers any custom methods you
have created.
This will bring you back to the Shipping
Methods page which displays all configured shipping
service types available for the store.

The Type
column displays the shipping service and any custom methods
in place.
Additional columns are shown for Ship
Groups, Zones,
and User
Groups. Each of these features are documented separately.
From this page, you can add,
sort, remove and configure all shipping methods.
To add a new shipping carrier, go to the Plugins
page using the menu. You may have as many services and combinations
of shipping carriers as needed.
Troubleshooting Techniques
Use this quick guide if the shipping methods are not appearing
during the checkout process.
Confirm your product(s) are shippable and have a weight.
Some carriers require dimensions as well. This information
is found within the Shipping
and Tax section of the Edit Product page.
Confirm you warehouse (the shipping origin) has a valid
address for the carrier. Go to Configure
> Shipping > Warehouses to check address information.
On the same page, you will be able to find all the products
assigned to this warehouse.
Confirm you are shipping to a valid
address for the method. For example, some shipping
methods will only appear if they are within a particular country
or state. Another example, ground transportation is not available
to Hawaii from the mainland United States.
If the carrier requires an account
number or key, confirm the information is correct from
the applicable service carrier's configuration page. This
information is found under the Configure > Shipping >
Carriers page.
Check the available shipping services you have configured
and make certain they have the correct
ship groups or zones defined for the package and address
delivery. This step applies if you have configured special
shipping situations using Ship Groups and/or Zones.
From the configuration page of the carrier, there is
a checkbox to enable Debug
Mode. Only use this feature if all steps above have
been confirmed. Once debug is enabled, test a shipment calculation
through the checkout process. This will log an entry.
Then you will need to access
the debug log file which is located on the server in
the following location ...\website\App_Data\logs\*carrier
name*.log
Open the file and carefully review
the data that was SENT and RECEIVED. In the received
response, there should be a message or error indicating the
reason the shipping method did not calculate on the shipment
received. If needed, provide this information to technical
support.
When finished troubleshooting, make sure to turn
OFF debug mode.
Successful Shipping Rates
When the shipping carrier is setup correctly, the user should
see the selected shipping methods and rates on the /Checkout/ShipMethod
page:

NOTE: The USPS methods
are automatically filtered to show only the available service(s)
to any given address.
USPS is a registered trademark of the United
States Postal Service. All Rights Reserved. |