Our users need to be able to activate addons on their account, which will cost a 1 time setup fee (say $100) and then a recurring monthly fee after that (say $10). I can do this manually by going to the Stripe Dashboard, finding the subscription, and adding both these items (the one time $100 and the recurring $10) and clicking "Update". However, when I change my code:
$subscription->swapAndInvoice([
'site-membership', // all users already have this plan
'10-monthly-fee', // this is the addon being added
'100-one-time-fee' // one-time addon fee
]);
I get an error:
Stripe\Exception\InvalidRequestException: You passed a non-recurring price but this field only accepts recurring prices.
If I can't use swap
, is there some other way I can do this all at once? I know I could make an independent invoice for the one time fee, but I would hate for our customers to receive two separate invoices when they could just be invoiced once for $110. Is this possible using Cashier?
There's no method in Cashier directly, but I found a way to achieve this by passing a value through to Stripe. (Stripe docs)
$subscription->swapAndInvoice([
'site-membership',
'10-monthly-fee'
], [
'add_invoice_items' => [
[ 'price' => '100-one-time-fee' ]
]
]);