#_lionelp
1 messages ยท Page 1 of 1 (latest)
Hi, here it is evt_1NsiBhFvrVE1j92W8eCoM6aI
I launched via the command line this stripe trigger customer.subscription.created.
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.
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?
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.
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.
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?
I do not know much about Stripe so maybe I go completely in the wrong direction ๐ ๐คฏ
Yes. What are you trying to do exactly?
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
Stripe indeed does a lot. I would suggest you to start with a basic Subscription integration and then see how you integrate your business logic into this: https://stripe.com/docs/billing/subscriptions/build-subscriptions
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.
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
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.
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?
In any case, you don't need to replicate all the Stripe objects in your database, as it's not providing any benefits and is also error-prone.
I would suggest you first explore what Stripe is capable of, before you start designing your solution is such detail.
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 ?
We don't send emails in Test mode, if that's what you're asking.
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 ? ๐
Sorry for misunderstanding. What things are you trying to test exactly?
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
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.
Which way do you test if not using Stripe CLI ? ๐ You just use Postman or equivalent solutions?
I meant, don't rely on stripe trigger
You can build a simple integration to create Checkout Sessions/use Postman/use stripe checkout sessions create ...: https://stripe.com/docs/api/checkout/sessions/create?lang=cli
This way you can provide all the parameters you need to test a real-life scenario.
Ok, I will read all that and I will wish you a good day ๐
Happy to help!