Friday, April 14, 2017

Laravel cashier with Stripe: invoice number

Not sure it's the same elsewhere, but in my country, invoice numbers must be sequential for a service in a company.

My Laravel application sells a service via subscription. It must produce invoices with sequential numbers (abcdef-0001, abcdef-0002, etc.). I use Laravel Cashier with Stripe because both are easy to configure. Now I want to generate invoices. But Invoices in Laravel Cashier have no sequential numbers nowhere. I can access to one user "invoices" with:

$invoices = $user->invoices();

But it seems it's not really invoices, just payment informations from Stripe. Calling this function for each user to get the total number of invoices, then calculate the sequential number is not an option.

How can I handle a sequential number for invoices easily without breaking the simple model built by Laravel Cashier (+Stripe)? Is there a proper way to do this kind of thing? Or do I have to re-develop a whole system for such a need?



via rap-2-h

Advertisement