{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/4682","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/4682/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/4682/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/4682/events","html_url":"https://github.com/magento/magento2/issues/4682","id":156631769,"number":4682,"title":"Improve error reporting for failed order placement (checkout)","user":{"login":"leoquijano","id":7789514,"avatar_url":"https://avatars.githubusercontent.com/u/7789514?v=3","gravatar_id":"","url":"https://api.github.com/users/leoquijano","html_url":"https://github.com/leoquijano","followers_url":"https://api.github.com/users/leoquijano/followers","following_url":"https://api.github.com/users/leoquijano/following{/other_user}","gists_url":"https://api.github.com/users/leoquijano/gists{/gist_id}","starred_url":"https://api.github.com/users/leoquijano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leoquijano/subscriptions","organizations_url":"https://api.github.com/users/leoquijano/orgs","repos_url":"https://api.github.com/users/leoquijano/repos","events_url":"https://api.github.com/users/leoquijano/events{/privacy}","received_events_url":"https://api.github.com/users/leoquijano/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/magento/magento2/labels/improvement","name":"improvement","color":"e102d8"},{"url":"https://api.github.com/repos/magento/magento2/labels/Payments","name":"Payments","color":"1d76db"},{"url":"https://api.github.com/repos/magento/magento2/labels/PROD","name":"PROD","color":"c7def8"}],"state":"open","locked":false,"assignee":{"login":"asemenenko","id":8157727,"avatar_url":"https://avatars.githubusercontent.com/u/8157727?v=3","gravatar_id":"","url":"https://api.github.com/users/asemenenko","html_url":"https://github.com/asemenenko","followers_url":"https://api.github.com/users/asemenenko/followers","following_url":"https://api.github.com/users/asemenenko/following{/other_user}","gists_url":"https://api.github.com/users/asemenenko/gists{/gist_id}","starred_url":"https://api.github.com/users/asemenenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asemenenko/subscriptions","organizations_url":"https://api.github.com/users/asemenenko/orgs","repos_url":"https://api.github.com/users/asemenenko/repos","events_url":"https://api.github.com/users/asemenenko/events{/privacy}","received_events_url":"https://api.github.com/users/asemenenko/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2016-05-24T23:27:24Z","updated_at":"2016-06-19T15:00:55Z","closed_at":null,"body":"Hi,\r\n\r\nI've been debugging some checkout issues. I noticed that several of them were fixed in Magento 2.0.7, so I went in to test our payment process using that version.\r\n\r\nAs I tested my integration with Autorize.NET DPM gateway, my checkout page froze in the \"loading\" stage. The order was successfully received and Authorize.NET debug log showed the information. However, something was happening after the response came back.\r\n\r\nSometimes I would get a window saying \"Cannot place order\". Sometimes it would just get stuck. However, at no point I would get more detailed information, as a developer, to what's going on.\r\n\r\nI traced down the issue to the ```vendor/magento/module-authorizenet/Controller/Directpost/Payment/Place.php``` file (I'm using a Composer based install). The following method would be executed:\r\n\r\n```php\r\nprotected function placeCheckoutOrder()\r\n{\r\n    $result = new DataObject();\r\n    $response = $this->getResponse();\r\n    try {\r\n        $this->cartManagement->placeOrder($this->_getCheckout()->getQuote()->getId());\r\n        $result->setData('success', true);\r\n        $this->eventManager->dispatch(\r\n            'checkout_directpost_placeOrder',\r\n            [\r\n                'result' => $result,\r\n                'action' => $this\r\n            ]\r\n        );\r\n    } catch (\\Exception $exception) {\r\n        $result->setData('error', true);\r\n        $result->setData('error_messages', __('Cannot place order.'));\r\n    }\r\n    if ($response instanceof Http) {\r\n        $response->representJson($this->jsonHelper->jsonEncode($result));\r\n    }\r\n}\r\n```\r\n\r\nSince I got the error message 'Cannot place order' a couple of times, I entered some logging statements, and got this in my log:\r\n\r\n```\r\n2016-05-24T23:08:42+00:00 INFO (6): Error placing order: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '000000010-1' for key 'SALES_ORDER_INCREMENT_ID_STORE_ID', query was: INSERT INTO `sales_order` (`state`, `status`, `protect_code`, `shipping_description`, `is_virtual`, `store_id`, `customer_id`, `base_discount_amount`, `base_grand_total`, `base_shipping_amount`, `base_shipping_tax_amount`, `base_subtotal`, `base_tax_amount`, `base_to_global_rate`, `base_to_order_rate`, `discount_amount`, `grand_total`, `shipping_amount`, `shipping_tax_amount`, `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `tax_amount`, `total_qty_ordered`, `customer_is_guest`, `customer_note_notify`, `customer_group_id`, `quote_id`, `base_shipping_discount_amount`, `base_total_due`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `increment_id`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `customer_middlename`, `global_currency_code`, `order_currency_code`, `remote_ip`, `shipping_method`, `store_currency_code`, `store_name`, `total_item_count`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `shipping_discount_tax_compensation_amount`, `base_shipping_discount_tax_compensation_amnt`, `discount_tax_compensation_invoiced`, `base_discount_tax_compensation_invoiced`, `discount_tax_compensation_refunded`, `base_discount_tax_compensation_refunded`, `shipping_incl_tax`, `base_shipping_incl_tax`, `gift_message_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\r\n```\r\n\r\nSo it is clearly an inconsistent database state. I deleted the contents from the ```sales_order``` table and the checkout now works fine.\r\n\r\nHowever, it would be a good idea to provide feedback for developers when an order placement fails. Something like this:\r\n\r\n```php\r\nprotected function placeCheckoutOrder()\r\n{\r\n    $result = new DataObject();\r\n    $response = $this->getResponse();\r\n    try {\r\n        $this->cartManagement->placeOrder($this->_getCheckout()->getQuote()->getId());\r\n        $result->setData('success', true);\r\n        $this->eventManager->dispatch(\r\n            'checkout_directpost_placeOrder',\r\n            [\r\n                'result' => $result,\r\n                'action' => $this\r\n            ]\r\n        );\r\n    } catch (\\Exception $exception) {\r\n        $this->_logger->info(\"Error placing order: \".$exception->getMessage());\r\n        $result->setData('error', true);\r\n        $result->setData('error_messages', __('Cannot place order.'));\r\n    }\r\n\r\n    if ($response instanceof Http) {\r\n        $response->representJson($this->jsonHelper->jsonEncode($result));\r\n    }\r\n}\r\n```\r\n\r\n... where ```$this->_logger``` is an appropriately configured logger (via DI). This would provide something to the developer to work with, and prevent [exception swallowing](http://karlz.net/blog/index.php/2013/02/10/dont-swallow-exceptions/)."},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/227001830","html_url":"https://github.com/magento/magento2/issues/4682#issuecomment-227001830","issue_url":"https://api.github.com/repos/magento/magento2/issues/4682","id":227001830,"user":{"login":"hudson1985","id":17986963,"avatar_url":"https://avatars.githubusercontent.com/u/17986963?v=3","gravatar_id":"","url":"https://api.github.com/users/hudson1985","html_url":"https://github.com/hudson1985","followers_url":"https://api.github.com/users/hudson1985/followers","following_url":"https://api.github.com/users/hudson1985/following{/other_user}","gists_url":"https://api.github.com/users/hudson1985/gists{/gist_id}","starred_url":"https://api.github.com/users/hudson1985/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hudson1985/subscriptions","organizations_url":"https://api.github.com/users/hudson1985/orgs","repos_url":"https://api.github.com/users/hudson1985/repos","events_url":"https://api.github.com/users/hudson1985/events{/privacy}","received_events_url":"https://api.github.com/users/hudson1985/received_events","type":"User","site_admin":false},"created_at":"2016-06-19T15:00:55Z","updated_at":"2016-06-19T15:00:55Z","body":"Thank you so much for replying so quickly.  Is it possible to send me a\nlink to the specific original post you are referring to in order to ensure\nI get it right.  Also please let me know if you have a fee structure that\nwe could pay to cure this in the event we can't cure it.\n\nHudson Copeland\n256-483-2671\n\n*Hudson Copeland*\n\nDirector, Software Solutions, e-Commerce Management\n\n*Distinctive Designs International Inc.*\n\nhcopeland@distdesigns.com <dhoffmann@distdesigns.com>\n\n800-243-4787 x 127\n\nOffice: 256-332-7390 x 127\n\nMobile: 256-483-2671\n\nFax: 256-332-7890\n\nOn Sat, Jun 18, 2016 at 11:12 PM, Leonardo Quijano <notifications@github.com\n> wrote:\n\n> Hi @hudson1985 <https://github.com/hudson1985> . Check my original post.\n> You can add manually this statement:\n>\n>         $this->_logger->info(\"Error placing order: \".$exception->getMessage());\n>\n> To the appropriate spot (described there). My issue report is for an\n> improvement. Your \"Cannot Place Order\" may be related to something else\n> entirely.\n>\n> —\n> You are receiving this because you were mentioned.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/magento/magento2/issues/4682#issuecomment-226978403>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe/ARJ1k-BeOpxQathpJbhes05niVd_lVxJks5qNMGVgaJpZM4ImBo6>\n> .\n>\n"}}
{"actor":{"display_login":"hudson1985"}}