Zen Cart Logo
Forums / Addon Shipping Modules / UPS Shipping using RESTful/OAuth API [Support Thread]

UPS Shipping using RESTful/OAuth API [Support Thread]

Sticky

Views: 45,473

Results 1 to 20 of 220
14 Jun 2023, 2:26 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,103
Plugin Contributions:
56

UPS Shipping using RESTful/OAuth API [Support Thread]

FWIW, I'm getting close to having a beta version of the UPS shipping module that makes use of the now-current RESTful API using OAuth authentication. Once the beta is published, I'll be asking for help in the validation of its interface as I don't have access to any non-US sites that make use of UPS shipping nor do I have access to a site that uses negotiated rates.

The plugin's GitHub repository is https://github.com/lat9/upsoauth and instructions as to how to receive the OAuth Client ID and Client Secret can be found here: https://github.com/lat9/upsoauth/wiki/Creating-Your-OAuth-Client-ID-and-Client-Secret

14 Jun 2023, 6:05 PM
#2
dbltoe avatar

dbltoe

Totally Zenned

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

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

@lat9
Thanks so much for all you do for the ZC family.
I am reminded of a saying of my grandmother's> You can't pour coffee from an empty pot.
We are a vessel and, if we are not whole, we have a problem filling someone else's.
Make sure you take the time needed for yourself.:hug:

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

14 Jun 2023, 8:35 PM
#3
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Hi @lat9,

I'm so lucky to see this post today. Thanks for your contribution.

I have followed your detailed guide to create my OAuth app. I'm more than happy to test this plug-in.

15 Jun 2023, 9:15 AM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,717
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

I also have a customer who will want to use this as soon as it's ready. Thanks @lat9!

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

15 Jun 2023, 2:53 PM
#5
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,103
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Let the games begin! I've just published (on GitHub) a pre-release v0.0.0: https://github.com/lat9/upsoauth/releases/tag/v0.0.0

Follow the instructions in that GitHub repository's Wiki (see the first post for direct link) to retrieve your UPS OAuth credentials.

I have not validated:

  • On Zen Cart versions prior to 1.5.8a. If you're validating on a previous Zen Cart version, please post here so that I'm aware of the versions on which it's been tested.
  • Negotiated Rates. I'm *pretty *sure (i.e. not sure) that there are different response fields that will come back with negotiated rates. If you have an an account with UPS that has negotiated rates, please let me know.
  • Non-US "Origins". I don't think that there will be issues, but wanted all to know.

The majority of the documentation will remain online on the module's GitHub repository (https://github.com/lat9/upsoauth), but I'll be getting a minimal readme together for the v1.0.0 release.

The pre-release module displays its name a United Parcel Service (OAuth), enabling you to have it enabled side-by-side with the current (and to-be-deprecated) UPS-XML version and distinguish the two module's outputs. The OAuth suffix will be removed for the v1.0.0 release.

16 Jun 2023, 3:58 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,103
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

v0.0.1 (still beta/pre-release) now available on GitHub: https://github.com/lat9/upsoauth/releases/tag/v0.0.1

This version now returns negotiated rates if so configured, corrects the number of parameters required to zen_get_zone_code for Zen Cart versions prior to 1.5.8 and removes use of the PHP null-coalesce operation since that operator wasn't available until PHP 7.0.

16 Jun 2023, 5:57 PM
#7
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Hi @lat9,

I just tried v0.0.1 from Github, but I cannot make it work.

Test #1: zc 1.5.7d & PHP 7.4

After I entered my Client ID, Client Secret, UPS shipper number, I cannot get a shipping quote (no UPS section showing up). I tried to enable debug but no log files were generated. I tried both test mode and production mode, no difference.

Test #2: zc 1.5.8 & PHP 8.0

Same result. No quote, no debug files...

16 Jun 2023, 6:11 PM
#8
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Update: I spoken too early.

In the "estimate shipping" section in the shopping cart, I cannot get a UPS quote. No UPS section is displayed.

But if I tried to checkout, I can see the UPS quote there.

Still no debug/log files generated, even I enable the debug option.

zc 1.5.7d

16 Jun 2023, 6:21 PM
#9
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,967
Plugin Contributions:
8

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

njcyx:

Update: I spoken too early.

