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

ValueError: There is already an order with number 100551 #4246

Open
matburnham opened this issue Feb 8, 2024 · 2 comments
Open

ValueError: There is already an order with number 100551 #4246

matburnham opened this issue Feb 8, 2024 · 2 comments

Comments

@matburnham
Copy link

Issue Summary

(Some, ~20%) of my orders are being processed, paid for (via django-oscar-paypal) but then not created as orders. I've found errors repeated errors in the log as below.

Steps to Reproduce

Difficult, I think this is down to database state but I don't know how I've got to that point.

  1. Put site live.
  2. Take orders.
  3. Find that some orders are being duplicated, and others are paid for but not recorded.
  4. Dig about with customer.
  5. Find they're experiencing errors then trying again:
    image
  6. Refund the duplicated orders.
  7. Recreate the lost order.

Technical details

  • Python version: 3.8.10
  • Django version: 4.2.9
  • Oscar version: 3.2.3
  • Django-Oscar-Paypal: 2.0.0 + patch to dump version dependency (24e1477f9b7dd8d020b4b14c48d34e0f4e9b2136)

Error log

[2024-02-08 19:53:43 +0000] [1470626] [DEBUG] GET /checkout/paypal/preview/551/
[2024-02-08 19:53:52 +0000] [1470625] [DEBUG] POST /checkout/paypal/place-order/551/
Order #100551: unhandled exception while placing order (There is already an order with number 100551)
Traceback (most recent call last):
  File ".../lib/python3.8/site-packages/oscar/apps/checkout/views.py", line 665, in submit
    return self.handle_order_placement(
  File ".../lib/python3.8/site-packages/oscar/apps/checkout/mixins.py", line 110, in handle_order_placement
    order = self.place_order(
  File ".../lib/python3.8/site-packages/oscar/apps/checkout/mixins.py", line 162, in place_order
    order = OrderCreator().place_order(
  File ".../lib/python3.8/site-packages/oscar/apps/order/utils.py", line 72, in place_order
    raise ValueError(
ValueError: There is already an order with number 100551
[2024-02-08 19:55:16 +0000] [1470625] [DEBUG] POST /checkout/paypal/place-order/551/
[2024-02-08 19:55:16 +0000] [1470626] [DEBUG] GET /basket/
[2024-02-08 19:55:22 +0000] [1470625] [DEBUG] GET /checkout/
[2024-02-08 19:55:22 +0000] [1470627] [DEBUG] GET /checkout/shipping-address/
[2024-02-08 19:55:30 +0000] [1470625] [DEBUG] POST /checkout/shipping-address/
[2024-02-08 19:55:30 +0000] [1470627] [DEBUG] GET /checkout/shipping-method/
[2024-02-08 19:55:30 +0000] [1470625] [DEBUG] GET /checkout/payment-method/
[2024-02-08 19:55:30 +0000] [1470627] [DEBUG] GET /checkout/payment-details/
[2024-02-08 19:55:35 +0000] [1470625] [DEBUG] GET /checkout/paypal/payment/
[2024-02-08 19:55:44 +0000] [1470626] [DEBUG] GET /checkout/paypal/preview/551/
[2024-02-08 19:55:50 +0000] [1470625] [DEBUG] POST /checkout/paypal/place-order/551/
Order #100551: unhandled exception while placing order (There is already an order with number 100551)
Traceback (most recent call last):
  File ".../lib/python3.8/site-packages/oscar/apps/checkout/views.py", line 665, in submit
    return self.handle_order_placement(
  File ".../lib/python3.8/site-packages/oscar/apps/checkout/mixins.py", line 110, in handle_order_placement
    order = self.place_order(
  File ".../lib/python3.8/site-packages/oscar/apps/checkout/mixins.py", line 162, in place_order
    order = OrderCreator().place_order(
  File ".../lib/python3.8/site-packages/oscar/apps/order/utils.py", line 72, in place_order
    raise ValueError(
ValueError: There is already an order with number 100551

@matburnham
Copy link
Author

matburnham commented Feb 8, 2024

Analysis

I run an annual event. Order number 100551 references an order from 2023 from the same user. Order number is derived from the cart number. I seem to have an open cart from a more than a year ago which is attempting to be re-used.

image

Why? How do I fix this? Presumably I don't want to just delete the carts as order numbers may then clash later. Should I just close all open carts? Is the order process documented anywhere?

Remaining issue

Why do carts get into this state? Could place_order handle this?

@matburnham
Copy link
Author

Looks like this may have been caused by something similar to #3768

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

1 participant