Draft: Preview stripe payment
This commit is contained in:
parent
6234a284e0
commit
c6fe5b4ff1
@ -1,5 +1,6 @@
|
||||
import MainButton from "@/components/MainButton";
|
||||
import Title from "@/components/Title";
|
||||
import routes from "@/routes";
|
||||
import { actions } from "@/store";
|
||||
import {
|
||||
PaymentElement,
|
||||
@ -8,6 +9,7 @@ import {
|
||||
} from "@stripe/react-stripe-js";
|
||||
import { useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
interface ICheckoutFormProps {
|
||||
children?: JSX.Element | null;
|
||||
@ -17,6 +19,7 @@ export default function CheckoutForm({ children }: ICheckoutFormProps) {
|
||||
const stripe = useStripe();
|
||||
const elements = useElements();
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [message, setMessage] = useState("");
|
||||
const [isProcessing, setIsProcessing] = useState(false);
|
||||
@ -43,6 +46,7 @@ export default function CheckoutForm({ children }: ICheckoutFormProps) {
|
||||
setMessage(error?.message || "Oops! Something went wrong.");
|
||||
} else {
|
||||
dispatch(actions.status.update("subscribed"));
|
||||
navigate(routes.client.paymentSuccess());
|
||||
}
|
||||
} catch(error) {
|
||||
console.log('error -> ', error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user