#aliihsan01100_code

1 messages ยท Page 1 of 1 (latest)

obtuse emberBOT
#

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

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

late parrot
rare reef
#

req_kDGM9prPUB1NmX

#

Users can create multiple invoices

#

and If one suceed, the status of their subscription became true

#

but other ones after 24h when they expire they send also a customer.subscription.updated to my webhooks

#

which deactivate the user's subscription

#

The solution I found was to just ignore incomplete and incomplete_expired

#

But I want to know If this is something I should avoid doing or if it is okay doing that

#

Thank you very much and sorry if this sounds like a stupid question, dev is not my main domain but I am trying to learn

late parrot
#

How are the invoices being generated?

rare reef
#

This is a test I have done

#

The first one are open

#

I thought about user payment_behavior: error if incomplete

#

so that there are no open invoices

#

but the documentation says that default_incomplete is recommended

#

and in France all the banks uses 3dsecure so I thought this was not the best idea to set payment_behavior: error

late parrot
#

Do you have any examples of invoice IDs? e.g. in_123

rare reef
#

in_1SPjrYP4CL0PMszKfdzQzdou

#

in_1SPJqIP4CL0PMszKEF9xhka4

#

is the good practices to just detect if an open invoice is already existing and redirecting user to the open invoice instead of a new checkout session ?

obtuse emberBOT
chilly flint
#

hey ther,e stepping in for my colleageu who needed to step away. Give me a little bit to review here.

rare reef
#

I have added the invoice detection, so that instead of creating a new checkout session each time, the user is redirected to the open invoice. But the problem with this is that the user cannot use a discount code. So I don't know what should I do ? 1. Create a new checkout session each time and ignore incomplete and incomplete_expired in my webhooks ? 2. redirect the user to the existing invoice but they cannot use a coupon code 3. maybe create a new checkout session each time but delete the old invoices (Is this possible ?)

chilly flint
# rare reef req_kDGM9prPUB1NmX

So this request example is from a checkout session, which should handle the subscription creation flow for you. Is this how you create all subscriptions, or do you have examples you're creating yourself directly?

rare reef
#

Yes it is how I create all my subscriptions. On my app, the users click on subscribe, a new checkout session is created each time, and my app then listens to the webhooks.

#

But my problem is that if a user try to subribe but his card is declined

#

then he go back to my app

#

and click again on subscribe, a new checkout session is created

#

and the last invoice is kept open

#

thus, the first invoice sends customer.subscription.updated with status incomplete_expired 24h later which deactivate the user subscription status in my app

#

My question was about what is the best good practice i should implement to prevent this

#

and 3 solutions came to my mind: 1. ignore incomplete and incomplete_expired in my webhooks (even though multiple invoices can be opened) 2. check for open invoice and redirect to the open invoice instead of new checkout (but the user cannot use a discount code if he is redirected to an open invoice) 3. check for open invoice, delete the open invoice and create a new checkout session

chilly flint
#

Ok i see, thanks for explaining more

#

So in this case, the checkout session was never completed and what i think you want is to send the customer back to the existing checkout session url if it is not expired

#

Then they can retry completing payment there, on the same existing subscription before it goes incomplete_expired

#

If the session/subscription expire before they come back to try paying again, then you have no choice but to create a new session to create a new subscription for them to try again

rare reef
#

redirecting to an exiting invoice and redirecting to an existing checkout is not the same thing then ?

chilly flint
#
  1. ignore incomplete and incomplete_expired in my webhooks (even though multiple invoices can be opened)
    this is up to you, really. It's mostly a temporary/transient state for this subset of customers with failing payments and yea you can ignore those subs if thats easier, just create new sessions.
rare reef
#

oh okay I get it now

#

Thanks a lot!

chilly flint
chilly flint
#

Give that a shot if you want to tidy these temporary subs and reduce the duplicates, but its not harmful to have those and its part of why they get auto-expired if payment is not completed

rare reef
#

You made it very clear for me!

chilly flint
#

NP! Good luck with your work ๐Ÿ™‚