magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.31k forks source link

Magento 2.1.3 | getting 400 (Bad Request) error on placing order #8488

Closed shahrukh-alizai closed 6 years ago

shahrukh-alizai commented 7 years ago

I am using Magento 2.1.3, and getting xhr 400 (Bad Request) error on placing order via Stripe payment method. Same error on "Cash on Delivery" method too. I am getting same error on logged-in and guest user both. Here are the error details:

AJAX request information:

POST http://******************/rest/en/V1/guest-carts/e8683a16265d10b750962fff18ccbf4f/payment-information 400 (Bad Request)
send @ jquery.js:9666
ajax @ jquery.js:9211
post @ storage.js:39
(anonymous) @ place-order.js:17
(anonymous) @ place-order.js:35
_super @ wrapper.js:73
(anonymous) @ place-order-mixin.js:20
(anonymous) @ wrapper.js:78
getPlaceOrderDeferredObject @ default.js:163
placeOrder @ default.js:140
(anonymous) @ knockout.js:3863
dispatch @ jquery.js:4624
elemData.handle @ jquery.js:4292

Request Payload:

{
   "cartId":"e8683a16265d10b750962fff18ccbf4f",
   "billingAddress":{
      "countryId":"US",
      "regionId":"15",
      "regionCode":"DE",
      "region":"Delaware",
      "street":[
         "Test",
         ""
      ],
      "company":"",
      "telephone":"+99 308 579 0000",
      "postcode":"52000",
      "city":"Test",
      "firstname":"Test",
      "lastname":"Test",
      "saveInAddressBook":null
   },
   "paymentMethod":{
      "method":"inchoo_stripe",
      "additional_data":{
         "cc_cid":"848",
         "cc_ss_start_month":"",
         "cc_ss_start_year":"",
         "cc_ss_issue":"",
         "cc_type":"VI",
         "cc_exp_year":"2024",
         "cc_exp_month":"6",
         "cc_number":"4242424242424242"
      }
   },
   "email":"user3@******.com"
}

Response:

{
   "message":"An error occurred on the server. Please try to place the order again.",
   "trace":"#0 [internal function]: Magento\\Checkout\\Model\\GuestPaymentInformationManagement->savePaymentInformationAndPlaceOrder('e8683a16265d10b...', 'user3@*******n...', Object(Magento\\Quote\\Model\\Quote\\Payment), Object(Magento\\Quote\\Model\\Quote\\Address))\n#1 \/home\/****magento****\/vendor\/magento\/module-webapi\/Controller\/Rest.php(307): call_user_func_array(Array, Array)\n#2 \/home\/****magento****\/vendor\/magento\/module-webapi\/Controller\/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#3 \/home\/****magento****\/var\/generation\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(24): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#4 \/home\/****magento****\/vendor\/magento\/framework\/App\/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#5 \/home\/****magento****\/vendor\/magento\/framework\/App\/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#6 \/home\/****magento****\/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#7 {main}"
}

General Request Information:

Request URL:http://**********/rest/en/V1/guest-carts/e8683a16265d10b750962fff18ccbf4f/payment-information
Request Method:POST
Status Code:400 Bad Request
Remote Address:******:80
joni-jones commented 7 years ago

Hi, @shahrukh-alizai, you need to check Magento exception log to find original reason of exception.

shahrukh-alizai commented 7 years ago

Hi @joni-jones I found no trace except these broken references type logs:

https://gist.github.com/shahrukh-alizai/eac4d415e3bde3ccabae9151e03f2f74

joni-jones commented 7 years ago

@shahrukh-alizai, system.log does not contain any useful information related to your issue.

If your exception.log does not contain any exceptions, you can use xdebug and set breakpoint in GuestPaymentInformationManagement (for guest checkout) or PaymentInformationManagement (for registered customers) and exception object will contains original exception message.

wolfgangleon commented 7 years ago

After doing what you said @joni-jones this is what I found in my exception.log...

0 The element 'product.info.options' already has a child with alias 'default'

0 Magento\Framework\Data\Structure->_insertChild('product.info.op...', 'product.info.op...', NULL, 'default')

. . . .

0 The element 'product.info.options' already has a child with alias 'text' in

