-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Do not allow successful checkout when order has only a void payment #3123
Do not allow successful checkout when order has only a void payment #3123
Conversation
When a payment has been marked for some reason as `void`, the customer should not be able to complete the checkout process successfully. The customer is now redirected to the payment page, where they can add another payment to the order in order to complete it successfully.
f8f8d9a
to
5eb0bdd
Compare
When a single payment exists for the order, and the payment is marked as void, then the order payment state changes to `Failed`. When there are multiple pending payments for the order, if only one is marked as void the order payment state is still `Balance Due`. If all the payments are marked as void then the order payment state changes to `Failed`.
After some input from @aitbw about the possible behavior regarding the failing spec, it seems reasonable that when a single payment exists and it is marked as On the other hand, when there are other pending payments, the state remains as So I added one more spec (and did some refactoring later) in order to properly expose this behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, @spaghetticode! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this solution, I'd just change the last commit message with something more descriptive. I know you added some lines in the commit description but sometimes you only have the commit message visible and it would be great to have some more information about what it does.
Utility method `create_payment` was extracted in order to DRY up the code a bit.
a4ec39a
to
e663b24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @spaghetticode, great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Andrea! 🥇
When a payment has been marked for some reason as
void
, the customer shouldnot be able to complete the checkout process successfully.
The customer is now redirected to the payment page, where they can add another
payment to the order in order to complete it successfully.
This scope for
Spree::Payment
model:now includes also
void
, first because adding it there fixes the issue during the checkout, second because the wordvoid
means quite the opposite ofvalid
.One spec in the backend is currently failing (
spec/features/admin/orders/payments_spec.rb:65
) so I'd like to understand from the community if its behavior can be changed there or other solutions make more sense.The reasoning behind this change is that, when an order with payment gets stale, admins may want to set the payment as
void
for some reason. When the customer resumes the checkout after some days they should not be able to complete it with that voided payment.