I'm using Laravel's
Stripe integration
to bill customers on a monthly basis.
Is it possible to add an invoice item to my subscription, so that my customer is billed monthly for a number of items he/she used within that period?
This question suggests that it is possible
And Laravel's
documentation covers creating an invoice but not adding an invoice item.
Does anyone know if there is a Laravel
method for add invoice item? If not, how is an invoice item added?
I think will be easier with Laravel 5.4, but since it's not out as of this writing, you have to set it up manually.
with Laravel 5.4 (assuming this function makes it in)
$user->invoiceForUpcoming('One-time charge', 1000);
Manual way (make sure you have Cashier installed, etc):
use Stripe\InvoiceItem as StripeInvoiceItem;
The in your controller or wherever makes sense:
$options = [
'customer' => $user->stripe_id,
'amount' => 1000,
'currency' => 'usd',
'description' => 'One-time fee',
];
$response = StripeInvoiceItem::create(
$options, ['api_key' => config('services.stripe.secret')]
);