#caze_api

1 messages ยท Page 1 of 1 (latest)

echo sierraBOT
#

๐Ÿ‘‹ 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/1262440003464724564

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

granite zincBOT
#

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.

plush lichen
#

These are the events my webhook is listening to:

lone flint
#

Hi ๐Ÿ‘‹

What have you tested out?

plush lichen
#

Nothing was triggered on my tests. I bought a plan, and then went on the dashboard and refunded it to the client, but no event triggered

#

IDK if I did that correctly, just a genuine question to what to do in these cases

lone flint
plush lichen
#

Okay, just a moment

#

/v1/charges/ch_3PYeZ0IcGGZP425o2z2TINNS/refund

#

req_rVRGtByoFBYLQf

lone flint
#

Thanks. Taking a look now

plush lichen
#

Oh thats perfect!

#

Thanks a lot

#

But in cases where I pause the subscription from the dashboard theres no webhook event generated, right?

lone flint
plush lichen
#

Oh thats even nice

#

I've tried this event before when pausing a subscription via client side, where the user was pausing it manually, not the owner of the dashboard. pausing the payment collection, but this does not trigger a webhook event

lone flint
#

Sorry I'm not sure what you mean by that. I would need more requests to identify what you are referring to

plush lichen
#

I talked with another support member last week

#

So in cases where I call your api directly to pause it, it does not trigger an webhook, but if I pause it manually (via dashboard) it does trigger

#

I just paused from the dashboard, can you check if any event was triggered?

req_QMZkhlJLRMGniB

POST /v1/subscriptions/sub_1PVQkCIcGGZP425oxIjHO9Ww

lone flint
plush lichen
#

const subscription = await stripe.subscriptions.update(subscriptionId, {
pause_collection: {
behavior: 'mark_uncollectible',
},
});

in this case, no event is triggered

lone flint
#

Can you find that request in your dashboard? I'd like to take a look

plush lichen
#

one second

#

Just paused via api

POST /v1/subscriptions/sub_1PVQkCIcGGZP425oxIjHO9Ww

req_76b14ax5q8K8sM

lone flint
#

Thanks, looking

plush lichen
#

Okay, thanks a lot

#

I'll try that in my webhook

#

what element in each event, charge.refunded and customer.subscription.paused make me know if it was a success or not? I think the charfe.refunded is always after a successfull refund so I shouldn't mind. but in customer.subscription.paused, if I reactivate it, do it call the same event?

lone flint
#

For all the changes to the subscription, the event that was fired was customer.subscription.updated

#

For any .updated event, the property you want to pay special attention to is the previous_attributes. This will tell you want fields changed and what the old values were. You can compare these against what the values currently are to understand how things changed

#

For that last event, we had

previous_attributes: {
    pause_collection: null
  }

and in the Subscription object we can see the current value of pause_collection is

pause_collection: {
      behavior: "mark_uncollectible",
      resumes_at: null
    },
plush lichen
#

Thanks!

#

Do you know why my webhook is not receiving these events?

we_1PT6MPIcGGZP425oXvZtiQ8X

#

Just unpaused one subscription and it wasn't called

echo sierraBOT
lone flint
#

You are listening for the wrong event

#

Please add this event: customer.subscription.updated

plush lichen
#

no way๐Ÿคก

#

Sorry

#

So if I want to only check the event customer.subscription.updated in cases where the subscription is paused/unpaused I should only check if the "previous_attributes" includes pause_collection?

#

If it does not I cann call an res.status(304 or 200) for example

lone flint
#
  1. You should always respond with a 200 to webhook request.
  2. You can check what the current and previous values are for pause_collection to understand what happened
plush lichen
#
  1. Ok, thanks!

  2. But I think more events from customer.subscription.updated are going to trigger my webhook, but I only want to check the ones related to pausing/unpausing subscriptions, so in theses cases the previous_attributes will always have the pause_collection prop, right? so if it does not contain this prop, I can return an 200 right after

lone flint
#

Correct.

#

You can use the presence of pause_collection in the previous attributes to indicate it's a pause/unpause event

plush lichen
#

Nice

#

You helped me a lot

#

A LOT

#

I think i got what I need

lone flint
#

I'm happy to shed what ๐Ÿ’ก I can ๐Ÿ™‚

plush lichen
#

If I got any further issues, I contact you guys again