Stripe,是否可以通过电子邮件搜索客户? [英] Stripe, is it possible to search a customer by their email?
问题描述
更新:从 2018 年 1 月左右开始,现在可以使用 Stripe 上的 email
参数进行搜索.请参阅已接受的答案.
Update: Since around January 2018, it is now possible to search using the email
parameter on Stripe. See the accepted answer.
我想知道在使用 Stripe API 时是否可以仅通过电子邮件地址搜索客户.
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.
推荐答案
Stripe 现在允许您通过电子邮件过滤客户.
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);
...
这有助于确保您不会创建重复的客户.因为您不能将在 Stripe 中创建客户和在系统中存储 Stripe 客户 ID 放在单个事务中,所以您需要构建一些故障保险柜,在创建新客户之前检查特定客户是否存在.在这方面,通过电子邮件搜索客户很重要.
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.
这篇关于Stripe,是否可以通过电子邮件搜索客户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!