#Lucas974
1 messages · Page 1 of 1 (latest)
There are a number of ways to do this. Do your users log in before creating a payment?
nop
in fact I will use passwordless auth
I need to build a api for stripe webhook
to detect new users, and add them to mongodb
when payment is done, they will get a thank you page with a text saying them, to restore purchase, go back to home and press restore purchase, this will ask them their email, and then if they are registered, they will get an url to visit and get the product + stripe invoice
I wish to deny user to go manually at /thankYou page (even if there's nothing important here :))
is there a way to do that ?
You could dynamically build the URL based on the Checkout Session ID and restrict users from accessing the URL without a Checkout Session ID. You could also just track the session with a cookie that tells your server to only redirect to the /thankYou page if they have the cookie.
It all kind of depends on what you want to do
the easiest way for you ??
`'You could also just track the session with a cookie that tells your server to only redirect to the /thankYou page'
How can I do that?
I use this:
import { loadStripe } from '@stripe/stripe-js';
export default function handlePayment(event){
const stripeLoadedPromise = loadStripe(import.meta.env.VITE_STRIPE_API_KEY);
stripeLoadedPromise.then(stripe => {
stripe.redirectToCheckout({
lineItems:[{
price: import.meta.env.VITE_STRIPE_PRODUCT_ID,
quantity: 1
}],
mode: "payment",
successUrl: `${import.meta.env.VITE_URL_ROOT}/thankyou`,
cancelUrl: `${import.meta.env.VITE_URL_ROOT}/`,
billingAddressCollection: 'required',
})
.then(response => {
console.log(response.error);
})
.catch(error => {
console.log(error);
});
});
}
I can't really write the code for you, but I would recommend taking a look at this: https://stackoverflow.com/questions/66334547/react-and-react-router-a-really-very-basic-and-simple-cookie-banner
That's a pretty simple answer for a simple cookie implementation using React Router
Unfortunately that's the simplest it gets for the most part. It might be worth doing a google search to learn how cookies work with React and maybe look at some tutorials
this cookie https://m.stripe.network contains the information?
No, you would need to set your own cookie
the cookie i will set
what is the relationship with the successurl?
I don't understand at which moment this cookie will be created, and by which route?
If you can explain me a bit more without giving me the code, just how it works
I will be very very grateful 🙂
and this is the frontend part...