feat(tip): add coffee tipping page
This commit is contained in:
@@ -27,12 +27,14 @@ const stripePromise = stripePublishableKey
|
||||
|
||||
export interface StripePaymentDialogProps {
|
||||
clientSecret: string;
|
||||
returnPath?: string;
|
||||
onClose: () => void;
|
||||
onConfirmed?: () => void;
|
||||
}
|
||||
|
||||
export function StripePaymentDialog({
|
||||
clientSecret,
|
||||
returnPath = ROUTES.subscription + "/success",
|
||||
onClose,
|
||||
onConfirmed,
|
||||
}: StripePaymentDialogProps) {
|
||||
@@ -91,7 +93,11 @@ export function StripePaymentDialog({
|
||||
},
|
||||
}}
|
||||
>
|
||||
<StripePaymentForm onClose={onClose} onConfirmed={onConfirmed} />
|
||||
<StripePaymentForm
|
||||
returnPath={returnPath}
|
||||
onClose={onClose}
|
||||
onConfirmed={onConfirmed}
|
||||
/>
|
||||
</Elements>
|
||||
</div>
|
||||
</div>
|
||||
@@ -99,9 +105,13 @@ export function StripePaymentDialog({
|
||||
}
|
||||
|
||||
function StripePaymentForm({
|
||||
returnPath,
|
||||
onClose,
|
||||
onConfirmed,
|
||||
}: Pick<StripePaymentDialogProps, "onClose" | "onConfirmed">) {
|
||||
}: Pick<
|
||||
StripePaymentDialogProps,
|
||||
"returnPath" | "onClose" | "onConfirmed"
|
||||
>) {
|
||||
const stripe = useStripe();
|
||||
const elements = useElements();
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
@@ -141,7 +151,7 @@ function StripePaymentForm({
|
||||
}
|
||||
|
||||
const returnUrl = new URL(
|
||||
ROUTES.subscription + "/success",
|
||||
returnPath ?? ROUTES.subscription + "/success",
|
||||
window.location.origin,
|
||||
);
|
||||
const { error } = await stripe.confirmPayment({
|
||||
|
||||
Reference in New Issue
Block a user