0 Magento\Framework\Data\Structure->_insertChild('product.info.op...', 'product.info.op...', NULL, 'text')

. . . . .

MainCritcal The element 'product.info.options' already has a child with alias 'file'

0 Magento\Framework\Data\Structure->_insertChild('product.info.op...', 'product.info.op...', NULL, 'file')

. . . . . Main.critical The element 'product.info.options' already has a child with alias 'select'

0 Magento\Framework\Data\Structure->_insertChild('product.info.op...', 'product.info.op...', NULL, 'select')

. . . . . Main.Critical The element 'product.info.options' already has a child with alias 'date'

0 Magento\Framework\Data\Structure->_insertChild('product.info.op...', 'product.info.op...', NULL, 'date')

. . . ..

This are all made at the same time, so I'm guessing its a misconfiguration somewhere at the moment that an user tries to make an order using Braintree Payments on Magento.

I've truncate all sales orders in tables and tables related to orders. Tried to overwrite Magenot\Model\Checkout GuestPaymentInformationManagment and PaymentinformationManagment.

I have double check Braintree Ids and nothing. I updated the install to 2.1.5. Server info is PHP 7.0 memory_limit 768MB.

I can't find a solution to this please I need help.

Thanks,

Puru2016 commented 7 years ago

Is there any update on this as I am using Magento 2.1.2 and getting same error in checkout page

magento-engcom-team commented 6 years ago

@shahrukh-alizai, thank you for your report. We were not able to reproduce this issue by following the steps you provided. Please provide more detailed steps to reproduce or try to reproduce this issue on a clean installation or latest release.

magento-engcom-team commented 6 years ago

@shahrukh-alizai, thank you for your report. We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.

Kronmose commented 6 years ago

We have a similar problem on Magento 2.1.9 only the problem only exists on download / virtual products.

Corsten commented 6 years ago

I have a similar problem on Magento 2.1.8. message: "Are your billing address and shipping address the same? If not uncheck the box, fill in the address, and hit the update button. Or did you forget to fill in a mandatory field with a red asterisk?" trace "#0 /var/www/html/test/app/code/Amasty/Checkout/Model/PaymentInformationManagement.php(46): Magento\Checkout\Model\PaymentInformationManagement->savePaymentInformationAndPlaceOrder(1158520, Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address\Interceptor))↵#1 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(146): Amasty\Checkout\Model\PaymentInformationManagement->savePaymentInformationAndPlaceOrder(1158520, Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address\Interceptor), Array)↵#2 /var/www/html/test/var/generation/Amasty/Checkout/Model/PaymentInformationManagement/Interceptor.php(26): Amasty\Checkout\Model\PaymentInformationManagement\Interceptor->_callPlugins('savePaymentInfo...', Array, Array)↵#3 [internal function]: Amasty\Checkout\Model\PaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder(1158520, Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address\Interceptor), Array)↵#4 /var/www/html/test/vendor/magento/module-webapi/Controller/Rest.php(307): call_user_funcarray(Array, Array)↵#5 /var/www/html/test/vendor/magento/module-webapi/Controller/Rest.php(216): Magento\Webapi\Controller\Rest->processApiRequest()↵#6 /var/www/html/test/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))↵#7 /var/www/html/test/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))↵#8 /var/www/html/test/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\App\Http->launch()↵#9 /var/www/html/test/var/generation/Magento/Framework/App/Http/Interceptor.php(26): Magento\Framework\App\Http\Interceptor->callPlugins('launch', Array, Array)↵#10 /var/www/html/test/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch()↵#11 /var/www/html/test/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))↵#12 {main}"

huykon commented 4 years ago

I have same problem on Magento 2.3.3. It occured when I add a coupon code and checkout with guest user. Anyone have same problem?

j-lloyd-slc commented 4 years ago

FWIW, I am having this problem in Magento 2.3.3, with or without coupon codes. The store does not allow guest checkout.

It seems like this error is being raised at a bottleneck where incomplete error logging is obscuring the underlying issue(s). Specifically savePaymentInformationAndPlaceOrder in vendor/magento/module-checkout/Model/PaymentInformationManagement.php

Forgot to add: this happens for only one of the stores in a multi-store setup.