Laravel stripe get subscription date

By: Ryan Wong at

I’ve looked at alot of tutorials and couldn’t find one that can retrieve your subscription plans details like when subscription ends.
You must install laravel cashier first.

1
2
3
4
5
6
7
8
9
10
11
12
13
use Stripe_Customer as Customer;
public function getSubscriptionDetail($user)
{

Stripe::setApiVersion("2015-02-10");
Stripe::setApiKey(Config::get('services.stripe.secret'));
$customer = Customer::retrieve($user["stripe_id"]); //your customer stripe id
$subscription = $customer->subscriptions->retrieve($user["stripe_subscription"]); //stripe subscription column in your user table
return array(
'subscriptionPlan' => $subscription->plan->statement_descriptor,
'planEnd' => date('Y-m-d', $subscription->current_period_end),
'planPrice' => $subscription->plan->amount
);
}