When calling Stripe::Customer.all(:limit => 100)
there is a limit of 100 per call. We have a lot more customers than that, and I would like to get them all at once. Am I missing something, or is this only possible by writing a naive loop that checks on the has_more
attribute and then makes a new call until has_more = false
?
Just use the following line of code you will get the customer id. $customer = $stripe->customers()->create([ 'email' => $_POST['stripeEmail'], 'source' => $_POST['stripeToken'], 'plan' => trim($plan) ]); echo $customer['id']; This will help you.
By default, Stripe shows examples using the popular command line tool curl.
It is built for its users, engineers Stripe's landing pages & online sandboxes play a key role at this. For each business area (Payment, Business operations, etc.), you can choose from integration guides, sample open source projects or no-code alternatives.
Stripe integrations handle complicated processes. The API uses a single object to track each process. You create the object at the start of the process, and after every step you can check its status to see what needs to happen next. For instance, while completing a payment, a customer might try several payment methods.
You are right, you must write a naive loop with a cursor per the stripe docs:
starting_after
optional
A cursor for use in pagination.
starting_after
is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending withobj_foo
, your subsequent call can includestarting_after=obj_foo
in order to fetch the next page of the list.
Here's one in case anyone needs a quick copy-paste.
def self.all_stripe_customers
starting_after = nil
customers = []
loop do
results = Stripe::Customer.list(limit: 100, starting_after: starting_after)
break if results.data.length == 0
customers = customers + results.data
starting_after = results.data.last.id
end
return customers
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With