admin管理员组

文章数量:1313613

I have this:

const customer = await stripe.customers.retrieve(
  '[email protected]'
);

I'm trying to get the customer number (id) of the customer based on the email address. Is this possible through stripe? It gives me an error when I do this.

I have this:

const customer = await stripe.customers.retrieve(
  '[email protected]'
);

I'm trying to get the customer number (id) of the customer based on the email address. Is this possible through stripe? It gives me an error when I do this.

Share Improve this question edited Oct 7, 2022 at 23:47 Super Kai - Kazuya Ito 1 asked Oct 27, 2021 at 3:31 gianlpsgianlps 2174 silver badges14 bronze badges 2
  • it says you need the id stripe./docs/api/customers/retrieve – cmgchess Commented Oct 27, 2021 at 3:44
  • maybe there can be many accounts for one email address – cmgchess Commented Oct 27, 2021 at 3:47
Add a ment  | 

2 Answers 2

Reset to default 8

You will need to use https://stripe./docs/api/customers/list and it will return a list of customers with that particular email address.

const customers = await stripe.customers.list({
  email: '[email protected]',
});

Note that there is a limit on the number of objects to be returned. You should make use of auto pagination in case there is a large number of customers with the same email.

Using "list()" and "search()", you can get customers by email with these Node.js code below:

const customers = await stripe.customers.list({
  email:"[email protected]",
});
const customers = await stripe.customers.search({
  query:"email:'[email protected]'",
});

You can also limit customers to get with "limit" parameter as shown below:

const customers = await stripe.customers.list({
  email:"[email protected]",
  limit: 3,
});
const customers = await stripe.customers.search({
  query:"email:'[email protected]'",
  limit: 3,
});

本文标签: javascriptHow to retrieve customers by email in nodejs (Stripe)Stack Overflow