#DeputyCheese
1 messages · Page 1 of 1 (latest)
What event are you looking for?
invoice.paid
I received the invoice.paid event yesterday, when I initiated the subscription via our booking form
Now I'm waiting for the subscription to be renewed + paid and to receive the invoice.paid event so I can renew/extend the subscription on our side.
The subscription is set to daily and the setup was at 12:17 yesterday. I should receive the webhook event before 12:17 today, right? Otherwise the subscription would have been expired.
You can refer to the upcoming invoice page about invoice creation timestamp: https://dashboard.stripe.com/test/customers/cus_MgqqzC6nQFfCe9/upcoming_invoice/sub_1LxT99ClDK2O5WMjJ52cX41a
The invoice will be finalised and charged 1 hour after creation: https://stripe.com/docs/billing/invoices/subscription#create-an-invoice
If you do not wish to wait, I'd recommend using test clocks to advance the time, so that you can test the events immediately: https://stripe.com/docs/billing/testing/test-clocks
Ah thanks that's super helpful
I saw that (https://dashboard.stripe.com/test/customers/cus_MgqqzC6nQFfCe9/upcoming_invoice/sub_1LxT99ClDK2O5WMjJ52cX41a) but I'm just curious when exactly the invoice will be created. It must be before the expiration date, right?
Yup, an invoice has to be created in order to charge the customer
But that happens automatically, right?
It depends collection_method on the subscription: https://stripe.com/docs/api/subscriptions/object#subscription_object-collection_method
If collection_method is set to charge_automatically, the invoice will charge to the saved payment method
Yes, that's what we are using
Then the invoice will be charged automatically with collection_method: charge_automatically
Will this always happen on the day of the expiration and at the exact same time? In this case today at 12:17?
Hi! I'm taking over this thread.
You can know when the next invoice will be created by looking at current_period_end on the subscription objet: https://stripe.com/docs/api/subscriptions/object#subscription_object-current_period_end
If you have a daily subscription, then yes the next invoice will be created at about the same time every day.
Note that the invoices are created in draft, and then are finaliazed by Stripe automatically one hour later. But you can finalize the invoices yourself if you don't want that delay.
And in general you can test this type of things on your end by using Test Clocks: https://stripe.com/docs/billing/testing/test-clocks
Okay thanks, I got it.
One more question:
I am not using prices in the stripe dashboard but submit them dynamically (because based on the given user the price can be different and also change during the subscription).
How can I afterwards change a price?
I found this: https://stripe.com/docs/api/prices/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But it looks like I only can change meta data etc.
I would need to change the price itself though (for example: someone subscribes for 5€ in the first month, but based on his inputs the price can be 4€ in the second month and so on)
You can't change a price after it was created. If you want to change the price of a subscription, then you have to create a new price and then update the subscription. This is explained here: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade
Okay, this is no downgrade/upgrade though. For example: the user initiates a subscription, but adds his vat afterwards. The the second month has to have a lower price than the first one, even if it's the same product/subscription (because the user would get an invoice without vat for the second month, but not for the first month, because he added it after it was already created). How would I do this?
I cannot immediately charge him too because this change only applies to the second month (+ the following months) but he has already paid for the first one.
So you would like to change the price of the subscription the next time the subscription renews?
Exactly
Then it's a little more complicated. For this you would need to use subscription schedules: https://stripe.com/docs/billing/subscriptions/subscription-schedules
Mmmh it's not really a phase/scheduled subscription but only something tax related. Isn't it possible to change the price when invoice.created is called or something like that?
I also cannot predict when (+ if) the user adds his tax information
the user initiates a subscription, but adds his vat afterwards
Can you clarify how the user add his vat? Is this related to Stripe Tax or something your compute on your end?
That's something on our end. We have a lot of business clients with valid vat numbers. Those clients can add their vat number on our end, so they will receive an invoice excluding sales tax.
Now it could happen that they add their vat number after they already submitted the subscription. In that case we would like to give them a correct invoice in the following month/renewal.
We are not using stripe invoices but our own.
Another use case would be if we decide to change the price of our subscription in the future (same product).
Then we also would need to make a price change of running subscriptions
Maybe it's this? https://stripe.com/docs/api/subscription_items/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
We are not using stripe invoices but our own.
Can you clarify this?
Another use case would be if we decide to change the price of our subscription in the future (same product).
Like I mentioned earlier, if you want to make change to a subscription in the future, you have to use subscription schedules.
Yes, we got our own invoicing system and we cannot use stripe invoices, so the user will get invoices directly from us and not the ones from stripe in our dashboard. We have to merge invoices + products from different sources so we cannot use the ones from stripe.
Can you check this one here: https://dashboard.stripe.com/test/subscriptions/sub_1LxRvqClDK2O5WMjUxxF4oKi
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I changed the price, it was 4.16€ in the first month and now is 4.99€
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Yes, we got our own invoicing system and we cannot use stripe invoices
So you use Stripe subscription to charge the customer, but you don't use the actual Stripe invoices (you built your own)?
Yes
Stripe invoices are created though but we don't send them to the user, instead he receives them from us.
Okay, makes sense!
But yes what I mentioned before still applies:
- You can directly update the amount of a price
- Instead you need to create a new price and then update the subscription with https://stripe.com/docs/billing/subscriptions/upgrade-downgrade
- And if you want to make the change at a future date, then you need to use subscription schedules: https://stripe.com/docs/billing/subscriptions/subscription-schedules
Okay but it worked, did you see this:
https://dashboard.stripe.com/test/subscriptions/sub_1LxRvqClDK2O5WMjUxxF4oKi
I was using subscriptionItem->update and then I could pass my payment_data the same way as when I created the subscription
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
You see the first month was 4.16€. The next invoice will be 4.99€ though.
👋 taking over for my colleague. Let me catch up.
taking a look at the subscription
it would be a minute
no problem, thanks
Fyi I am using stripe->subscriptionItems->update for the price change
1.) Getting the subscription (subscriptions->retrieve($subscriptionId))
2.) Getting the subscription item ($subscription->items->data[0])
3.) Updating the price of the subscription item (subscriptionItems->update($subscriptionItem->id,['price_data' => ...]))
ok
This is my subscription I was testing right now:
https://dashboard.stripe.com/test/subscriptions/sub_1LxSsnClDK2O5WMjnIYCRPhY
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
what is the Q really?
The first month was 4.16€ and I now changed it to 4.99€
The basic question was how I can change a price of a running subscription when it's not an immediate upgrade/downgrade and the subscription stays the same EXCEPT for that price change. Your colleague said I have to use schedules but it seems to work the way I described it too.
The use case is: a user creates a monthly subscription and is billed 4.99€ in the first month. Now the user adds his vat afterwards and therefore doesn't have to pay the 4.99€ anymore but instead the net price (4.16€ for example) because of reverse-charge.
In that case (or also just with price changes in our subscription) I would have to change the price for a subscription dynamically.
so you want to refund the already paid VAT?
nope
I just want to change the price for the future months
And I think I found the way (see above) but I'm just confused because your colleague told me I have to use schedules and that this is the only way.
I just want to make sure it's correct
Okay, let's say we've got a lot of subscriptions. And in 5 years we are changing our pricing, so everything will be +1€. How can we do this?
So from January 1st everything is 5.99€
Then there are users whos subscription ends at January 14th for example. And with the renewal we would have to raise the price.
if you which for the price to take affect in the next billing cycle you can use https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior none and https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_cycle_anchor unchanged
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Please give me a second, I'm testing it right now.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I changed the interval to weekly so we can better see when the next invoice will be issued
Nope, somehow now the item is added
fyi, you can use test clocks if you want to test subscriptions https://stripe.com/docs/billing/testing/test-clocks
Thanks I saw that, but that's not helping atm. I need to change the price for the next renewal. When I update the subscription a new product is added though.
I agree, I just wanted to mention this while I take a look at your subscription
I know what happened
you are trying to update the Subscription Item instead of the Subscription itself
you need to create a Subscription and in items you can mention the (already created) subscription item id to update it
Ah sorry, my mistake
I forgot to define the subscription item id in the subscription update items key
This looks correct, right? https://dashboard.stripe.com/test/subscriptions/sub_1LxpKyClDK2O5WMjNFmnDbDA
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I'm updating the price via:
$stripe->subscriptions->update($subscriptionId, [
'cancel_at_period_end' => false,
'proration_behavior' => 'none',
'billing_cycle_anchor' => 'unchanged',
'items' => [
[
'id' => $subscription->items->data[0], // there's always only one item in subscriptions
'price_data' => [
'unit_amount' => $price,
'currency' => 'eur',
'product' => $productId,
'recurring' => [
'interval' => 'week',
],
]
],
],
]);
So in sub_1LxpKyClDK2O5WMjNFmnDbDA we got 4.99€ for the week october 28th - november 3rd and then 4.16€ for nov 4th - nov 11th, right?
Great
And the invoice for the week 4th-11th isn't issued right now, but later short before renewal, right?
So it's not immediate like the way I changed the price before, right?
yes correct
correct
Peeerfect, thank you so much! That's exactly what I needed 😄
You've been a great help, thank you very much
let me know if you need any more help
Yeah one more question 😄
I see that the webhook was called for this subscription:
https://dashboard.stripe.com/test/subscriptions/sub_1LxT99ClDK2O5WMjJ52cX41a
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I only received customer.subscription.updated though
The renewal invoice is still in draft and the invoice.paid hook was not called at all
I would have expected that the invoice.paid event would have been called by now to confirm the renewal + that the user paid?
This is the webhook: https://dashboard.stripe.com/test/webhooks/we_1Kc3JvClDK2O5WMjZLaXTAPg
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
that's normal, this will happen once the upcoming invoice gets created and paid
this is why I suggested using test clocks
so you can advance in time and see the changes instantly
not really since you wanted the invoice to be generated on the next billing cycle
Do I have to use collection_method => charge_automatically for this or is this the default value?
not related
collection_method is by default charge_automatically but that doesn't mean it will charge immediately
if you want your customer to be charge immediately you would go back to the previous model
your first use-case
I thought the user only has to enter his credentials and pay an invoice once he starts his subscription, and after that the rest runs automatically -> every month a new invoice is created and the amount is automatically deducted from his credit card?
yes that's correct, if you're using charge_automatically
But this should be charge_automatically already (if that's the default value)?
yes true
My first use case was solved, this is another one.
I want the charge to happen automatically
the charge is happening automatically
it's just not immediate
you have to wait till the next invoice gets generated and it will be paid using the payment method attached to customer or subscription
Okay, but in this case the payment has not been made but the time was running out
If I understood correctly, this (https://dashboard.stripe.com/test/subscriptions/sub_1LxT99ClDK2O5WMjJ52cX41a) should have been paid until 28th october 2022 12:17 (~14 minutes ago)
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Because now the subscription has ended but payment has not been made for the next interval
(in that example the interval is 1 day)
taking a look, but what happens at the end of a cycle is we generate an invoice and wait an hour
Thanks. So that would mean there's an hour difference between the end of the subscription for last interval before I really know that the client has paid
that's one way of looking at it I suppose yes. The billing period is all correct, it's just that the payment itself can happen a little later
Okay, so I should allow users to use our services outside of the subscription for ~ +1 hour right?
yes https://stripe.com/docs/billing/subscriptions/webhooks#active-subscriptions
Your site receives an invoice.paid event.
Your webhook endpoint finds the customer the payment was made for.
Your webhook endpoint updates the customer’s access expiration date in your database to the appropriate date in the future (plus a day or two for leeway).
Because right now the state would be, that the user has no access to the service because he hasn't paid for the 2nd day
in your case if it's a daily plan I suppose you don't want days of leeway, but a few hours, sure
Ah thanks. So 2 days and we should be fine, right?
Thanks. That's just for testing purposes. We will have monthly or yearly so 2 days should be fine.
seems fine. depends too what retry schedule you have configured for invoice retries and how you want to treat giving access in those cases
Okay thanks for your help
One last question:
Will stripe contact our clients directly to pay an invoice if that fails?
Or only if we pass their e-mail address?
I think it depends, if it's collection_method:charge_automatically I don't think we email them, we just retry the charge per the settings you configure on https://dashboard.stripe.com/settings/billing/automatic, we'd only email invoice links for send_invoice invoices that are passing due dates