-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error 400 with braintree on checkout #8978
Comments
We have a lot of http/400 this morning, could you tell me where can I add lines in the code in order to log more things and understand the reason of this 400 ? |
At first, need to get transaction details from debug log. To find original reason of fails, you can use xdebug and set breakpoints in the https://github.com/magento/magento2/blob/2.1/app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php#L83 and https://github.com/magento/magento2/blob/2.1/app/code/Magento/Checkout/Model/PaymentInformationManagement.php#L71 or can use a logger to find original reason of failing like in https://github.com/magento/magento2/blob/develop/app/code/Magento/Checkout/Model/PaymentInformationManagement.php#L90 |
Usually, when this issue happend, there is nothing in the debug.log and there is nothing in the transaction log in the braintree backend. I'll add a logger to get more informations. I discovered this morning that the two http / 400 are another issue. This time, there is line written in the debug.log. Payment where accepted, but there were no sales recorded in the sales history (magento), confirmation mail is not sent. There is lines for that transaction in the debug.log. it's maybe preferable that I open a different issue ? |
@joni-jones Just to be sure, this server is in production, I can't switch it into dev mode, to much traffic. The code is compiled, could you tell me where can I find those files : https://github.com/magento/magento2/blob/2.1/app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php#L83 and https://github.com/magento/magento2/blob/2.1/app/code/Magento/Checkout/Model/PaymentInformationManagement.php#L71 or can use a logger to find original reason of failing like in https://github.com/magento/magento2/blob/develop/app/code/Magento/Checkout/Model/PaymentInformationManagement.php#L90 |
This classes should be in |
For the first issue (error http 400, without transaction in the braintree history, and in sale history). Something is going wrong in vendor/magento/module-quote/Model/QuoteManagement.php In the function I added some error_log calls (I know it's not the best way)
// When error 400 happend, it never reach this step :
Nothing in the exception.log, nothing in debug.log
I Didn't sorted this out for now. If someone has an idea.. |
@joni-jones If I comment this part :
The payment is successfull and no error 400, but if I uncomment it and retry, I get an error 400. I did this modification :
And again, payment successfull, no error 400. Version of php : |
You need to log original exception message, from https://github.com/magento/magento2/blob/2.1/app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php#L83 and https://github.com/magento/magento2/blob/2.1/app/code/Magento/Checkout/Model/PaymentInformationManagement.php#L71 these two points where you can catch all exceptions, even if fails quote management, it much easier to find at first original exception message and then find an issue in the source code. If you are using |
OK, I added " $this->getLogger()->critical($e);" at : Today, a lot of errors, this time the script exited 3 times between Another bug (not the same) is present in the checkout process, but it trigger rarely. In this other bug, the payment is OK and appear in the braintree history but the order is not present in the sale history. |
To the latter point, this is an architectural concern I also have: if there is an exception in processing the payment after it is captured, the handling structure causes the order not to be created and the user to be taken back to the payment form. This is obviously a major customer service issue, but since exceptions should be, well, exceptional, it's hard to argue it's strictly a bug. |
@scottsb I understand your point of view, but this kind of situations are critical, because you need to check every transactions in order to see if one of them has been "forgotten" in the sales list. I think that once the payment has been accepted, even if there is an exception in the process, an order should be created (even with minimal informations), or notified (mail if it's not possible to write in db). |
I'd certainly not argue if the Magento gods look upon this kindly to change. ;-) |
Agreed - that's no ok to lose exceptions if the order cannot be save, specially after payment. Actually the logs @joni-jones is suggesting (which are today the only way to know what's going on besides xdebug) are in develop branch, apparently part of a 2.2-dev ticket (MAGETWO-60073). That's a good candidate for 2.1.7 or a patch, seeing the number of different bugs where people are puzzled with similar "400", and no exceptions in log : #8488 #6929 #5902 #6125 #6522 #9116 |
I followed @joni-jones suggestions, but this error did not happend since I added log lines. Just one time because of "incorrect address" according to the logs, but the shipping address was correct. I added some more check point (log ...), and I'm waiting for more data. |
Here is an error messages logged into exception.log after some error 400 (4 times today) : Integrity constraint violation: 1062 Duplicate entry '000000898-1' for key 'SALES_ORDER_INCREMENT_ID_STORE_ID', query was: INSERT INTO I don't know how to prevent this issue. The payment is accepted (4 times by credit card, that I must refund now ..) but there is no records in the sales list. |
Anyone know if this issue has been resolved? I can't find a reference in any recent release. |
The issue already fixed in 2.2.0 |
Hi,
We are facing this issue with some payment. Most of payment are successfull but sometimes it happend and we didn't figured why. If the user close the browser window and reopen it, It can solve the issue, but we do not know if it's always the case.
This issue can happend with logged in user, OR guests, and happend when user select stored card number OR, when the user give the card numbers.
It's difficult to reproduce this error, when we try to do so, it works ... but this issue happend with 10% of our clients (estimation based on logs).
When it happend, there is no exceptions in the log, even in debug mode for the braintree module.
here is some apache log lines :
With this client using Edge :
4 unsuccessfull payment
Here the client tried to close the browser window, reopen it, re log and retry payment :
xx.xx.xx.xx something.com - - [21/Mar/2017:18:18:34 +0100] "POST /rest/default/V1/carts/mine/payment-information HTTP/1.1" 200 501 "https://something.com/checkout/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"
This time it was good.
Preconditions
Environement : Debian 8 / PHP 7 / Magento 2.1.2 / Redis for sessions and FPC / Opcache
Mysql : mysqlnd 5.0.12-dev / mysqld 5.7.16
Apache : Server version: Apache/2.4.10 (Debian)
Steps to reproduce
As you can see in the log, this happend when the client click on the "Proceed payment button", but it's really hard for us to reproduce it, its random.
Expected result
Actual result
Thanks for your help.
The text was updated successfully, but these errors were encountered: