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

USPS Shipping (RESTful) (USPSr)

Sticky

Views: 54,962

Results 141 to 160 of 558
10 Aug 2025, 9:49 PM
#141
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
971
Plugin Contributions:
0

USPS Shipping (RESTful) (USPSr)

your module though is the only 1 not showing up when not logged in, all other shipping modules show

10 Aug 2025, 11:27 PM
#142
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)

jimmie:

your module though is the only 1 not showing up when not logged in, all other shipping modules show

Looks like I have to investigate why that is.

11 Aug 2025, 5:42 AM
#143
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)

jimmie:

that did not work, I used find and replace all instances of apis.usps.com to api.usps.com

I would be willing to bet that a look in those files would find some api.usps.com/#)(#()#)__+

When you do a find and replace, it only replaces what you tell it to. It's kinda stubborn about that.:P

So, when you told it to change, basically only the apis to api, the original file https://apis.usps.com/prices/v3/total-rates/search became *https://api.usps.com/prices/v3/total-rates/search

*You're going to need to go back and get rid of everything after https://api.com

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

12 Aug 2025, 7:19 PM
#144
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)

jimmie:

your module though is the only 1 not showing up when not logged in, all other shipping modules show

Random question: where are you getting the ID and Secret being used? https://developer.usps.com or https://developers.usps.com (note the S)

12 Aug 2025, 7:40 PM
#147
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)

jimmie:

from here https://developers.usps.com/user/13759/apps

Okay yeah I have to rewrite these urls. So leaving it as apis.usps.com is the play. It works on my naked ZenCart 2.1.0 but for some reason revocation calls are busted. I can make calls from the not logged in shipping estimator and get results but for some reason, revoking the token isn't working. I'm still playing email tag with the USPS API support team to figure out what's wrong. (I'm probably going to stop revoking the token for now and instead of making multiple requests to generate it, use server-side sessions instead to store the token.)

So all USPS APIs should be called from https://apis.usps.com/ .

I have no idea why the plain developer.usps.com site is functioning in that case as they told me it's deprecated (even I used it last a few days ago). It even still serves API credentials but the version is out of date (3.0.4 vs 3.0.6)

12 Aug 2025, 7:57 PM
#148
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)

retched:

Okay yeah I have to rewrite these urls. So leaving it as apis.usps.com is the play. It works on my naked ZenCart 2.1.0 but for some reason revocation calls are busted. I can make calls from the not logged in shipping estimator and get results but for some reason, revoking the token isn't working. I'm still playing email tag with the USPS API support team to figure out what's wrong. (I'm probably going to stop revoking the token for now and instead of making multiple requests to generate it, use server-side sessions instead to store the token.)

So all USPS APIs should be called from https://apis.usps.com/ .

I have no idea why the plain developer.usps.com site is functioning in that case as they told me it's deprecated (even I used it last a few days ago). It even still serves API credentials but the version is out of date (3.0.4 vs 3.0.6)

Like I genuinely wish I had better answers here but I cannot for the life of me figure why it's breaking this badly.

13 Aug 2025, 3:04 PM
#149
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)

jimmie:

but transit day delay still not saving

Figured out what happened here. I can't give an "easy" fix because it requires updating the configuration table in the DB and a language file but in short, I tried to recreate the wheel without thinking on it to see if something can already handle it. Now I'm trying to see about the val_function in the database.

14 Aug 2025, 2:37 AM
#151
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)

retched:

In doing this... do you also have a footer? Like the page loads normally?

Nevermind this, I forgot to make the language file available.

Can confirm, I have the module running with this change and can see quotes.

14 Aug 2025, 4:03 PM
#152
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)

Working through the night, can confirm the following:

  • The /revoke endpoint of the API, is indeed busted. (Confirmed via email with the API Support team this morning.) This means that you cannot revoke the tokens generated by the API through the /revoke API (they mentioned do it through the portal but I'm not sure what that means and I'm fairly certain they don't know what I'm using it for). This doesn't affect the operation of the module, however. I just don't like the idea of not closing the door behind you. I'm still going to leave it off the codebase for now, but in the future I will look to creating a observer to revoke the token once an order is completed or when a customer logs out. (Or maybe just forget about revoking the AuthToken as a whole. I don't think the UPSOAuth module does either...)
  • The API calls are indeed correct in the codebase as a whole (now). Speaking with the API Functional Team of USPS, quote: "We are urging customers to use developers.usps.com instead of developer.usps.com as we are slowly transitioning to the new one (developers). They have the same capabilities, functionalities, and offer the same product" And further more they state that apis.usps.com should be the endpoint going forward. api.usps.com and the developer.usps.com can still be used but it is effectively retired. (I will be updating all instruction documentation and the ZenCart instructions to reflect this shortly.) In short, this means you must make the app on developers.usps.com and the apis should point to apis.usps.com.
  • To jimmie's other post with regard to the "Hide Shipping Estimator" unless the form is filled out, that does NOT have an effect on the module itself. I tested it with the current ZenCart + Bootstrap and the quotes work fine. (I might also suggest that code be put into the main ZenCart codebase but not sure. Maybe some prefer to have all the flat rate modules available without showing the vendor ones.)

I will be making a patch in a few hours(?) addressing these three points and the addition of USPS First Class Mail Letters. (I've stalled on this but will be back working at it again... probably will have to do a soft restart as I broke the repository with the branch switches.)

16 Aug 2025, 3:49 PM
#153
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)

