#florian-ruen_billing-webhook-events
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1277663883254829087
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- florian-ruen_api, 3 hours ago, 14 messages
- florian-ruen_api, 4 days ago, 7 messages
- florian_subscription-invoice, 6 days ago, 14 messages
- florian-ruen_api, 6 days ago, 33 messages
- florian-ruen_best-practices, 6 days ago, 90 messages
Hello there,
for more details:
- i'm using checkout session as setup mode for my customers add billing details and credit card ;
- the eevent checkout.session.completed will create a subscription, only using the schedulling feature here ;
- when the invoice.created is fired, I'll add recorded usage (in my DB) to the invoice ;
but when my customer upgrade/downgrade/cancel, I want to charge now, the previous usage
i means if my customer sent 3 transactions, downgrade to free offer, i want to charge now for the 3 transactions, so i'm expected the invoice.created event
i guess using InvoiceNow from cancellation should fire this no ?
Hi ๐
Can you share an example API request ID for when a customer updated their subscription and an event was not fired?
for cancellation, this one: req_HP6IEAa5wkhvJv
for update, maybe this one: req_4eyHuBe0CM6pQw
maybe the event is not invoice.created for this, but something similar ?
For the invoice that was canceled, the subscription was created with a 0 price
So the first invoice was created and marked as paid
there wasn't anything to invoice for
Yes, but maybe in my own DB, I've usage to report for the final invoice (i'm not using billing meters here)
If the customer subscribe to premium on 3rd - then send 3 transactions - then cancel - i want to report the price for the 3 transactions for the final invoice
today when the billing period is finished, the invoice.created is fired, and I report the 3 transactions, but not working with cancel/update it seems
I see an update request here https://dashboard.stripe.com/test/logs/req_1rG2HbVIyPoEii
but the quantites are still 0 so nothing to bill
And then the Subscription is deleted in this request: https://dashboard.stripe.com/test/logs/req_HP6IEAa5wkhvJv
Nowhere do you ever provide any data that would generate an Invoice
So there is nothing to Invoice a customer for
so here, if i want to create an invoice, I need to manually create it right ?
using API call create invoice, will fire the event I think
because 0 quantity is normal, I'm using this to not bill for subscriptions fees, only usage (reported on invoice.created event actually)
if I put quantity 1, will generate an invoice, but the customer will pay fees (in my case 0.25 and 0.03), and I don't want this
only usage * 0.03 or usage * 0.25 (computation in my backend)
so here, if i want to create an invoice, I need to manually create it right ?
Not necessarily. Sorry your logic here makes absolutely no sense to me
You create a Subscription for a Customer but set thee quantity for two Subscription Items to 0.
Then you delete those items to replace them with two other Subscription Items, both with a quantity of 0.
What are you trying to bill your customer for?
Between the create and the update, the customer send 5 transactions.
The price for the 5 transactions will depend on the two subscriptions items unit price (which is 0.03 โฌ and 0.25 โฌ, will do computation based on this)
And before the update (= upgrade from one offer to another), I want to generate an invoice for the 5 transactions
Okay but there is no record with that Subscription of any of this
The records are in my own DB, because the computation for the price is way too complex to use billing meters for this
So to report this to the invoice, I'm using webhook events (invoice.created when billing cycle end)
Okay so we won't fire an Invoice created on these susbcriptions because there is nothing to bill a customer for
I see
However, you could listen to the customer.subscription.deleted event that this request triggered: https://dashboard.stripe.com/test/logs/req_HP6IEAa5wkhvJv
That event payload will contain the full Subscription, so you could do your calculations based on the prices in the Subscription items. https://dashboard.stripe.com/test/events/evt_1Ps5YuJihFHvqYjRWrKsQs0v
And then generate an Invoice for the Customer identified.
Same thing for the updated request. Use the customer.subscription.updated event
Then the logic of examining the Subscription object will work for both
I see
And is it better to use these 2 events, or to create an invoice before the cancellation / update, passing only the subscription and customer ID, to generate the invoice.created event?
That would depend on how you want to model the scenario. Personally, it makes more sense to me to rely on the two customer.subscription.* events then generate an empty Invoice just to create the invoice.created event.
I will do this way, seems good!
Thanks for your help!
Sure thing! Happy to shed what ๐ก I can ๐