'Laravel - How to retrieve all subscriptions with metadata from Stripe
I am creating a Stripe subscription with Laravel cashier. I have successfully created a subscription in Stripe with metadata. How to retrieve all subscriptions (with metadata) of a customer.?
Below is the code that creates the subscription
$request->user()->newSubscription('main', $plan->stripe_plan)->withMetadata(['wcda_reference' => $reference])->create($request->stripeToken);
Tried below code to retrieve but its listing from my database - not from Stripe API
$request->user()->subscriptions();
Solution 1:[1]
$all_subs_ids = [];
$allSubs = \Stripe\Subscription::all(['limit' => 10, 'status' => 'active']); foreach($allSubs->autoPagingIterator() as $allSub) {
array_push($all_subs_ids, $allSub->id);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | S.I. |