In the "estimate shipping" section in the shopping cart, I cannot get a UPS quote. No UPS section is displayed.

But if I tried to checkout, I can see the UPS quote there.

Still no debug/log files generated, even I enable the debug option.

zc 1.5.7d

the debug option works.

if you are not getting any quotes that suggests something is failing prior to the quote. in which case you should see a ZC debug log.

if you are not seeing that log, i would talk to your hosting company. systems should generate error logs; if they do not then there is something wrong for the system config and you need to talk to your hosting company about being able to see them and track them down.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

16 Jun 2023, 6:48 PM
#10
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Hi @carlwhat

Sorry, I spoken too early again.

I only used "Display Log Files" function in zc admin page to view the log files, and I cannot find it there. After I used FTP to view the /logs folder, I can find the UPS log files there. Format is upsoauth-2023xxxx.log.

Can you get a UPS shipping quote in the "estimate shipping" page in the shopping cart?

Hi @lat9,

-Here is my input regarding the negotiated rates. Our UPS account has a negotiated rates. I tried all your provided Customer Classification Code options, here is what I found:

For 00, 05 and 06, they display the same rate (negotiated rate). But for 01, 04 and 53, I have three different rates. Here is the compare result:

00<53<04<01

Not sure why there are four different rates under my UPS account.

  • I have one more input for the pickup method. Here are five options available in this plug-in:

Daily Pickup, Customer Counter, One Time Pickup, On Call Air Pickup, Letter Center and Air Service Center

Daily Pickup, Customer Counter, One Time Pickup: no rate changes.

On Call Air Pickup: $13 is added on every tiers.

Letter Center and Air Service Center: Ground and 3 day select options were gone. No price difference.

16 Jun 2023, 7:01 PM
#11
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,103
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

njcyx:

Hi @carlwhat

Sorry, I spoken too early again.

I only used "Display Log Files" function in zc admin page to view the log files, and I cannot find it there. After I used FTP to view the /logs folder, I can find the UPS log files there. Format is upsoauth-2023xxxx.log.

Can you get a UPS shipping quote in the "estimate shipping" page in the shopping cart?

Hi @lat9,

-Here is my input regarding the negotiated rates. Our UPS account has a negotiated rates. I tried all your provided Customer Classification Code options, here is what I found:

For 00, 05 and 06, they display the same rate (negotiated rate). But for 01, 04 and 53, I have three different rates. Here is the compare result:

00<53<04<01

Not sure why there are four different rates under my UPS account.

  • I have one more input for the pickup method. Here are five options available in this plug-in:

Daily Pickup, Customer Counter, One Time Pickup, On Call Air Pickup, Letter Center and Air Service Center

Daily Pickup, Customer Counter, One Time Pickup: no rate changes.

On Call Air Pickup: $13 is added on every tiers.

Letter Center and Air Service Center: Ground and 3 day select options were gone. No price difference.
For the "Display Log Files" to display these logs, you'll need to add the upsoauth- prefix to Configuration :: Logging :: Display Logs: Included File Prefixes.

I can't speak to the vagaries of the different UPS rates based on the Customer Classification Code, but I've found the 04 (Retail) rates return the same as those published on the ups.com "Quote" tool. You just need to choose the classification code that 'works' for what you want to charge your customers.

I, too, saw that On Call Air Pickup adds $13 for each order. If that's the means that your store uses to get the packages in UPS' hands, then that's what they charge.

Ditto on the Package Types; I'll surmise that certain package types aren't supported for some of the UPS shipping methods.

P.S. For negotiated rates, be sure to use 0.0.1 or later.

16 Jun 2023, 7:55 PM
#12
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Hi @lat9,

Thanks for your information.

I have one more question. Is it normal that UPS quote is not showing under the estimate shipping section in the shopping cart?

16 Jun 2023, 8:07 PM
#13
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,967
Plugin Contributions:
8

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

njcyx:

Hi @lat9,

Thanks for your information.

I have one more question. Is it normal that UPS quote is not showing under the estimate shipping section in the shopping cart?

that is not normal...

there should be a log as to why it is not showing up.

on 1 of my test sites running the bootstrap template, it shows up just fine...

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

16 Jun 2023, 8:21 PM
#14
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Hi @carlwhat,

