#erztemplerobba_webhooks

1 messages · Page 1 of 1 (latest)

tall joltBOT
#

👋 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. Thank you for your patience!

⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.

🔗 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/1214846923039576084

📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.

strange orchidBOT
#

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.

plain flume
#

I'm using this to handle cancellations via the stripe portal:

    case 'customer.subscription.updated':
      const subscriptionSession = event.data.object

      if (
        subscriptionSession.cancel_at_period_end === true
        && subscriptionSession.cancel_at
      ) {
      ... CANCELLATION LOGIC

I'm not sure what exactly I'm supposed to check within the event.data.object to identify my renewal via portal.

meager sail
plain flume
#

Do you mean this:

canceled The subscription has been canceled. During cancellation, automatic collection for all unpaid invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.
?

   case 'customer.subscription.updated':
      const subscriptionSession = event.data.object

      if (
        subscriptionSession.auto_advance === false
      ) {
      ... CANCELLATION LOGIC

Honestly, I've read the link you posted before but I cannot extract any info about the renewal out of it. Would you mind pointing me in the right direction?

meager sail
#

So basically you can just check the susbcription's status to tell if it's cancelled

plain flume
#

This wouldn't give me information about a renewal update event, right?

Maybe I phrased it the wrong way (and mixed it up with the cancellation because it's related). This is the action flow:

  1. The user goes to the stripe portal
    -> 2024-03-06 17:03:53 --> billing_portal.session.created [ID]

  2. The user presses renew button
    -> 2024-03-06 17:04:05 --> customer.subscription.updated [ID]

This customer.subscription.updated [] is the only event that gets triggered. Now, since this event is triggered in multiplte different cases, I want to identify only the renewal. As far as I know, the subscription's status wouldn't help me here. The status is active, but this is the case for many different customer.subscription.updated [] events.

In plain english, I want to check this:

 case 'customer.subscription.updated':
      const subscriptionSession = event.data.object

      if (EVENT IS A RENEWAL EVENT) {
        RENEWAL LOGIC
      }

if (EVENT IS A RENEWAL EVENT) this is what I'm interested in since I can't find any renewal-related property in the event object.

meager sail
plain flume
#

The invoice.paid event is only triggered when the subscription reaches its end date. This is not the case here.

In my case, only the 2024-03-06 17:04:05 --> customer.subscription.updated [ID] event is triggered. Imagine this case:

  1. Customer subscribes successfully for a 1 year billing cycle.
  2. He then cancels the subscription 1 day after subscribing
  3. One week later, he decides to renew his plan. Here, no invoice.paid event is triggered because he already paid for the full year subscription. But I want to catch exactly this renewal event.
meager sail
#

Can you share with me the ID of the request where your customer " renew his plan." ?

plain flume
#

customer.subscription.updated [evt_1OrGEdItN31KXN7TPBhI7r0x]

#

This event triggers when I presst his button

meager sail
#

OK, this subscription wasn't cancelled (Its status is alwasy active). What happenend here is that when your customer "Cancel" it through Billing portal, the billing portal set its cancel_at_period_end to true, which means that the subscription is scheduled to be cancelled at the end of the billing cycle.

#

However, when you customer "renew" it through portal again, cancel_at_period_end is then set to false.

strange orchidBOT
meager sail
#

So technically the subscription is always in active status, it's never cancelled

plain flume
#

Ah, I see. So checking for cancel_at_period_end === true and cancel_at_period_end === false would basically determine if the subscription is cancelled or renewed.

Since you're saying that this subscription wasn't cancelled. I wondered about his because the cancellation in the portal seems to work correctly but the status never changes.

This is the request ID for the cancellation:
customer.subscription.updated [evt_1OrGNbItN31KXN7TiSKw2TZt]

#

In my stripe dashboard, it appears to be cancelled correctly but the event.object has:

  start_date: 1709707532,
  status: 'active',
  tax_percent: null,
```j
nimble temple
#

it's not cancelled, it will cancel on Mar 13; that's what this cancel_at_period_end means.

plain flume
#

Ah yeah, that makes sense.

nimble temple
#

it's 'marked for cancellation' or however you might like to think about it

plain flume
#

I see, then I'll use cancel_at_period_end to trigger my logic for cancellations and renewals