Reputation: 8877
I'm using Laravel 5 with the Cashier package. I have some simple subscriptions ('standard' and 'pro') set up.
I need to show how much the user is currently being billed per year - the subscriptions are both annual.
I also have a handful of coupons a user can use. So, how can I show what the user is currently being billed, taking into account their coupon they may or may not have used?
I'd like to think $user->currentBillingPrice
might exist, or something similar. I'd even be happy with $user->invoice->latest->total
, if such a thing exists?
Upvotes: 1
Views: 2168
Reputation: 903
In case someone comes looking for this still, as it's pretty high in search results, "asStripeUser" appears to be "asStripeCustomer" now. You can use it to grab a plethora of information about the current customer.
$info = $user->asStripeCustomer();
Upvotes: 1
Reputation: 978
For those still looking for this answer.
You have access to the Stripe objects which contain the information you're looking for. Here is an example of how to get this information for percentage coupons.
To get subscription information (change 'main' to what you use)...
$sub = $user->subscription('main')->asStripeSubscription();
$plan = $sub->plan;
$amount = $plan->amount;
$percent_off = $sub->discount->coupon->percent_off;
To get user information (you can apply a coupon to the user and it applies to all his invoices)
$stripe_user = $user->asStripeUser();
$percent_off = $stripe_user->discount->coupon->percent_off;
Upvotes: 1