Magento – payment-information 400 bad request when product quantity is bigger (or equal) than 3

checkoutdebuggingmagento2

I've recently reviewed a lot of 400 errors on payment-information API

My problem is a little different, since it happens only when the product quantity is 3 or more.

I select the shipping method (the problem occurs with all shipping methods) and when I click the "place order" button I got this error (sorry the language is Italian)

error after placing order

if I set the amount to 2 or less (even for multiple products) the order is placed correctly.

So it's OK to buy:

  • 2 item A
  • 1 item B
  • 2 item C

but it is not OK to buy:

  • 3 items A
  • 1 item B
  • 2 items C

I'm unable to debug this issue, since the only trace I get is this one:

  #0 [*MAGENTO_PATH*]/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Checkout\Model\PaymentInformationManagement->savePaymentInformationAndPlaceOrder(34, Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))↵#
    #1 [*MAGENTO_PATH*]/var/generation/Magento/Checkout/Model/PaymentInformationManagement/Interceptor.php(26): Magento\Checkout\Model\PaymentInformationManagement\Interceptor->___callPlugins('savePaymentInfo...', Array, Array)↵#
    #2 [internal function]: Magento\Checkout\Model\PaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder(34, Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))↵#
    #3 [*MAGENTO_PATH*]/vendor/magento/module-webapi/Controller/Rest.php(307): call_user_func_array(Array, Array)↵#
    #4 [*MAGENTO_PATH*]/vendor/magento/module-webapi/Controller/Rest.php(216): Magento\Webapi\Controller\Rest->processApiRequest()↵#
    #5 [*MAGENTO_PATH*]/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(37): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))↵#
    #6 [*MAGENTO_PATH*]/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))↵#
    #7 [*MAGENTO_PATH*]/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()↵#
    #8 [*MAGENTO_PATH*]/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))↵#
    #9 {main}

but no actual errors are stored in logfiles.

Can someone help me debug this problem?

Thanks a lot

UPDATE 1:
The system is crashing with the error message "you cannot order more than 5 items" (max order size is set to 5 by me)
If I order 3, 4 or 5 I get this error in the e->getMessage() of the exception thrown by magento/module-checkout/Model/PaymentInformationManagement.php:71
If I order more than 5 items I get the standard frontend error. is it possible that the amount of items is doubled when I order a Simple product associated to a Configurable product?

Best Answer

The original message is being overwritten as you can see in here:

 $this->savePaymentInformation($cartId, $email, $paymentMethod, $billingAddress);
        try {
            $orderId = $this->cartManagement->placeOrder($cartId);
        } catch (\Exception $e) {
            throw new CouldNotSaveException(
                __('An error occurred on the server. Please try to place the order again.'),
                $e
            );
        }
        return $orderId;

This happens in:

magento/module-checkout/Model/GuestPaymentInformationManagement.php:83

and

magento/module-checkout/Model/PaymentInformationManagement.php:71

Have a look to the message ($e->getMessage()) before it gets overridden.

That should help you discover why you cannot place an order when quantity is 3 or more.

Related Topic