verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

FedEx: Rate Error: There are no valid services available #58

Closed Stalex89 closed 2 years ago

Stalex89 commented 3 years ago

Description I'm using headless Craft CMS 3 for backend + Nuxt.js as frontend. I want to add FedEx shipping option for the website. Currently I'm using FedEx test account for development. The problem is that I see no Fedex shipping methods/rates on the frontend.

Shipping country: The Netherlands

When I'm trying to get cart response in Postman, I see the following:

Screenshot 2021-02-18 at 10 56 59

I follower the documentation and I think I've configured everything. Can you please tell me if I have something extra to configure?

Thank you!

Steps to reproduce

  1. Install Postire plugin
  2. Configure Postie (enable debug and error display)
  3. Create a product
  4. Add product to cart
  5. Call '/?action=commerce/cart/get-cart&note=from+ajax' from Postman

Additional info

Additional context My configuration: Screenshot 2021-02-18 at 11 43 23 Screenshot 2021-02-18 at 11 45 02 Screenshot 2021-02-18 at 11 45 53 Screenshot 2021-02-18 at 11 46 10 Screenshot 2021-02-18 at 11 49 06 Screenshot 2021-02-18 at 11 50 49

engram-design commented 3 years ago

Looks like everything is setup correctly. Can you consult the storage/logs/postie.log file?

What test credentials are you using? I know sometimes this can be finicky depending on the country of origin your FedEx account is created on.

What origin and destination addresses are you testing with?

Stalex89 commented 3 years ago

@engram-design Thank you for the quick response, here are the latest items from the storage/logs/postie.log:

$_POST = []
2021-02-18 10:52:57 [-][-][-][info][postie] FedEx: Sending payload: `{}`.
2021-02-18 10:53:01 [-][-][-][error][postie] FedEx: Rate Error: There are no valid services available. 
2021-02-18 10:53:01 [-][-][-][error][postie] FedEx: Rate Error: The origin state/province code has been changed.  
2021-02-18 10:53:01 [-][-][-][error][postie] FedEx: Rate Error: The destination state/province code has been changed.  
2021-02-18 10:52:57 [-][-][-][info][application] $_GET = [
    'action' => 'commerce/cart/get-cart'
    'note' => 'from ajax'
]

$_POST = []
2021-02-18 10:59:01 [-][-][-][info][postie] FedEx: Sending payload: `{}`.
2021-02-18 10:59:02 [-][-][-][error][postie] FedEx: Rate Error: There are no valid services available. 
2021-02-18 10:59:02 [-][-][-][error][postie] FedEx: Rate Error: The origin state/province code has been changed.  
2021-02-18 10:59:02 [-][-][-][error][postie] FedEx: Rate Error: The destination state/province code has been changed.  
2021-02-18 10:59:01 [-][-][-][info][application] $_GET = [
    'action' => 'commerce/cart/get-cart'
    'note' => 'from ajax'
]

$_POST = []
2021-02-18 11:51:52 [-][1][-][info][postie] FedEx: Sending payload: `{}`.
2021-02-18 11:51:55 [-][1][-][error][postie] FedEx: Rate Error: There are no valid services available. 
2021-02-18 11:51:55 [-][1][-][error][postie] FedEx: Rate Error: The origin state/province code has been changed.  
2021-02-18 11:51:55 [-][1][-][error][postie] FedEx: Rate Error: The destination state/province code has been changed.  
2021-02-18 11:51:52 [-][1][-][info][application] $_GET = []

$_POST = []
2021-02-18 11:51:55 [-][1][-][info][postie] FedEx: Sending payload: `{}`.
2021-02-18 11:51:56 [-][1][-][error][postie] FedEx: Rate Error: There are no valid services available. 
2021-02-18 11:51:56 [-][1][-][error][postie] FedEx: Rate Error: The origin state/province code has been changed.  
2021-02-18 11:51:56 [-][1][-][error][postie] FedEx: Rate Error: The destination state/province code has been changed.  
2021-02-18 11:51:55 [-][1][-][info][application] $_GET = []

$_POST = []

This is the link I was using for creating test account: https://www.fedex.com/wpor/wpor/editConsult.do

Screenshot 2021-02-18 at 12 22 54

The destination addresses I'm using is in The Netherlands as well: Screenshot 2021-02-18 at 12 29 20

Has it something to do with the empty payload it's sending to FedEx?

engram-design commented 3 years ago

No need to worry about the empty payload, that's just a logging issue I need to sort.

I'm interested in these lines:

2021-02-18 11:51:55 [-][1][-][error][postie] FedEx: Rate Error: The origin state/province code has been changed.  
2021-02-18 11:51:55 [-][1][-][error][postie] FedEx: Rate Error: The destination state/province code has been changed. 

I've not seen that before, but that's coming back from FedEx.

engram-design commented 3 years ago

I would also double check your details are working via https://www.fedex.com/en-us/online/rating.html

I've just tested with a Netherlands testing account, with origin/destination Netherlands addresses, and seems to be returning rates.

image

Stalex89 commented 3 years ago

Ok, I double checked the ratings on the website, looks like it should work:

Screenshot 2021-02-18 at 13 53 14

Just in case I also checked if the problem can be because I'm using Nuxt.js or Postman, but I got the same error in the Craft Commerce example checkout as well:

Screenshot 2021-02-18 at 13 53 55

Stalex89 commented 3 years ago

Ok, I have installed the clear Craft with Craft Commerce and Postie. Still have the same error.

After diving into a code a little bit, i found the following:

1) First error of sending {} payload occurs in the /src/base/Provider.php in the line 615 Dumping the Json::encode($payload) as it is in the plugin returns an empty object, while dumping just the $payload returns an RateRequest object:

Screenshot 2021-02-23 at 12 25 57 Screenshot 2021-02-23 at 12 26 07 Screenshot 2021-02-23 at 12 26 28 Screenshot 2021-02-23 at 12 26 40

2) In the /jeremy-dunn/php-fedex-api-wrapper/src/FedEx/RateService/Request.php in line 29 the $response is following: Screenshot 2021-02-23 at 12 34 37 Screenshot 2021-02-23 at 12 34 56

I see the $rateRequest is passing an object: Screenshot 2021-02-23 at 12 38 55

Also tried to change the shipping/billing address to one you set in the screenshot, nothing changed:

Screenshot 2021-02-23 at 12 52 41

Is it something to be additionally set up in the Fedex account (apart from the sender address) in order for this plugin to work? Does the test account work with the plugin? Also does the plugin work on the localhost?

UPD: When looking at the test credentials creation page I've noticed some small note: Screenshot 2021-02-23 at 13 56 36

So I have before I had only 'Netherlands' Intra Country test key, now I laso created 'Global' one, Still no luck after applying global key in the settings

engram-design commented 3 years ago

Hmmm, I wonder if it's something to do with your test credentials, or something I'm not factoring in on my end. I did note the Global vs Netherlands option and I tried both.

All you should need is:

If you can shoot me an email to web@verbb.io I'm happy to share my test credentials with you to rule that out.

Stalex89 commented 3 years ago

Thank you for the keys provided,

Good news, the key for Netherlands works for me: Screenshot 2021-02-23 at 23 17 16

the Global/US key throws an error: Screenshot 2021-02-23 at 23 39 44