Stripe making multiple customers with same email address

You will need to store the relationship between email address and Stripe customer ID in a database. I've determined this by looking at Stripe's API on Customers.

First, when creating a new customer every field is optional. This leads me to believe that every single time you POST to /v1/customers, it will "[create] a new customer object."

Also, when retrieving a customer the only field available is the id. This leads me to believe that you cannot retrieve a customer based on an email address or other field.


If you can't store this information in a database, you can always list all the customers with GET /v1/customers. This will require you to paginate through and check all customer objects until you find one with a matching email address. You can see how this would be quite inefficient if done every time you tried to create a customer.


You can list all users for a given email address. https://stripe.com/docs/api#list_customers

In JavaScript you could do this:

const customerAlreadyExists = (email)=>{
    return  doGet(email)
                .then(response => response.data.length > 0);
}

const doGet = (url: string)=>{
    return fetch('https://api.stripe.com/v1/customers' + '?email=' + email, {
        method: 'GET',
        headers: {
            Accept: 'application/json',
            Authorization: 'Bearer ' + STRIPE_API_KEY
        }
    }).then(function (response) {
        return response.json();
    }).catch(function (error) {
        console.error('Error:', error);
    });
}