#joel_best-practices
1 messages ยท Page 1 of 1 (latest)
๐ 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/1214187043014311976
๐ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
Hi thanks for replying! Im using stripe webhooks
elif event_type == 'customer.subscription.created':
print('Subscription created %s', event.id)
mongo.insiderdata.users.update_one(
{'stripe_customer_id': data_object.customer},
{'$set': {
'stripe_subscription_status': data_object.status,
'subscription_plan': {
'plan_id': data_object.plan.id,
'plan_name': data_object.plan.nickname,
'amount': data_object.plan.amount,
'currency': data_object.plan.currency,
},
'subscription_dates': {
'start_date': data_object.start_date,
'end_date': data_object.current_period_end,
},
'has_trial': data_object.trial_end,
'cancel_at_period_end': data_object.cancel_at_period_end,
}}
)
After stripe.checkout.Session.create
Are you creating Subscriptions via Stripe Checkout?
Thats right:
checkout_session = stripe.checkout.Session.create(
line_items=[
{
'price': price_id,
'quantity': 1,
},
],
mode='subscription',
allow_promotion_codes=True,
customer=stripe_customer_id,
customer_email=email,
metadata={
'user_id': user['_id'],
},
subscription_data={
"trial_period_days": trial_days,
},
success_url=url_for('index.konto', _external=True) + '?session_id={CHECKOUT_SESSION_ID}',
cancel_url=url_for('index.konto', _external=True),
)
Then a Subscription shouldn't really ever be in an incomplete state. Could you please share the Subscription ID sub_xxx?
I think it was this one
sub_1OqaguA20NWHSZe8JflFUgqB
Yeah looks like the payment declined on-session via Checkout, which can leave the subscription in this state. You need to bring the customer back on-session and re-confirm the intent
I think they can pay the invoice via the portal, which will active the subscription
Alright so if the status is incomplete they should get access to the customer portal, but not the extra features yet? The incomplete state can only be changed to active by manually checking out again? Stripe wont try again?
What do you mean by 'extra features'? You can create a portal session for any Customer object
The incomplete state can only be changed to active by manually checking out again? Stripe wont try again?
No we won't automatically retry the initial payment
Ah okay got you! Thanks you so much for the help ๐
Another question. Did i read somewhere that stripe retries to charge for the subscription x times if payments fail?
and will automatically send a 'customer.subscription.deleted' webhook if those x tries fail?
That is true yes for recurring (non-initial) payments: https://docs.stripe.com/billing/revenue-recovery/smart-retries
Yes, if you have it configured to cancel after the failures