Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe, is it possible to search a customer by their email?

Update: Since around January 2018, it is now possible to search using the email parameter on Stripe. See the accepted answer.


I was wondering if it was possible to search a customer only by their email address when using the Stripe API.

The documentation only indicates searching by:

created, ending_before, limit, starting_after  

but not email.

I'd like to avoid having to list over all my customers to find which ones have the same email addresses.

like image 311
Cyril N. Avatar asked Nov 05 '14 21:11

Cyril N.


People also ask

How do I get my Stripe customer information?

On the left side of the page, you'll find basic information about the customer, like their name and contact details, and a helpful summary of their purchase history, including how much they've spent with your business. If you've provided metadata for a customer, such as an internal ID, it will also appear here.

What information can be stored under a customer ID Stripe?

The Customer resource is a core entity within Stripe. Use it to store all of the profile, billing, and tax information required to bill a customer for subscriptions and one-off invoices.

How do you search on Stripe?

To search for an entire phrase, use quotation marks. For example, “Stripe Shoppe” provides matches for that full phrase, but Stripe Shoppe searches the words Stripe and Shoppe separately.

Where do I find my Stripe customer ID?

Finding your account ID An account ID is generated for you when you create your Stripe account. This is different from your account's name and uniquely identifies your account. You can find your account ID in your Account and Profile settings.


2 Answers

Stripe now allows you to filter customers by email.

https://stripe.com/docs/api#list_customers

Map<String, Object> options = new HashMap<>(); options.put("email", email); List<Customer> customers = Customer.list(options).getData();  if (customers.size() > 0) {     Customer customer = customers.get(0);     ... 

This is important to help ensure you don't create duplicate customers. Because you can't put creating a customer in Stripe and the storage of the Stripe customer ID in your system inside a single transaction you need to build in some fail safes that check to see if a particular customer exists before you create a new one. Searching customers by email is important in that regard.

like image 52
Russ Jackson Avatar answered Sep 21 '22 17:09

Russ Jackson


I did this by using the following API request. This was not available in stripe docs.I got this by tracking down their search in the dashboard area using Browser Developer Tools.

    url :https://api.stripe.com/v1/search?query="+email+"&prefix=false",     method: GET     headers: {       "authorization": "Bearer Your_seceret Key",       "content-type": "application/x-www-form-urlencoded",     } 

Warning This uses an undocumented API that is specific to the dashboard. While it might work today, there is no guarantee it will continue to work in the future.

like image 36
Sufyan Ahmad Avatar answered Sep 22 '22 17:09

Sufyan Ahmad