#idyoks_api

1 messages · Page 1 of 1 (latest)

tough sealBOT
#

👋 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.

safe warren
#

👋 happy to help

#

would you mind elaborating a bit more?

sage helm
#

Did my message get truncated, or is it just on my end?

safe warren
#

it might have been

sage helm
#

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:

  1. 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_id internally.
      • Finally, it creates a Checkout session for the subscription and customer_id.
  2. First Subscription Payment:

    • I pay for the subscription using the test Visa card 4242 4242 4242 4242.
  3. 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
    
#
  1. 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).
  2. 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.
  3. 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 by invoice.incoming and invoice.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."
  4. 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:

  1. Why is automatic collection turned off for the draft invoice generated by the subscription when I advance the time clock?
  2. Why doesn’t the draft invoice get finalized, and why are no payment attempts triggered automatically after advancing the time?
  3. 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.

safe warren
#

that's a lot of text 😓 , let me take a few minutes to go through it

sage helm
#

Ok, thanks

safe warren
#

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

sage helm
#

sub_1QHkkwLAK4Wf9wLyEtsI9AoY

sage helm
#

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?

safe warren
#

oh sorry I misread your webhook endpoint code, I though you were changing the subscription

#

my bad

sage helm
#

In # I update the user profile and take necessary action I just set plan_tier to premium for the user profile.

safe warren
safe warren
sage helm
#

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.

safe warren
#

yes

#

you need to advance the test clock one more hour

#

or finalize the invoice manually

sage helm
#

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

safe warren
#

just try to advance one more time

#

there might some seconds/minutes differences

sage helm
#

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



safe warren
#

you need to contact https://support.stripe.com/?contact=true your account application has been rejected

sage helm
#

So that is why it is not triggering auto charges?

safe warren
#

yes

sage helm
#

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?

safe warren
#

no that only happens if the first invoice isn't paid and you downgrade/upgrade