When dealing with metered billing, either with recieving usage records or reporting usage to a metered subscription, stripe tells me this:
Error:
Cannot create a usage record for SUBSCRIPTION_ITEM because it is not on the legacy metered billing system. Call /v1/billing/meter_events instead.
Cashier Stripe Version
15.0
Laravel Version
11.21.0
PHP Version
8.2
Database Driver & Version
No response
Description
When dealing with metered billing, either with recieving usage records or reporting usage to a metered subscription, stripe tells me this:
Error: Cannot create a usage record for
SUBSCRIPTION_ITEM
because it is not on the legacy metered billing system. Call /v1/billing/meter_events instead.Here are the docs: https://docs.stripe.com/api/billing/meter-event/create
This code worked for me then:
$stripe = new StripeClient(config('services.stripe.secret')); $stripe->billing->meterEvents->create([ 'event_name' => 'EVENT_NAMEr', 'payload' => [ 'value' => '1', 'stripe_customer_id' => $company_stripe_id, ], 'identifier' => 'identifier_123', ]);
Steps To Reproduce
$company->subscription('default')->reportUsageFor('PRICE_ID', 1);