Stripe - check if client exists

In the lane documentation, they have the following:

customer = Stripe::Customer.create(email: params[:stripeEmail], card: params[:stripeToken])
charge = Stripe::Charge.create(customer: customer.id, amount: price, description: '123', currency: 'usd')

      

But I think this is wrong as for each payment we have to check if the customer exists in the first place, I just tried it with a test account and it turned out that several different customers were created with the same email address, but with different identifiers.

How to check if a client exists?

+3


source to share


1 answer


There is no Stripe end-to-end validation to ensure the uniqueness of customers (email, card, name, etc.) and that's what you need to do at the end.



Typically, when you create a customer with a specific email address, you need to associate the customer ID that you received from the API with the email address. Then next time you check if that email is on your system and either create a new customer or reuse the customer ID from the previous time.

+6


source







All Articles