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

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ interface StripeGateway extends Gateway {
}

/**
* @unreleased added fields conditional when donation amount is zero
* @since 3.13.0 Use only stripeKey to load the Stripe script (when stripeConnectedAccountId is missing) to prevent errors when the account is connected through API keys
* @since 3.12.1 updated afterCreatePayment response type to include billing details address
* @since 3.0.0
Expand Down Expand Up @@ -212,6 +213,10 @@ const stripePaymentElementGateway: StripeGateway = {
appearance: appearanceOptions,
};

if (donationAmount <= 0) {
return <>{__('Donation amount must be greater than zero to proceed.', 'give')}</>;
}
jonwaldstein marked this conversation as resolved.
Show resolved Hide resolved

return (
<Elements stripe={stripePromise} options={stripeElementOptions}>
<StripeFields gateway={stripePaymentElementGateway} />
Expand Down
Loading