I’m trying to implement the diagram (find it at the bottom of this post) in my application. This is required in order to prevent users from accidentally purchasing the same products more than once.
At a minimum, I would like to be able to create a checkout session where I can specify I don’t want to allow existing customers from making purchases, for example:
stripe.checkout.sessions.create({
line_items: [{
price: priceId,
quantity: 1,
}],
mode: "payment",
ui_mode: "embedded",
redirect_on_completion: "never",
// I would like something like this:
forbid_returning_customers: true,
});
I would then set this to true
only when the checkout session is being created by a non-logged-in visitor.
While, for logged-in visitors, I would set it to false
and I would pre-populate the customer id so that the email is pre-filled for them.
It would be better if it allowed me to specify a custom error message or a way to programmatically handle the event.
Unfortunately I can’t find anything that satisfies my needs on the Stripe API documentation. What am I missing?
Here’s the diagram with the whole flow, I’m providing it in case other solutions could apply to my request.