#ahjaydog-webhook-paused-payments

1 messages · Page 1 of 1 (latest)

solid goblet
#

Hi there! What do you mean by paused payments, exactly?

#

Like when your account is disabled?

scenic prairie
#

pause payment collection under subscriptions

solid goblet
#

Thanks

scenic prairie
#

there are trials too where in the past they were used for pauses

solid goblet
#

Yes customer.subscription.updated is what you want.

scenic prairie
#

ok and then what do i look for to indicate pause?

#

This event works for both trials and pauses?

solid goblet
scenic prairie
solid goblet
#

Sure, that will set all Subs to be paused.

scenic prairie
#

ok so when i pause i look for if the hash is not none. Then when the pause hash is none then reactivate membership for example?

solid goblet
#

Yep, and you may want to check the status as well when it unpauses if you only want to provision when the Sub has a certain status

#

But that part is up to you.

#

Once pause_collection is null, then you will know it is unpaused.

scenic prairie
#

what status do you recommend?

solid goblet
#

Depends... most folks use active but you can also still provision when the Sub is past_due if you still expect future payment for the unpaid invoice depending on your product.

#

That part is really up to you

scenic prairie
#

ok

#

another webhook event i am looking for is when i make a subscription for the first time would it be customer.subscription.created ?

solid goblet
scenic prairie
#

ok thanks

#

if i have missing ids or something do you recommend using try except statements or something else?

solid goblet
scenic prairie
#

thanks

#

is there a way to test disputes with ACH/

#

I also noticed a lot of the docs now for python use json / jsonify why is that?

solid goblet
#

The debitNotAuthorized account number is for testing disputes

#

I'm not a python dev so I can't really speak to exactly why that method is recommended.

scenic prairie
#

ok no worries about the python thing

#

thank you i'll try that for the ach

#

what were to happen if lets say i pause everybody and i have a webhook for that, would that be problematic if everybody gets paused at the same time?

#

If i were to change my database during 'checkout.session.completed to a paid membership would there be a conflict if i do the same thing of customer.subscription.created? They are 2 separate events even though they both make a subscription?

sharp stratus
#

If i were to change my database during 'checkout.session.completed to a paid membership would there be a conflict if i do the same thing of customer.subscription.created?
When you say "do the same thing" do you mean also update the database on the customer.subscription.created? If so, what's the point? What are you updating?

scenic prairie
#

when completing the checkout, behind the scenes a subscription gets created

#

but if i make another separate customer.subscription.created event, will they conflict?

#

I am updating my database for when someone pays via checkout or if someone on stripe manually adds a subscription, then also update my db

sharp stratus
#

The events you mentioned are entirely separate from each other. No matter where the subscription is created (e.g. Checkout or elsewhere), it will send the customer.subscription.created event. What specifically are you updating in the DB?

scenic prairie
#

if the customer is paid or free

sharp stratus
#

If both events are referencing the same Subscription and Customer, then you shouldn't need to worry about one overwriting the other, because they should both reference the same objects (unless you change something on them between events)

scenic prairie
#

ok i'll give it a try and see what happens

scenic prairie
#

"pause_collection": {
"behavior": "keep_as_draft",
"resumes_at": null
},

#

That is what happens when i pause a subscription. What exactly do I use here in my if statement?

#

event.data.object.pause_collection.behavior == keep_as_draft ?

#

event.data.object.pause_collection != None ?

#

This is for the event.type == 'customer.subscription.updated':

#

nevermind i see it is null/None

#

if i unpause

sharp stratus
#

Alright. Is there an outstanding question here? Or did you unblock yourself?

scenic prairie
#

no i should be ok now sorry

sharp stratus
#

It's all good! I just want to make sure that I'm not overlooking anything and that you're set 😄

scenic prairie
#

"latest_invoice": "in_1LDXIQIeTJrsS1reCATgv4hf" from the subscription.updated event... is that referring to what may have already been paid?

#

API says The most recent invoice this subscription has generated.

#

so the one at the top of the invoices section of the customer page

sharp stratus
#

It will be the most recent Invoice that was created. It might be paid, or unpaid.

scenic prairie
#

ok thanks

#

i think bismark may have given the wrong info before?

#

whenever i pause i see pause_collection has data and whenever i unpause i see pause_collection None

#

oh wait sorry

#

i keep talking to myself today he was right he said not none

scenic prairie
#

How come event.data.object.items.data[0].price.id is not working on customer.subscription.updated

#

AttributeError: 'builtin_function_or_method' object has no attribute 'data'

scenic prairie
grand summit
#

That is actually a quirk of Python itself

#

Can you try the same thing but use event.data.object['items'].data[0].price.id instead?

#

Essentially python is mixing up the items field with the items() function of the object. I know the one workaround of what I just sent, I forget if there is another way to specify what you are looking for here

scenic prairie
#

ooh man that makes a lot of sense let me try

#

yes that worked thank you

grand summit
#

Great to hear!