Added in 1.3.0

  • Added support for First Class Mail and First Class Mail International to the module. Both will be automagically added to the table of services upon upgrading to 1.3.0. Additionally added processing class flags: Letters, Flats (or Large Envelopes), and Cards (like Postcards).
  • Added a toggle to determine which API endpoint to use (the apis.usps.com endpoints should be used as the USPS API team is nudging everyone to that).
  • Added new <label> tag to checkboxes as needed.

Changed in 1.3.0

  • AuthTokens are now stored in the $_SESSION in PHP. Rather than generate a new AuthToken on every page visit, the module will check if there is already an AuthToken already made and if there is not, THEN make a new AuthToken at that point. (AuthTokens last for roughly eight hours. So long as there aren't more than 60 requests per hour. If there is a chance you might go above that, no problem... simply request the API Team to provision you more requests.)
  • As part of the AuthToken request, the module will now send the version of the module and the ZenCart version as the USERAGENT portion of the CURL request.
  • Running the v0.0.0 version from the Repository will now have a warning banner appear in the admin backend. That warning uses the messageStack system and will link to the ZenCart thread and this repository on GitHub.

Breaking in 1.3.0

  • Removed the module's ability to revoke AuthTokens in the module. (USPS API Support Team reported that there is a breaking fault on their side. To avoid the headaches, I just removed the revokeToken command and procedure. Will likely add in again later.)

Submitted to ZenCart directory, now available for download on GitHub.

16 Aug 2025, 4:38 PM
#154
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)

And in my rush to make the First Class Mail Letter available, I forgot to re-add in the four cent differential between the Metered Mail and Non-Metered Mail Rates.

I will push this out in a future version but in case anyone wanted to make the change now, open /catalog/includes/modules/shipping/uspsr.php (either encapsulated or unencapsulated) and make the following change around line 392.

Add the following below the line 391:

            if ($this->usps_countries == 'US') {// Only applies to US
                # Bug fix for letters since the metered rate is four cents less.
                $_letter['rates'][0]['price'] += 0.04;
                $_letter['totalBasePrice'] += 0.04;
            }
23 Aug 2025, 7:05 AM
#155
siliconbug avatar

siliconbug

Zen Follower

Join Date:
Apr 2009
Posts:
125
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

Is version 1.3.0 compatible only with ZenCart 2.1.0?
The README.html states: "Released August 16, 2025 for ZenCart 2.1.0."

23 Aug 2025, 7:28 AM
#156
siliconbug avatar

siliconbug

Zen Follower

Join Date:
Apr 2009
Posts:
125
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

Update:
I'm using the same non-encapsulated version for ZenCart 1.5.5+.

I don’t use the First-Class Letter service, but I did try adding the related code anyway.
Regardless of whether the code is included or not, I’m still getting the same error log.
It’s quite lengthy, so let me know if you'd like me to post it here.

23 Aug 2025, 7:30 AM
#157
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)

siliconbug:

Update:
I'm using the same non-encapsulated version for ZenCart 1.5.5+.

I don’t use the First-Class Letter service, but I did try adding the related code anyway.
Regardless of whether the code is included or not, I’m still getting the same error log.
It’s quite lengthy, so let me know if you'd like me to post it here.

Need to see the errorLog to help with this.

23 Aug 2025, 7:37 AM
#158
siliconbug avatar

siliconbug

Zen Follower

Join Date:
Apr 2009
Posts:
125
Plugin Contributions:
0

Re: USPS Shipping (RESTful) (USPSr)

ZC 1.5.8a w/ php 7.4
I can still get the estimate shipping costs correctly.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_DIMMENSIONS - assumed 'MODULE_SHIPPING_USPSR_LTR_DIMMENSIONS' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2122.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_DMST_LETTER_SERVICES - assumed 'MODULE_SHIPPING_USPSR_DMST_LETTER_SERVICES' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2157.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_INTL_LETTER_SERVICES - assumed 'MODULE_SHIPPING_USPSR_INTL_LETTER_SERVICES' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2158.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_PROCESSING - assumed 'MODULE_SHIPPING_USPSR_LTR_PROCESSING' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2257.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS - assumed 'MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2260.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS - assumed 'MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2261.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS - assumed 'MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2262.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS - assumed 'MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2263.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS - assumed 'MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2264.

[23-Aug-2025 00:21:51 Canada/Pacific] Request URI: /index.php?main_page=shopping_cart, IP address: x.x.x.x, Language id 1
#1 uspsr->_getQuote() called at [/zc/includes/modules/shipping/uspsr.php:376]
#2 uspsr->quote() called at [/zc/includes/classes/shipping.php:201]
#3 shipping->quote() called at [/zc/includes/modules/shipping_estimator.php:151]
#4 require(/zc/includes/modules/shipping_estimator.php) called at [/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php:229]
#5 require(/zc/includes/templates/bootstrap/templates/tpl_shopping_cart_default.php) called at [/zc/includes/templates/bootstrap/common/tpl_main_page.php:233]
#6 require(/zc/includes/templates/bootstrap/common/tpl_main_page.php) called at [/zc/index.php:94]
--> PHP Warning: Use of undefined constant MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS - assumed 'MODULE_SHIPPING_USPSR_LTR_MACHINEABLE_FLAGS' (this will throw an Error in a future version of PHP) in /zc/includes/modules/shipping/uspsr.php on line 2265.
 
23 Aug 2025, 3:38 PM
#159
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)

Something didn't run correctly. One moment.

Was this a fresh install or an upgrade?

23 Aug 2025, 3:55 PM
#160
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)

siliconbug:

Is version 1.3.0 compatible only with ZenCart 2.1.0?
The README.html states: "Released August 16, 2025 for ZenCart 2.1.0."

To answer this, the module is still compatible with older versions of ZC up to 1.5.5 (anything before that and it's a mystery bag).