In this episode, we focus on displaying two key details for our customers: their upcoming renewal date and the total amount for their next subscription charge. At first, it might seem like we can just grab this info straight from Stripe's subscription object, but in reality, it doesn't always have these values calculated the way we need them (especially the next amount due).
To solve this, we use Stripe's concept of the "upcoming invoice"—which is super handy because it tells us exactly when the next charge is due and how much it's going to be. Laravel Cashier, our go-to for subscription billing, conveniently provides an upcomingInvoice()
method on the billable model, and it's already nicely wrapped in a useful object!
We walk through how to grab this invoice object, check if it's present (since users who have cancelled might not have an upcoming invoice), and then show the renewal date. We also make sure to format the date nicely (using Carbon's toDateString()
and even diffForHumans()
for a friendly countdown). Finally, we display the next charge amount, which is formatted automatically to match the currency, thanks to Cashier's built-in helpers.
By the end, you'll see how to safely show users when their subscription will renew and the precise amount they'll be charged next, creating a clearer billing experience. Plus, you'll know how to pull out any other relevant details from the upcoming invoice if you wish!