#BilalSaeedAlam
1 messages · Page 1 of 1 (latest)
hi, what's the question?
Basically i am using Stripe Card Element by using it i am getting payment method and then i am sending this id to backend to create cusstomer and store that customer id to database.
So is it a good way to store customer id into database and in future with that id i will get customer detail and payment id and charge customer.
HEre is the way i am taking card info like payment method id
const { paymentMethod, error } = await stripe.createPaymentMethod({
type: 'card',
card: cardElement,
});
here after getting payment id i am call backedn API
const response = await createCustomerId(id);
On the backend side i am creating customer like this
const customer = await stripe.customers.create({
payment_method: paymentMethodId,
invoice_settings: {
default_payment_method: paymentMethodId,
},
//source: paymentMethodId,
// Add any additional customer information as needed
});
const customerId = customer.id;
generally you should use a SetupIntent for all instead, don't manually save the PaymentMethod.
So basically we need to first create payment method element on stripe on frontend and then call second steup for this
and in the second step part 2 if there is no customer then we will create cyustomer and attach with it
??
the guide above I think explains the steps
Can we use one customer id for multiple payment methods? Like if i create a customer id and store it, next time if i change payment method so that customer id will attach with it. We don't need to create customer again and again?
yes, you can reuse customer IDs and use the same ID with multiple SetupIntents and attach multiple cards to the customer
Alright thank you