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

前端 未结 12 1424
暗喜
暗喜 2020-12-08 06:32

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


I

12条回答
  •  再見小時候
    2020-12-08 06:44

    Stripe now allows you to filter customers by email.

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

    Map options = new HashMap<>();
    options.put("email", email);
    List 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.

提交回复
热议问题