Skip to content

Commit

Permalink
bug in stripe fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jitheshm committed Aug 12, 2024
1 parent fc35bc8 commit ae73d9b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frontend/src/components/Stripe/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function CheckoutForm({ clientSecret }: CheckoutFormProps) {

const [message, setMessage] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [attempt, setAttempt] = useState<number>(0);

useEffect(() => {
if (!stripe) {
Expand All @@ -37,8 +38,13 @@ export default function CheckoutForm({ clientSecret }: CheckoutFormProps) {
setMessage("Your payment is processing.");
break;
case "requires_payment_method":
console.log(paymentIntent);
setMessage("Your payment was not successful, please try again.");
{
console.log(paymentIntent);
if (attempt > 0) {
setMessage("Your payment was not successful, please try again.");
}
setAttempt(attempt + 1);
}
break;
default:
setMessage("Something went wrong.");
Expand Down Expand Up @@ -72,7 +78,7 @@ export default function CheckoutForm({ clientSecret }: CheckoutFormProps) {
setIsLoading(false);
};

const paymentElementOptions:StripePaymentElementOptions = {
const paymentElementOptions: StripePaymentElementOptions = {
layout: "tabs"
}

Expand Down

0 comments on commit ae73d9b

Please sign in to comment.