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

Fix: prevent Stripe Payment Element from rendering when amount is zero #7515

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

jonwaldstein
Copy link
Contributor

@jonwaldstein jonwaldstein commented Aug 23, 2024

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:

Screenshot 2024-08-23 at 9 29 07 AM

After

Screenshot 2024-08-23 at 10 10 35 AM

Testing Instructions

  • create a v3 form
  • specify 0 for the amount
  • click on stripe payment element

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

Copy link

github-actions bot commented Oct 8, 2024

This PR is stale because it has been open 45 days with no activity. Stale PRs will NOT be automatically closed.

@github-actions github-actions bot added the Stale label Oct 8, 2024
@jonwaldstein
Copy link
Contributor Author

Closing for now:

I started working on this for Stripe but quickly realized the nuances become a weird experience. When 0 is entered we can display a message within the gateway but you can still technically submit the form and receive an error. Furthermore, Stripe uses the amount value, while events are not included in this value.

@jonwaldstein jonwaldstein marked this pull request as ready for review October 30, 2024 21:47
@github-actions github-actions bot removed the Stale label Oct 31, 2024
Comment on lines +216 to +218
if (donationAmount <= 0) {
return <>{__('Donation amount must be greater than zero to proceed.', 'give')}</>;
}
Copy link
Contributor

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?

Copy link
Contributor Author

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:

  1. Assume all gateways will not render fields when amount is 0
  2. 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.

Copy link
Contributor

@JasonTheAdams JasonTheAdams Oct 31, 2024

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

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

Successfully merging this pull request may close these issues.

2 participants