Skip to content

Calling cancelation endpoint on an order with coupon code multiple times can result in multiple decrements on the coupon usages #11

Closed
@anthonyvdg-se

Description

@anthonyvdg-se

I have noticed that the frontend cancelation endpoint doesn't modify the state of the order (into cancel), though that the same endpoint will decrement the coupon usage.

Given that this url is called by the user, there are 2 edge case situations that can occur:

  • The user visits the endpoint multiple times (locally reproduced by spamming the cancel button on the payment page): I was able to reduce the coupon code usage multiple times. Luckily the coupon usage counter cannot go below 0 and the usage limit of a coupon would be set to 1, so this issue shouldn't happen too often.
  • The user doesn't visit the cancelation endpoint, or hit it too late (because it is triggered after a call to the notify endpoint to put the order on cancel, not sure if this could happen). In this case, the coupon code usage will not decrement.

In the ideal case, the coupon decrement should happen when the order is changing its state to cancel or happen in a way that ensures the decrement count is guaranteed to be called once during cancelation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions