Skip to content

Commit

Permalink
Fix: prevent Stripe Payment Element from rendering when amount is zero (
Browse files Browse the repository at this point in the history
#7515)

Co-authored-by: Jon Waldstein <[email protected]>
  • Loading branch information
jonwaldstein and Jon Waldstein authored Nov 5, 2024
1 parent 6c91a94 commit 3f46b6f
Showing 1 changed file with 5 additions and 0 deletions.
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')}</>;
}

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

0 comments on commit 3f46b6f

Please sign in to comment.