nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.14k stars 5.25k forks source link

UPS plugin failing to retrieve rates #7119

Closed danFbach closed 4 months ago

danFbach commented 5 months ago

nopCommerce version: 4.60.6

Official nop UPS plugin is failing to retrieve rates. I believe this just started in the last day.

Here's the error log.

Shipping (UPS (United Parcel Service)). Error while getting UPS rates
Could not deserialize the response body stream as Nop.Plugin.Shipping.UPS.API.Rates.RATEResponseWrapper.

Status: 200
Response: 

I'm guessing that the problem is occurring in /API/Rates/RateClient.cs in the method protected virtual async System.Threading.Tasks.Task<ObjectResponseResult<T>> ReadObjectResponseAsync<T>(...) line 200 Not sure how much more i can debug on my own as this appears to be generated code

//----------------------
// <auto-generated>
//     Generated using the NSwag toolchain v13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
danFbach commented 5 months ago

Correction, the oldest occurrence i have of this error is 03/19/2024 10:28:34 PM CST

Also, just checked their API Updates and there is nothing past January...but they don't always post changes.

danFbach commented 5 months ago

I think this is also being brought up on the latest comment of #6712

danFbach commented 5 months ago

In reference to that comment, they suggest just removing the Alert object from RateResponse_Response. Of course this will work, but is not an ideal solution. Changing it from

public System.Collections.Generic.ICollection<Response_Alert> Alert { get; set; }

to

public Response_Alert Alert { get; set; }

Also allows it to work.

danFbach commented 5 months ago

https://developer.ups.com/api/reference?loc=en_US#operation/Rate Official UPS documentation still defines Alert as an array of objects - so the existing implementation should work, and my changes should not fix it. I've got a ticket open with UPS to get some answers.

danFbach commented 5 months ago

image

It can be EITHER a single object OR an array. wtf. not sure how a deserializer can compensate for that

danFbach commented 5 months ago

In fact, multiple fields can be arrays or single objects - probably other fields that aren't listed here too. If the response contains <= 1 result, it just returns the single object instead of an array with one object. image

skoshelev commented 5 months ago

Hi @danFbach. Thank you for your help. We also don’t know how this is possible, but this is not the first such object that can have a dual structure in the new API. Therefore, we were forced to make our implementation of some fields, such as RateResponse_RatedShipment.RatedPackage. We will make the necessary changes soon

skoshelev commented 4 months ago

Closed #7119

sangeet-shah commented 4 months ago

@skoshelev @AndreiMaz

This plugin still having issue.

image

image

I getting error while RatedShipment property get as object from UPS response.

{ "RateResponse": { "Response": { "ResponseStatus": { "Code": "1", "Description": "Success" }, "Alert": [ { "Code": "113060", "Description": "The weight exceeds the limit for the UPS Letter/Envelope rate and will be rated using the weight." }, { "Code": "110971", "Description": "Your invoice may vary from the displayed reference rates" } ], "TransactionReference": { "CustomerContext": "testing", "TransactionIdentifier": "iewssoat24d2WM6mXBy9YL" } }, "RatedShipment": { "Service": { "Code": "65", "Description": "" }, "RatedShipmentAlert": [ { "Code": "113060", "Description": "The weight exceeds the limit for the UPS Letter/Envelope rate and will be rated using the weight." }, { "Code": "110971", "Description": "Your invoice may vary from the displayed reference rates" } ], "BillingWeight": { "UnitOfMeasurement": { "Code": "LBS", "Description": "Pounds" }, "Weight": "1.0" }, "TransportationCharges": { "CurrencyCode": "USD", "MonetaryValue": "126.36" }, "ServiceOptionsCharges": { "CurrencyCode": "USD", "MonetaryValue": "0.00" }, "TotalCharges": { "CurrencyCode": "USD", "MonetaryValue": "126.36" }, "NegotiatedRateCharges": { "TotalCharge": { "CurrencyCode": "USD", "MonetaryValue": "125.10" } }, "RatedPackage": [ { "TransportationCharges": { "CurrencyCode": "USD", "MonetaryValue": "0.00" }, "ServiceOptionsCharges": { "CurrencyCode": "USD", "MonetaryValue": "0.00" }, "TotalCharges": { "CurrencyCode": "USD", "MonetaryValue": "0.00" }, "Weight": "1.0", "BillingWeight": { "UnitOfMeasurement": { "Code": "LBS", "Description": "Pounds" }, "Weight": "1.0" } } ] } } }

skoshelev commented 4 months ago

Hi @sangeet-shah. This month, UPS updated both the API and documentation; according to the new specification, such problems should no longer exist. We have updated the code to use API version v2403.

Closed #7119