#_lionelp

1 messages ยท Page 1 of 1 (latest)

cold mangoBOT
fervent panther
#

Hi! Let me help you with this.

#

Could you please share the Event ID?

#

evt_xxx

bitter veldt
#

Hi, here it is evt_1NsiBhFvrVE1j92W8eCoM6aI

#

I launched via the command line this stripe trigger customer.subscription.created.

fervent panther
#

The 2 events were created at exactly the same time 2023-09-21 08:24:41, so it's normal that they might have arrived to your webhook in another order.

#

I would advise not to rely on webhook notification order in your business logic. In the end, these 2 events were created as a result of the same API request.

bitter veldt
#

I would advise not to rely on webhook notification order in your business logic
I guessed that with the weird order... but what is the best solution then?
Create a useless temporary table that stores the payment method, wait for the customer creation and then retrieve the data and remove the temporary table or ... what?

fervent panther
#

It depends on what your business logic needs to do, it's hard for me to advice without context.
You might not need to listen to webhooks at all, as all the information is already available in the API response.

bitter veldt
#

Not sure of what to say. I believe I need to handle those events

#

I have two offers/products that are annual subscriptions.

#

So I created this database

#

As I believed all worked via webhooks, I created all those services to process each one.

fervent panther
#

It seems like you're trying to replicate Stripe in your app, which is completely unnecessary.

#

Are you trying to sync all the Stripe objects with your database? For what?

bitter veldt
#

I do not know much about Stripe so maybe I go completely in the wrong direction ๐Ÿ˜‚ ๐Ÿคฏ

fervent panther
#

Yes. What are you trying to do exactly?

bitter veldt
#

In fact, at first, I just wanted to know if a user has bought a subscription, so I have to send him a mail with the license key.
I have to update the expiration date of the license key or remove it.
I wanted to think at all the possibles things that I need. But it seems that Stripe does a lot of those things but I do not know well what Stripe does and does not.

#

Stripe is a big thing and it takes time to read all the documentation but I'm on it

fervent panther
#

You'll probably just need to listen to customer.subscription.created event to mark the start of a subscription, and then check for invoice.paid/invoice.payment_failed (please note that retries are possible) to make sure each new month is paid for.

bitter veldt
#

I already created a page with two buttons that are tied with Stripe Checkout and redirects correctly to my success page or cancel page.

#

So I just ignore payment methods etc. Initially, I wanted to check the event of the payment methods in order to know if a user has add payment method but did not have done anything then...to ask him why for example.

#

or if there are too many weird changes to check if there is a security issue or something

fervent panther
#

It seems like a bit of an overkill for this stage.

#

Please start with making sure you can track the license management in your app using webhooks, and then add more things.

bitter veldt
#

maybe but I do not want to restructure my database afterwards. If I can create a solid foundation to avoid losing time in the long run ...

#

If I do not handle this now, I will probably have fix my database in the future and that can be some pain ๐Ÿค”

#

Trying to filling the gaps and "relinking" the things no?

fervent panther
#

I would suggest you first explore what Stripe is capable of, before you start designing your solution is such detail.

bitter veldt
#

Also, when I trigger things via Stripe CLI does not include email for the user, how can I test mails if I do not have emails with the event customer.created ?

fervent panther
#

We don't send emails in Test mode, if that's what you're asking.

bitter veldt
#

I do not want to make Stripe send mails but I want that my site send mails

#

So I can only test my mails in production mode ? ๐Ÿ˜…

fervent panther
#

Sorry for misunderstanding. What things are you trying to test exactly?

bitter veldt
#

No problem, thanks for your time ๐Ÿ™‚ I want to send a mail if the transaction has succeeded to send a license key to my user.
But there is no way to get mail in test mode, I will just try to see which field is present in production mode and maybe add it myself in development mode to send my mail

#

And use the real data when I am in production mode

fervent panther
#

I would suggest you create a full new Subscription with a Stripe Checkout for example in Test mode.

#

And don't focus to much on Stripe CLI for testing.

bitter veldt
#

Which way do you test if not using Stripe CLI ? ๐Ÿ™‚ You just use Postman or equivalent solutions?

fervent panther
#

This way you can provide all the parameters you need to test a real-life scenario.

bitter veldt
#

Ok, I will read all that and I will wish you a good day ๐Ÿ™‚

fervent panther
#

Happy to help!