Skip to content
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

Unable to continue with payment of order when pressing "back" to payment selection #4474

Closed
karl-ravn opened this issue May 12, 2016 · 6 comments

Comments

@karl-ravn
Copy link

When an order

Steps to reproduce

  1. Install Magento from develop branch.
  2. Add Product to the cart.
  3. Install (for instance) SaferPay plugin from CustomWeb
  4. Go to Checkout
  5. Fill in shipment details
  6. Select payment method and click "Place order"
  7. Press back in button (not cancel in payment provider)
  8. Press "Place order" again

Expected result

  1. You would go to the payment provider and continue on the already made order in the system

Actual result

  1. You get an error due to that the database table sales_order already contains the increment number
  2. The order is now in "pending payment" state until the timeout occurs, and the user cannot proceed with checkout without clearing cookies or switching web browser.

Stack trace

[2016-05-12 02:37:15] main.CRITICAL: Zend_Db_Statement_Exception: Report ID: webapi-5733ec5b3500f; Message: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3000000496-3' for key 'SALES_ORDER_INCREMENT_ID_STORE_ID', query was: INSERT INTO `sales_order` (`state`, `status`, `coupon_code`, `protect_code`, `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_subtotal_incl_tax`, `base_total_due`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `increment_id`, `applied_rule_ids`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `customer_middlename`, `discount_description`, `global_currency_code`, `order_currency_code`, `remote_ip`, `store_currency_code`, `store_name`, `x_forwarded_for`, `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`, `coupon_rule_name`, `gift_message_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) in /opt/store.traxfamily.com/vendor/magento/framework/Webapi/ErrorProcessor.php:194
Stack trace:
#0 /opt/store.traxfamily.com/vendor/magento/framework/Webapi/ErrorProcessor.php(139): Magento\Framework\Webapi\ErrorProcessor->_critical(Object(Zend_Db_Statement_Exception))
#1 /opt/store.traxfamily.com/vendor/magento/module-webapi/Controller/Rest.php(163): Magento\Framework\Webapi\ErrorProcessor->maskException(Object(Zend_Db_Statement_Exception))
#2 /opt/store.traxfamily.com/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#3 /opt/store.traxfamily.com/vendor/magento/framework/App/Http.php(115): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#4 [internal function]: Magento\Framework\App\Http->launch()
#5 /opt/store.traxfamily.com/vendor/magento/framework/Interception/Interceptor.php(144): call_user_func_array(Array, Array)
#6 /opt/store.traxfamily.com/var/generation/Magento/Framework/App/Http/Interceptor.php(26): Magento\Framework\App\Http\Interceptor->___callPlugins('launch', Array, Array)
#7 /opt/store.traxfamily.com/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch()
#8 /opt/store.traxfamily.com/pub/index.php(73): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#9 {main} [] []
@joni-jones
Copy link
Contributor

@karl-ravn , seems your problem not related to Magento functionality and relates to SaferPay plugin.
If this behavior is reproducible with other Magento built-in payments, please, update details and reopen this issue.

In other case, please refer to the Community Forums or Magento Stack Exchange site for technical questions.

@karl-ravn
Copy link
Author

Seems to be same problem as #4580

@karl-ravn
Copy link
Author

The problem seems to be that the quote has been created with a reserved_order_id, but there already exists a row with the same increment_id in order_sales.

The error goes through:
OrderManager#save(\Magento\Sales\Api\Data\OrderInterface $entity)
OrderService#place(\Magento\Sales\Api\Data\OrderInterface $order)
QuoteManagement#submitQuote(QuoteEntity $quote, $orderData = [])
(line 478 Magento 2.0.5 $order = $this->orderManagement->place($order);)

This could be avoided if either QuoteManagement#submitQuote() or Quote#reserveOrderId() would do a sanity check that there are no order with a conflicting increment_id. If a conflict is found, just regenerate a new order id.

@rbutler514
Copy link

We just had this exact issue on Magento 2.07 using Braintree as our payment provider. Same steps to replicate the issue and since it was for a registered user, we had to manually remove the quote in the DB in order to allow them to create a new cart for checkout.

@bvboas
Copy link

bvboas commented Oct 18, 2016

Anyone figured out a temp fix?

I'm having the same issue.

@mimarcel
Copy link
Contributor

mimarcel commented Jan 2, 2017

@bvboas as stated in #4580 , commit fe97d9e should fix the issue. I didn't test it myself, but I'm looking into it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants