-
Notifications
You must be signed in to change notification settings - Fork 191
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
Fix: prevent Stripe Payment Element from rendering when amount is zero #7515
base: develop
Are you sure you want to change the base?
Conversation
This PR is stale because it has been open 45 days with no activity. Stale PRs will NOT be automatically closed. |
Closing for now:
|
if (donationAmount <= 0) { | ||
return <>{__('Donation amount must be greater than zero to proceed.', 'give')}</>; | ||
} |
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.
@jonwaldstein Should this be resolved upstream? Might this affect other gateways as well?
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.
It's a good question and something I have considered and even spiked
However, In order to accomplish this upstream the options I see are:
- Assume all gateways will not render fields when amount is 0
- The gateway API has a concept of accepts $0 and each gateway implements (test gateway, offline, etc would potentially return true)
These options further solidify our rejection of $0 donations which we're still working out in our product. So at this point, I think it's okay for the gateways to handle this themselves (which most are doing) - at least until we come to a solid conclusion and direction for our product around the subject.
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 not sure if this helps, but I know that we're planning at some point to allow $0 donations for things like events. I think, at that time, we're actually more likely to do something like hide the gateways (similar to WooCommerce). In the meantime, I think we can simply enforce the current assumption that donations must be at least $1 — or whatever the actual minimum donation value is.
I think it's fine to go this route for now, knowing we may change it later.
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.
Yeah hiding the gateways was an option on my $0 spike. That was something I built for the marketing team to allow $0 donations. I'd like to pull out some of what I did over there for core.
I do also like the idea of using the minimum amount value too 🤔
However, the scope of this PR is so small and would solve the immediate weirdness.
I'd be happy to open a separate one that ports over the gateway filtering to play around with all gateways which of course will increase the scope.
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.
Started scaffolding the other PR #7599
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.
Up to you whether you want to merge this PR to fix the immediate issue and proceed or not. This would ultimately become a tiny amount of technical debt.
Resolves GIVE-509
Description
This prevents the Stripe Payment Element from rendering when the donation amount is zero by adding a conditional before loading the fields.
Affects
Stripe payment element gateways
Visuals
Before:
After
Testing Instructions
Pre-review Checklist
@unreleased
tags included in DocBlocks