Forums / Addon Shipping Modules / USPS Shipping (RESTful) (USPSr)

USPS Shipping (RESTful) (USPSr)

Sticky

Views: 54,964

Results 341 to 360 of 558
13 Dec 2025, 3:58 AM
#341
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

USPS Shipping (RESTful) (USPSr)

NDboots:

Opps! Typo, found on line 702, not 207.

So, I just made this page on the Wiki of the Repo to explain how the handling fees are applied in the module. Be careful with regards to setting each one as you may discourage potential customers with a bad configuration.

(If I can figure out how to prettify here, I will)

How Quotes Are Calculated · retched/ZC-USPSRestful Wiki

14 Dec 2025, 10:47 PM
#342
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Update for everyone:

I'm working on the next 1.6.0 release right now. Just trying to solve an issue of language file conflicts that seem to pop up when the array-based language definition file and the older version of the language file are opposite each other in the language directories. Once I finish resolving that error, I'll submit it to the ZenCart directory.

18 Dec 2025, 3:41 PM
#343
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Changed in 1.6.0

  • Handling days are now added into the shipping days estimations. [#90]
  • Moved OAuth storage from system sessions to the database. [#88]

Fixed in 1.6.0

  • Expanded the list of APO/DPO/FPO Zip Codes.
  • Fixed the values of the services to match the newer options that were added on upgrade. (They didn't align from the changes in 1.5.2.)
  • Fixed an issue involving the calculation of services and add-ons. Values are now additive and not multiplicative. [#91]
  • Also fixed the math in the calculation of the order quote itself. (There was ambiguity in how the method price and handling should apply. The math now works as stated in the Wiki.)
  • Fixed a potential issue when making service standards requests and the resultant JSON file isn't in the proper form. [#93]
  • Fixed an issue that was preventing the configuration form from being submitted without an uninstall/reinstall on encapsulated installs during upgrading. [#78]

This plugin has been submitted via Plugin Database. Additionally, it has been posted on the GitHub repo. One huge change, if you are upgrading the encapsulated version of the module: you MUST visit the Shipping Modules page to upgrade the module. (Uninstalling/reinstalling is no longer necessary.)

18 Dec 2025, 4:26 PM
#344
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

So, I've done all that I can do with regards to the "429 - Too Many Requests" errors that pop up. Evidently, the USPS by default puts everyone on "Public Access I" API access which limits users of THAT tier API to "60 requests per hour". That means at best one call per minute. However, the module on average (assuming that you're not using "One Page Checkout") will use use on average three to four requests per customer. That's:

  1. A request to get an OAuth token. (Now moved to the database and will generate another one if it's expired.)
  2. The shipping estimator quotes
  3. The quotes provided during the shipping method selector.
  4. Retrieve the quote from the shipping method selector.
  • With OPC - One Page Checkout, you can remove one of these four steps (provided you don't change your address).

The only way to get around this would be to request elevated access. Problem is, the USPS API Team have a backlog of requests to get through. (Evidently the process is a bit more involved than Web Tools.)

I have provided these instructions on the Repo's Wiki but here they are here. (Again, I cannot help with ANY OF THIS as there isn't much I can do about the limit.)


This process involves you sending in a service ticket to the Email Us page (located at: https://emailus.usps.com/s/web-tools-inquiry) page on the USPS Website. From there, you'll be making a request with the following details:

  • Provide your username to USPS.com (this is your REGULAR username, not the API credential)
  • Choose "Price Calculator APIs" and "Error Messages"
  • The date, or close approximation, of when the error message was discovered. (Theoretically today.)
  • For "Additional information," provide them with this (obviously, providing your own information):
  * Your Name
  * Company Name
  * Contact Phone Number
  * Developer Portal Username
  * Developer Portal App Name
  * URL being called: apis.usps.com
  * Consumer Key/client_id
  * Customer Registration ID (CRID)
  * Mailer ID (MID)
  * Country
  * ZIP Code

Do not ever provide your Consumer Secret (client_secret). (I don't even have it included in your Debug Logs.)

To get your CRID (Customer Registration ID) or MID (Mailer Identification), check your email for the original confirmation you received when you created your USPS Business Account from the Consumer Onboarding Portal (COP). (You made one, right?) If you lost that email or otherwise misplaced them, you can retrieve them from the USPS COP Business Center. After you log in, click the "Explore The Business Portal" on the bottom right section of the menu or "My Account" on the top navbar. From there, if your account has at least one business location attached, click "Manage Locations". (If you didn't make one, make one now. This will also provide you a CRID and MID.) On the following screen, you will see your CRID and MIDs assigned to you. Provide one of the MIDs (preferably your Master) along with your CRID to the ticket above.

They will follow up with you in a few days with some follow-up questions. Some of the follow-up questions may be:

What APIs are you requesting access to/a quota increase for? Domestic Prices, International Prices, Service Standards, and International Service Standards
What is your legacy USPS Web Tools UserID (if you have one)?
What is your consumer key?
What is your CRID (if you have one)?
What is your estimated maximum daily API request volume at peak?
If you are not developing your own solution, what 3rd party software/plugin are you using to access our APIs?
Are you accessing the APIs on behalf of your own merchandise shipments?
How are you generating your shipping labels today?
How would access to the APIs enhance your shipping process today?
Please provide a list of at least 20 recent example tracking numbers for which you would like to use the API.

Be honest with your answers. Estimate where you can, and if you don't have tracking numbers (which you might not), don't worry about it. (I provided the first answer for you because the module DOES need higher quotas for those four in particular.) Consumer Key in this case is your API Consumer Key.

It will be a WHILE before you get your access granted. (I'm on week two of waiting.)

Hopefully this helps.

18 Dec 2025, 7:54 PM
#345
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,848
Plugin Contributions:
17

Re: USPS Shipping (RESTful) (USPSr)

Fails with Unknown MODULE_SHIPPING_USPSR_BEARER_TOKEN

Install works in plugins and fails when going to the Modules Shipping setting.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

18 Dec 2025, 8:43 PM
#346
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

dbltoe:

Fails with Unknown MODULE_SHIPPING_USPSR_BEARER_TOKEN

Install works in plugins and fails when going to the Modules Shipping setting.

Give me two seconds. That key should definitely be defined.

Was this an upgrade or fresh install?

18 Dec 2025, 9:06 PM
#347
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,848
Plugin Contributions:
17

Re: USPS Shipping (RESTful) (USPSr)

Dropped zcplugins through FTP, went to Plugin Manager and updated, went to Modules Shipping and clicked on USPSR. That's when it failed.

I notice your installer is different from 1.5.2, and that define was not in the previous version.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

18 Dec 2025, 10:12 PM
#348
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

dbltoe:

Dropped zcplugins through FTP, went to Plugin Manager and updated, went to Modules Shipping and clicked on USPSR. That's when it failed.

I notice your installer is different from 1.5.2, and that define was not in the previous version.

Yeah I scrubbed out the installer/upgrade which adds the fields in this version because it was doubling the work on updating. Next version it's going to be changed again to a "does this key exist? No? Add it."

I'm back at my desk doubling over everything now.

18 Dec 2025, 10:27 PM
#349
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

dbltoe:

Dropped zcplugins through FTP, went to Plugin Manager and updated, went to Modules Shipping and clicked on USPSR. That's when it failed.

I notice your installer is different from 1.5.2, and that define was not in the previous version.

I can't replicate this from a fresh 1.5.2 to 1.6.0 upgrade. What line is your debug referencing?

18 Dec 2025, 10:49 PM
#350
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,848
Plugin Contributions:
17

Re: USPS Shipping (RESTful) (USPSr)

There is no such entry in the configuration table but I am getting:```
File Contents( /home//public_html/logs/myDEBUG-adm-20251218-133749-503906-error.log)[18-Dec-2025 13:37:49 America/Chicago] Request URI: /YOUR_ADMIN/index.php?cmd=modules&set=shipping, IP address: ..., Language id 1
#0 [internal function]: zen_debug_error_handler()
#1 /includes/classes/db/mysql/query_factory.php(757): trigger_error()
#2 /includes/classes/db/mysql/query_factory.php(701): queryFactory->show_error()
#3 /includes/classes/db/mysql/query_factory.php(314): queryFactory->set_error()
#4 /includes/functions/database.php(134): queryFactory->Execute()
#5 /zc_plugins/USPSRestful/v1.6.0/catalog/includes/modules/shipping/uspsr.php(2919): zen_db_perform()
#6 /zc_plugins/USPSRestful/v1.6.0/catalog/includes/modules/shipping/uspsr.php(2081): uspsr->addConfigurationKey()
#7 /zc_plugins/USPSRestful/v1.6.0/catalog/includes/modules/shipping/uspsr.php(235): uspsr->adminInitializationChecks()
#8 /includes/functions/functions_general_shared.php(540): uspsr->__construct()
#9 /YOUR_ADMIN/modules.php(239): zen_update_modules_cache()
#10 /YOUR_ADMIN/index.php(16): require('/home/
******/...')
--> PHP Fatal error: FATAL MySQL error 1062: Duplicate entry 'MODULE_SHIPPING_USPSR_BEARER_TOKEN' for key 'unq_config_key_zen' :: INSERT INTO configuration (configuration_title, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, configuration_key, last_modified) VALUES ('USPS Active Bearer Token', '', '<strong>FOR INTERNAL USE ONLY:</strong> The active Bearer Token used to authenticate API requests to the USPS API server. (Leave blank to have the module generate a new token as needed.)', '6', '0', now(), 'MODULE_SHIPPING_USPSR_BEARER_TOKEN', now()) ==> (as called by) /includes/functions/database.php on line 134 <== in /includes/classes/db/mysql/query_factory.php on line 757.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

18 Dec 2025, 10:53 PM
#351
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

dbltoe:

There is no such entry in the configuration table but I am getting:```
File Contents( /home//public_html/logs/myDEBUG-adm-20251218-133749-503906-error.log)[18-Dec-2025 13:37:49 America/Chicago] Request URI: /YOUR_ADMIN/index.php?cmd=modules&set=shipping, IP address: ..., Language id 1
#0 [internal function]: zen_debug_error_handler()
#1 /includes/classes/db/mysql/query_factory.php(757): trigger_error()
#2 /includes/classes/db/mysql/query_factory.php(701): queryFactory->show_error()
#3 /includes/classes/db/mysql/query_factory.php(314): queryFactory->set_error()
#4 /includes/functions/database.php(134): queryFactory->Execute()
#5 /zc_plugins/USPSRestful/v1.6.0/catalog/includes/modules/shipping/uspsr.php(2919): zen_db_perform()
#6 /zc_plugins/USPSRestful/v1.6.0/catalog/includes/modules/shipping/uspsr.php(2081): uspsr->addConfigurationKey()
#7 /zc_plugins/USPSRestful/v1.6.0/catalog/includes/modules/shipping/uspsr.php(235): uspsr->adminInitializationChecks()
#8 /includes/functions/functions_general_shared.php(540): uspsr->__construct()
#9 /YOUR_ADMIN/modules.php(239): zen_update_modules_cache()
#10 /YOUR_ADMIN/index.php(16): require('/home/
******/...')
--> PHP Fatal error: FATAL MySQL error 1062: Duplicate entry 'MODULE_SHIPPING_USPSR_BEARER_TOKEN' for key 'unq_config_key_zen' :: INSERT INTO configuration (configuration_title, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, configuration_key, last_modified) VALUES ('USPS Active Bearer Token', '', '<strong>FOR INTERNAL USE ONLY:</strong> The active Bearer Token used to authenticate API requests to the USPS API server. (Leave blank to have the module generate a new token as needed.)', '6', '0', now(), 'MODULE_SHIPPING_USPSR_BEARER_TOKEN', now()) ==> (as called by) /includes/functions/database.php on line 134 <== in /includes/classes/db/mysql/query_factory.php on line 757.


So, this key is hidden and won't be visible. It must already exist in the DB, somehow. Can you uninstall and reinstall from the Plugin Module? Keep your Key/Secret combo though.
23 Dec 2025, 12:32 AM
#352
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

Full omnibus release made!

This changes... a few things....

Plugin Directory: USPS Shipping (RESTful) - Zen Cart Plugins
Github Repository: retched/ZC-USPSRestful on GitHub

=================

1.6.2 - (Originally released 2025-12-20)

Changed in 1.6.2

  • The module will no longer try to add new configuration keys blindly. Instead, it will check to see if the database key exists first and then try to insert it if it finds no match. Otherwise, it will update the value instead.

Fixed in 1.6.2

  • FINALLY got rid of the bug mentioned in [#78]. This required a soft rewrite of the "read-only" function. (Pretty much left the created "hidden" field off.) Will do more research into why this does not work.

1.6.1 - (Originally released 2025-12-18)

Fixed in 1.6.1

  • Fixed an issue that may cause upgrade/installation issues when a user upgrades an encapsulated install. (This was discovered after the 1.6.0 release. If you have a standard install, you can skip over this.)

1.6.0 - (Originally released 2025-12-17)

Changed in 1.6.0

  • Handling days are now added to the shipping days estimations. [#90]
  • Moved OAuth storage from system sessions to the database. [#88]

Fixed in 1.6.0

  • Expanded the list of APO/DPO/FPO Zip Codes.
  • Fixed the values of the services to match the newer options that were added on upgrade. (They didn't align with the changes in 1.5.2.)
  • Fixed an issue involving the calculation of services and add-ons. Values are now additive and not multiplicative. [#91]
  • Also fixed the math in the calculation of the order quote itself. (There was ambiguity in how the method's price and handling should apply. The math now works as stated in the repo Wiki.)
  • Fixed a potential issue when making service standards requests, and the resultant JSON file isn't in the proper form. [#93]
  • Fixed an issue that was preventing the configuration form from being submitted without an uninstall/reinstall on encapsulated installs during upgrading. [#78]

These are now available on both the repository and the plugins directory. A notification should also pop up in the admin backend. Whichever style you're using, keep using that style. (Do not start on an encapsulated install, then switch to a standard install. It causes a lot of conflicts as the module doesn't do a good job of determining which one is what (yet).)

7 Jan 2026, 12:17 AM
#353
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

Just installed this in 1.5.7c. No install issues that I have found

I did discover that a feather weight product had its weight set to 0, and this resulted in no shipping output. Yet the min was set to 0.

Regarding the handling time, there is not one for international. We ship only USPS 1st Class for international. I like to add in a large handling time, because USPS International is unpredictable as its government to government shipping.

Regarding the shipping cost shown, there is an option for "Retail" or "Commercial". Is the "Commercial" amount accurate, regardless of the provider used? For example, ShipRush, ShipWorks, Stamps.com, etc.

7 Jan 2026, 1:43 AM
#354
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

split63:

Just installed this in 1.5.7c. No install issues that I have found

I did discover that a feather weight product had its weight set to 0, and this resulted in no shipping output. Yet the min was set to 0.

Let me answer. First off, great set of questions.

For this I'm going to need you to provide the debug log of your 0 weight item. I need to see what the cart is sending to USPS and what USPS is doing in return. If ZenCart itself is creating an error log too, send that my way. (Use Pastebin, send to my email address (DM me for this), etc.)

split63:

Regarding the handling time, there is not one for international. We ship only USPS 1st Class for international. I like to add in a large handling time, because USPS International is unpredictable as its government to government shipping.

This is a limitation of the API. There was supposed to be a USPS International Standard API but I guess it got pulled because it disappeared off the API documentation site. For right now, only "standards" exist for domestic shipments. So even if you are configured to display travel time or estimated delivery date, the module won't send out a request to the API nor display anything because there is no way to make this API request. In a future version, maybe the next one, I might have the module just display "Varies by destination" or something similar for estimate travel time.

split63:

Regarding the shipping cost shown, there is an option for "Retail" or "Commercial". Is the "Commercial" amount accurate, regardless of the provider used? For example, ShipRush, ShipWorks, Stamps.com, etc.

Another great question and yes, Commercial is for ANY kind of online provider. This includes things like ShipRush, ShipWorks, Stamps.com (although supposedly they might offer lower), Pirate Ship, Easy Post, or even USPS Click-N-Ship on a business account. If you use any online service to get the postage quotes, you're likely using seeing the Commercial rates displayed. To further: Retail is the price you get if you walked up to the counter or use the USPS Automated Postal Counter. Contract is if you have any kind of specialized contract term for large shipping orders with the US Postal Service. Granted you are given an EPS account number when you make an account under the Customer Onboarding Portal, but it doesn't work as there is no rate initiated for you. (In fact, using that EPS account will generate a "soft" warning about "No contract found, using Commercial rates instead."

7 Jan 2026, 4:22 AM
#355
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

retched:

For this I'm going to need you to provide the debug log of your 0 weight item. I need to see what the cart is sending to USPS and what USPS is doing in return. If ZenCart itself is creating an error log too, send that my way. (Use Pastebin, send to my email address (DM me for this), etc.)
The zero weight has been set wrong for years. It worked with the old USPS module, so I suspect its not ZEN. But I fixed it by making the weight non zero, as it should have been

retched:

This is a limitation of the API. There was supposed to be a USPS International Standard API but I guess it got pulled because it disappeared off the API documentation site. For right now, only "standards" exist for domestic shipments. So even if you are configured to display travel time or estimated delivery date, the module won't send out a request to the API nor display anything because there is no way to make this API request. In a future version, maybe the next one, I might have the module just display "Varies by destination" or something similar for estimate travel time.
Its okay if no estimated time is returned for international, makes total sense. What I was asking for was the same added "handling time" for international. Since there is no USPS Int returned time, only the "Handling time" would appear. For example, I would set it to 19 days. So all USPS International customers would see 19 days.
With the previous USPS module, I just went into the PHP and hard coded the 19 days as simple text. The goal is to make those customers consider FedEx instead, which is a much more reliable and faster service.....less grief for us, as there are almost no lost packages with FedEx.

7 Jan 2026, 4:47 AM
#356
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

split63:

Its okay if no estimated time is returned for international, makes total sense. What I was asking for was the same added "handling time" for international. Since there is no USPS Int returned time, only the "Handling time" would appear. For example, I would set it to 19 days. So all USPS International customers would see 19 days.
With the previous USPS module, I just went into the PHP and hard coded the 19 days as simple text. The goal is to make those customers consider FedEx instead, which is a much more reliable and faster service.....less grief for us, as there are almost no lost packages with FedEx.

Would it be acceptable to say in your case of 19 days if it output something like: est. travel time: 19 days + local handling?

7 Jan 2026, 5:27 AM
#357
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

retched:

Would it be acceptable to say in your case of 19 days if it output something like: est. travel time: 19 days + local handling?
It has been a long time since I revisited this. I just checked and my message that I display is:
(8-30 days, depends on destination country (Not Insured, select only if you must))

Where could I hard code such a message in your module for 1st class international package?

7 Jan 2026, 6:37 AM
#358
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

split63:

It has been a long time since I revisited this. I just checked and my message that I display is:
(8-30 days, depends on destination country (Not Insured, select only if you must))

Where could I hard code such a message in your module for 1st class international package?

Aha. To put something like that in, I'd have to rewrite a bit of the code. I mentioned the 19+ days as that was the "handling time" in your example. But I can write something in there. Would adding 19 days onto those examples be sufficient? So it would be read (27 to 49+ days, depends on destination country).

7 Jan 2026, 1:33 PM
#359
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

19 days would be better than nothing, but I would probably look to hard code in some text message in the PHP.

7 Jan 2026, 2:02 PM
#360
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

As I examine the module files, I don't see where the text "USPS (First-Class Package International Service)" that is displayed to the customer. is coming from.