#idyoks_api
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/1303329133215875145
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Did my message get truncated, or is it just on my end?
it might have been
Issue Description:
I'm trying to figure out why, in test mode, after the first subscription payment using the advance time clock feature, Stripe behaves unexpectedly when I move the clock to the current subscription's end period.
Here’s what happens step by step:
-
Initial Setup:
- I created a product with a
price_id. - I have an endpoint on my backend that I use to create checkout session:
- Creates a customer if they don’t already exist.
- Links the
customer_idinternally. - Finally, it creates a Checkout session for the subscription and customer_id.
- I created a product with a
-
First Subscription Payment:
- I pay for the subscription using the test Visa card
4242 4242 4242 4242.
- I pay for the subscription using the test Visa card
-
Webhook Event Handling:
- In my webhook, I receive multiple events, including:
if event['type'] == 'customer.subscription.updated': subscription = event['data']['object'] if subscription['status'] == 'active' and (subscription['cancel_at_period_end'] is False or subscription['cancel_at_period_end'] is None): # I update the user profile and take necessary action
-
Subscription is Active:
- The subscription is successfully paid, and its status is "active."
- The current billing period starts on November 4th at 09:40 AM and ends on December 4th at 09:40 AM (1-month subscription).
-
Payment Method Update:
- I go to the customer's payment methods and add a new test Visa card
4000 0000 0000 0341(which is supposed to be rejected after association). - I delete the old test Visa card
4242 4242 4242 4242.
- I go to the customer's payment methods and add a new test Visa card
-
Advancing the Time Clock:
- I use the Advance Time feature and set the time to December 5th at 09:50 AM.
- This triggers several events:
test_helpers.test_clock.advancing,test_helpers.test_clock.ready, followed byinvoice.incomingandinvoice.created(draft). - When I hover over the draft invoice in the Dashboard, I see the message: "This draft invoice was generated by a subscription, but automatic collection was turned off."
-
No Automatic Payment Attempts:
- Even when I advance the time another 20 days past December 4th, the invoice remains a draft and is not finalized, nor do I see any payment attempts being made.
- The only way to trigger a payment attempt is by manually going into the draft invoice and clicking "Charge customer", which then triggers the payment.
My Questions:
- Why is automatic collection turned off for the draft invoice generated by the subscription when I advance the time clock?
- Why doesn’t the draft invoice get finalized, and why are no payment attempts triggered automatically after advancing the time?
- Is this expected behavior, or am I missing a configuration or setting that would enable automatic invoice finalization and payment attempts?
Let me know if you need more information or clarification! Thank you for your help.
that's a lot of text 😓 , let me take a few minutes to go through it
Ok, thanks
sorry for the delay, I'm reading through it now
would you mind sharing the subscription ID?
btw for the webhook endpoint I don't recommend using the customer.subscription.updated event for this
I would rather listen of the invoice.paid event and use that instead
sub_1QHkkwLAK4Wf9wLyEtsI9AoY
In some cases, upgrading or downgrading the subscription also creates a new invoice. We turn off auto_advance for these invoices from the outset.
I did not upgrade or downgrade the existing subscription. Am I missing something?
oh sorry I misread your webhook endpoint code, I though you were changing the subscription
my bad
In # I update the user profile and take necessary action I just set plan_tier to premium for the user profile.
in your case we're just talking about the https://docs.stripe.com/billing/invoices/subscription#subscription-renewal
yes I get that now that I've reread that code snippet
Creates an invoice.
Leaves the invoice in a draft state for about an hour.
Attempts to finalize and pay the invoice with the default payment method.
Changes the invoice status to paid if payment succeeds.
yes
you need to advance the test clock one more hour
or finalize the invoice manually
Yeah I get that, that is why I am asking why with clock advancing, I get no charges attempts nor invoice is getting finalized
I already advanced it to more just one hour
From 7 Dec to 8 Dec
The only events I get is related to clock. No invoice events.
+++ Event received: test_helpers.test_clock.advancing
Unhandled event type test_helpers.test_clock.advancing
INFO: 127.0.0.1:54970 - "POST /stripe/events HTTP/1.1" 200 OK
+++ Event received: test_helpers.test_clock.ready
Unhandled event type test_helpers.test_clock.ready
INFO: 127.0.0.1:54970 - "POST /stripe/events HTTP/1.1" 200 OK
you need to contact https://support.stripe.com/?contact=true your account application has been rejected
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
So that is why it is not triggering auto charges?
yes
Also, I have a new question In some cases, upgrading or downgrading the subscription also creates a new invoice. We turn off auto_advance for these invoices from the outset.
So, if a user is currently on the basic Tier 1 Premium plan and upgrades from the billing customer portal hosted by stripe to Tier 2 Prime (better plan), will auto_advance for invoices and charges be turned off, did I understand that correctly? Well, why would stripe do that? To solve that do I have to capture event and set back to auto_adnvace for that invoice?
no that only happens if the first invoice isn't paid and you downgrade/upgrade