Reputation: 107
I am creating stripe checkout as below -
stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: "USD",
product_data: {
name: "Product Name",
images: ["ProductImage"]
},
unit_amount: "200",
},
quantity: 2,
},
],
mode: 'payment',
success_url: "https://example.test/success",
cancel_url: "https://example.test/cancel",
});
I am not having any customer login. I want that only 1 customer should be created at stripe end corresponding to an email. Since I don't have customer login, so can't pass customer id while creating checkout session.
Is there any way to validate customer using email added in checkout payment form. Can we use any webhook or event for this? Any pointers? TIA.
Upvotes: 2
Views: 3374
Reputation: 1938
If you're not storing Customer object IDs and passing them when creating a Checkout Session, and you do not want a new Customer object to be created for each successful session then you can pass the customer_creation
parameter to prevent this.
stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: "USD",
product_data: {
name: "Product Name",
images: ["ProductImage"]
},
unit_amount: "200",
},
quantity: 2,
},
],
mode: "payment",
success_url: "https://example.test/success",
cancel_url: "https://example.test/cancel",
customer_creation: "if_required"
});
Upvotes: 6