I've been trying to add custom shipping methods to a Magento 2 webshop, using configurations in app/code/vendor/module/etc/config.xml, app/code/vendor/module/etc/system.xml and app/code/vendor/module/Model/Carrier/Shippingmethod.php.

So, this all works, and I can select the shipping methods. Also, when NOT logged in, the checkout works fine and can get completed.

The problem is, when logged in with a (new) customer, when using one of the custom shipping methods, it throws the following error:
'Please specify a shipping method' (freely translated from original language).
The console throws the following error:

Error payment-information

When I go the following link:


It says:
"User not authorized for %resources" and a <trace> tag with a few php files:

enter image description here

Some research later, people talk about tokens and stuff, but can't figure it out.


2 Answers 2


this possibly occurs because new customers do not have an address registered, I've pass throug problems with custom shipping too, see this question, maybe helps you.

And see my example of custom shipping method.

I hope it help

  • The new customers had an address specified beforehand, so that wouldn't have been the issue. I have used your example on Git, and after some modifications that works. I still want to know why mine did not work, cause it did not vary that much from yours, only that some values were obtained by setters and yours by a rand() or hardcoded.
    – Condor
    Commented Mar 2, 2018 at 13:36
  • your shipping method code, setted on app/code/vendor/module/Model/Carrier/Shippingmethod.php, must not contain "_" and can't be bigger than 40, like @Siarhey Uchukhlebau says. Check the system.xml and config.xml too, all carriers_code must be the same, send me your github, I'll take a look.
    – lpFranz
    Commented Mar 2, 2018 at 14:41
  • Due to the fact that this is for an internship, I cannot share my code with you unfortunately. But as @Siarhey Uchukhlebau, my method code did indeed include an '_' and was longer than 40 symbols! So that was the problem. Thank you for your help!
    – Condor
    Commented Mar 2, 2018 at 15:24
  • Will you pls help me : “Please specify a shipping method” error @ magento.stackexchange.com/q/225297/57334
    – zus
    Commented May 18, 2018 at 6:15

Another reason of that issue could be long method code (>40 symbols) or multiple symbols _ in the full method code (carrier code+method code). Check this data when it sending from the checkout to the backend.

  • What exactly are you meaning by 'long method code'? The Model/Carrier/Customshipping.php code itself is 76 lines long, so >40 symbols.
    – Condor
    Commented Mar 2, 2018 at 13:34
  • 1
    @bramulous Before the 2.2.0 release the shipping_method column in the table quote_address has length 40, so if your code >40 bytes it will be cropped by mysql (during insert/update). After the 2.2.0 Magento update it's length set to the 120 byte. Commented Mar 2, 2018 at 13:39
  • Okay okay, so maybe a stupid question: how do I know if my code is longer than '40 bytes'?
    – Condor
    Commented Mar 2, 2018 at 13:41
  • @bramulous Sum the carrier_code, the method_code and one symbol _ Commented Mar 2, 2018 at 13:52
  • Ah like so! And the code indeed contained an '_' and the name was to too long. Thank you, all settled now!
    – Condor
    Commented Mar 2, 2018 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.