I am having a problem adding invoice item on subscription and currently banging my head on the wall.
I've created an Invoice Item on stripe and I’d like the Invoice Item to be included on the recurring payment
Here’s my code, it adds an invoice item on first invoice but not on the next invoice.
$new_customer = Stripe_Customer::create(array(
'card' => $card,
'email' => $email,)
);
Stripe_InvoiceItem::create(array(
'customer' => $new_customer['id'],
'amount' => $additiona_charges,
'currency' => 'gbp',
'description' => 'Addtional Cities'
));
$new_customer->updateSubscription(array('plan' => $selected_plan, 'prorate' => true));
On my current set-up. I have additional custom charges based on customer selection upon subscription thats way I need to add additional charges on recurring payment.
Its something like this
1 Cookie - 99GBP / Per month
2 Cookies - 199GBP / Per month
3 Cookies - 300GBP / Per month
-With Candle - +20GBP // must be included on recurring payment.
-With Icecream - +26GBP // must be included on recurring payment.
-With Cheese - +28GBP // must be included on recurring payment.
-With Ketchup - +30 // must be included on recurring payment.
-With Poison (for your X) - +50 // must be included on recurring payment.
I hope someone could help. Thanks so much
Cheers Kenn
Recurring chargesAutomatically invoicing customers and attempting payments when new billing cycles start. When payments fail, Stripe retries them using the Smart Retries feature.
Stripe automatically creates an invoice for subscriptions at the end of each billing cycle. To create a one-off invoice for a non-recurring price, read the Invoicing docs. Stripe finalizes and sends the invoice in 1 hour. Before the invoice is finalized, you can edit it.
Multiple subscriptions for a customerYou can simultaneously create multiple subscriptions for a single customer. This capability is useful when you want to make it possible for your customers to subscribe to multiple products with separate intervals.
Make a partial payment, select Take part payment. Enter the amount of the payment and then click Charge. The invoice status is updated to Part Paid.
I have a support question open with Stripe, so will update as / if necessary.
However, I have just re-read the documentation on metered billing
The account balance and invoice items are simply one-time adjustments to your customer's account, so they won't be automatically applied each month.
If your service uses metered billing or needs to add custom amounts for taxes or other dynamic costs, then you will need to create invoice items every month.
It continues ....
To get started, just use webhooks to listen for the invoice.created event. Whenever an invoice is open for modification, your webhook endpoint can create an invoice item that references the existing invoice's ID. We'll automatically pull this amount into the invoice total before charging your customer.
So, it seems we'll need to create a web hook handler in order to re-add these invoice items each month.
According to the documentation on invoices
Once an invoice is created, payment is automatically attempted. Note that the payment, while automatic, does not happen exactly at the time of invoice creation. If you have configured webhooks, the invoice will wait until one hour after the last webhook is successfully sent (or the last webhook times out after failing).
That allows us to create a web hook, in order to modify the invoice, prior to payment being attempted.
My suggested InvoiceCreatedWebhook process
invoice.created
event - the full body looks like this
How about just creating the extras as additional plans and subscribing the client to those plans as well? So he would be subscribed to the 1 cookie plan + ice-cream plan as an example. You sure can have the same customer subscribed to multiple plans.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With