Thanks! I took a look at the log file and now I know the reason why it doesn't show up on my end now.

#1: In the estimate shipping quote page, if I only entered the zip code, but not choose any US states (Please Select), I can get the USPS and FedEx shipping quote.

#2: If I entered the zip code and choose a proper US state, I can get USPS, UPS and FedEx quote.

#3: If I entered the zip code but choose a wrong US state, I can get USPS and FedEx quote.

In other word, I need to select the correct state in the estimate shipping quote page, otherwise there will be no UPS quote.

16 Jun 2023, 8:29 PM
#15
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,717
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

You really have to enter all three for the system to work properly. You can get lucky by entering partial data, but the system expects all three.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

16 Jun 2023, 9:24 PM
#16
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,103
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

njcyx:

Hi @lat9,

Thanks for your information.

I have one more question. Is it normal that UPS quote is not showing under the estimate shipping section in the shopping cart?
For this UPS shipping module, no UPS quote will be shown if no such quote is returned. That can happen if your configuration settings (like the origin elements) or the state/zipcode aren't recognized by UPS.

Note, too, that if you're requesting Negotiated-rate quotes from UPS that UPS expects country, state and zip to be entered. If you're in a state (like Florida) that allows one zip-code to cross multiple counties (!), you might need to enter the city as well to get a quote returned.

19 Jun 2023, 2:27 PM
#17
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

Hi @swguy and @lat9, thanks for your information.

21 Jun 2023, 2:52 PM
#18
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,103
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

The first (v1.0.0) 'official' release of the UPS RESTful/OAuth shipping module is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=2374

27 Jun 2023, 3:08 PM
#19
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
370
Plugin Contributions:
0

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

I received a warning today. Plug-in version v1.0.0. Zc 1.5.7d. PHP 7.4

[26-Jun-2023 14:39:21 America/New_York] Request URI: /ajax.php?act=ajaxOnePageCheckout&method=updateShipping
#1 upsoauth->getConfiguredUpsQuotes() called at [/includes/modules/shipping/upsoauth.php:383]
#2 upsoauth->quote() called at [/includes/classes/shipping.php:174]
#3 shipping->quote() called at [/includes/classes/ajax/zcAjaxOnePageCheckout.php:163]
#4 zcAjaxOnePageCheckout->updateShipping() called at [/ajax.php:85]
--> PHP Warning: Invalid argument supplied for foreach() in /includes/modules/shipping/upsoauth.php on line 642.

Line 642 is the following:

foreach ($all_ups_quotes->RateResponse->RatedShipment as $next_shipment) {

I added one line above this section and it seems working fine:

if (is_iterable($all_ups_quotes->RateResponse->RatedShipment)) {
foreach ($all_ups_quotes->RateResponse->RatedShipment as $next_shipment) {
...
}
}

27 Jun 2023, 5:33 PM
#20
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,103
Plugin Contributions:
56

Re: UPS Shipping using RESTful/OAuth API [Support Thread]

njcyx:

I received a warning today. Plug-in version v1.0.0. Zc 1.5.7d. PHP 7.4

[26-Jun-2023 14:39:21 America/New_York] Request URI: /ajax.php?act=ajaxOnePageCheckout&method=updateShipping
#1 upsoauth->getConfiguredUpsQuotes() called at [/includes/modules/shipping/upsoauth.php:383]
#2 upsoauth->quote() called at [/includes/classes/shipping.php:174]
#3 shipping->quote() called at [/includes/classes/ajax/zcAjaxOnePageCheckout.php:163]
#4 zcAjaxOnePageCheckout->updateShipping() called at [/ajax.php:85]
--> PHP Warning: Invalid argument supplied for foreach() in /includes/modules/shipping/upsoauth.php on line 642.

Line 642 is the following:

foreach ($all_ups_quotes->RateResponse->RatedShipment as $next_shipment) {

I added one line above this section and it seems working fine:

if (is_iterable($all_ups_quotes->RateResponse->RatedShipment)) {
foreach ($all_ups_quotes->RateResponse->RatedShipment as $next_shipment) {
...
}
}
I've created a tracking issue on the shipping module's GitHub repository (https://github.com/lat9/upsoauth/issues/7). Any chance that you've got a upsoauth*.log file from that errant transaction?