#sheisty6_webhooks

1 messages ¡ Page 1 of 1 (latest)

brisk cragBOT
#

👋 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/1225440414946033686

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

jade elkBOT
timid sapphire
#

Hello

light meadow
#

Hi!

timid sapphire
#

So your goal here is to clean up Customers that attempt to start a Subscription through Stripe Checkout but the initial payment fails?

light meadow
#

Ideally, I would keep the customer existing, but I would not that their subscription is past due in my internal storage so that I can direct them to update their payment on my site.

#

But I can't update my internal storage without associating the customer with my internal id

timid sapphire
#

Hmm in this case though the Subscription won't be past_due

#

It will be incomplete

#

In which case there is only a 23 hour window for it to move to active otherwise it moves to incomplete_expired

#

But if you want to track this then you can listen for the customer.subscription.updated Webhook for when a Subscription's status is incomplete

#

Ah actually sorry that Webhook wouldn't fire

#

It would only be customer.subscription.created

#

As that is the initial status here

#

That Webhook would contain the Customer ID that you are looking for

light meadow
#

For any webhook, though, I update my internal state by looking up my internal customer object via the stripe_customer_id. However, without checkout.session.completed, I cannot tie my internal id to the created stripe customer id

#

session_params = {
"line_items": [
{
"price": price_id,
"quantity": 1,
}
],
"mode": "subscription",
"success_url": "https://doinksports.com?subscribed=true",
"cancel_url": "https://doinksports.com?canceled=true",
"automatic_tax": {"enabled": True},
"phone_number_collection": {"enabled": True},
"metadata": {"user_id": request.user["uid"]},
}

^^ my checkout session params. I use this metadata field

timid sapphire
#

Your other option in that case is to create the Customer ID before redirecting to Checkout

#

And then pass that Customer ID to the customer parameter for the Checkout Session

#

Then you have the Customer ID up front and can store it in your database

light meadow
#

Ohh ok. Makes sense. Thank you!