- Issue created by @rhovland
- πΊπΈUnited States rhovland Oregon
I have not found any PHP projects that implement the API in PHP except this one which is more of a script than a library
https://github.com/JohnAwesomeJr/php-ups-api-rate-oauth2However I did come across this project for UPS which mentions it was partly generated using Jane using the published UPS OpenAPI spec.
https://github.com/ShipStream/ups-rest-php-sdk#developmentUSPS publishes OpenAPI spec files for their API. We could use that to generate most of the code for a library using Jane.
https://developer.usps.com/sites/default/files/apidoc_specs/US_Postal_Se...
https://github.com/janephp/janephp - πΊπΈUnited States bill.zero
They may have turned off the Web Tools API last night. My rate requests are not getting responses.
- πΊπΈUnited States bill.zero
They apparently turned Web Tools back on. Watchdog has 200 status on USPS responses since 14 Jan 2025.
- πΊπΈUnited States bobburns
It seems easiest to use the Oauth2_client to authenticate integrating the existing Commerce USPS module and adding the new API calls.
Is anyone working on this???
- πΊπΈUnited States kevinhbruce Maryland
We're using the USPS module in our bookstore, so we're interested in the update as well.
- πΊπΈUnited States rhovland Oregon
Ok looks like we now have a end of service date
"The Web Tools API platform will be retired on January 25, 2026."
https://www.usps.com/business/web-tools-apis/welcome.htmThe first thing that needs to happen is a PHP API client being made
Once there is a client (the script I linked is not sufficient) then a new major version of this module can be created and adjusted to use the API client.
- πΊπΈUnited States rhovland Oregon
I'm going to put some time into evaluating janephp and openapi-generator and create a library for USPS using one of these generators. Using a generator will also help with adapting to subsequent changes to the API as we can just feed the new spec into it and audit the changes made for accuracy.
Once the library is made I'll create a new version of the USPS module and have the maintainers merge that into this project.
This is going to take a few months as I will be working on this in the spare time between projects at work. But now that there's an end date the urgency of this has placed this higher on my list.
- πΊπΈUnited States bobburns
The first issue is Oauth2 authentication. I have installed the Oauth2_client and modified the schema yml file to add the crid and mid needed to get a token, however the form did not change even after clearing the cache, but I did not uninstall and reinstall the new modified version.
It appears the API is the same but there is an issue of xml along with the Oauth2 authentication.
USPS lists the deprecated and new calls that can be manually changed.
There is a notice that USPS works with Oauth2 v3 and it appears Drupal 10 Oauth2_client is v4 possibly. Do not know if it is backward compatible if so.
My credentials work as I used that first script to test a flow connection - it connected but threw an error on the code for request
I have not modified the Oauth2 client for the USPS requests in commerce_usps yet because until I get the API information config section working with the four values I have ready to there it matters not. There is also an issue it may use the "key" module.
Once I do that the Oauth2_client will see the client and register it.
Does anyone know if I need to do more than modify the schema yml to get the config file to change???
- πΊπΈUnited States bill.zero
@bobburns asked "Where is the live and test mode urls stored or entrered?"
[site-root]/admin/commerce/config/shipping/methods/usps/edit is where the live url and username are stored, under the form field names "commerce_usps_connection_address" and "commerce_usps_user", respectively.I don't remember where the test url is.
- πΊπΈUnited States bill.zero
I just received my biweekly warning from USPS API Communications about their Web Tools platform shutdown in Jan 2026.
If I was capable of programming a new module to replace Commerce USPS, I would, but I just don't know PHP well enough to do that. I've done a few alters, but that's about it.
Is there going to be a 7.x-capable replacement for it with OAuth 2 login in time? It's ok if there won't be; I can develop some conditions in a rule and create our own estimates of customer shipping costs. In time those will get close to actual shipping costs.
If someone were to update Commerce USPS, however, I may be capable of semi-duplicating those to update the Commerce UPS module that has been non-function due to failed OAuth 2 logins since January of this year.
I truly appreciate the work of anyone who has this or is putting this on their plate!
Cheers
- πΊπΈUnited States rhovland Oregon
A 7.x compatible version is definitely not going to happen with it being EOL. I have no knowledge of it either. I've finished up my current project and this is my next project.
- πΊπΈUnited States astringer
@rvhovland -- does it look like the change to the new USPS API (in D10/11) will happen in time? (I won't hold you to it. :-) Feel free to give me odds rather than a yes/no.
I ask because I have a small non-profit still on Drupal and if it's unlikely, I need to prepare my client so they can can change to UPS or Fedex, and this will be a workflow change for them, so I want to give them time to prepare.
I really appreciate that you're working on it. Happy to test or help in any way.
Thanks.
- πΊπΈUnited States rhovland Oregon
A substantial number of packages are shipped via USPS for us, especially internationally. This is critical to our business. We ship around 200-400 packages a day.
The big maybes here are that building a PHP API is not something I have done before. It helps that there are generators I can use because UPS provides an OpenAPI spec.
The actual job of modifying this module to use the new API should be within my skillset.
The last challenge will be either getting maintainer status or having the cooperation of existing maintainers to publish the module. I have experience with both of these things.
At this point in time I'm confident I can make the end of year deadline. I would however encourage everyone who uses USPS to have a backup available due to potential volatility of the company's future itself.
- πΊπΈUnited States bobburns
The existing code can be used once authentication is complete to Oauth2. I have completed this step using the Oauth2_client.
A PHP API is not needed in actuality as the new USPS API does both PHP or XML
I went through a challenge to get the first authentication to wotk from USPS.
The existing in API can modified.
You need a usps business account to even get API credentials to request Oauth2 access, so I am not holding my breath this upgrade will get done by the maintainers
Is anyone actually working on this besides me, and I am sorry I cannot share code.