#isxander
1 messages ยท Page 1 of 1 (latest)
Hello! The recommended way would be to listen for webhooks generated by Subscription/Payment.
Yes I understand that, but in this webhook, where or how can I identify which user created this request on my end?
The checkout.session.completed Event will contain Customer information.
There's also Customer information on the Events that contain a Subscription.
just email? So I just need to make sure users know that they need the same email for stripe as my account otherwise it won't go through?
Not sure what you mean by "just email"?
Okay so this is where I'm at now:
I've created a webhook and my server receives this webhook
I create the "embed pricing table on your website" and complete the wizard for that.
Now I get a link to test the checkout, and then on the subscription created hook I get customer details.
The only identifiable detail on my end would be email, to correlate for my user database
Gotcha. Yeah, that makes sense.
so when I send users to stripe checkout, is there a way to also pass a unique id like my user's api key so when they get sent back to me through the webhook I can easily get the correct user
If you have the Customer's email already you can pass it in when you render the Pricing Table: https://stripe.com/docs/payments/checkout/pricing-table#customer-email
You can use the client-reference-id for their unique ID in your system: https://stripe.com/docs/payments/checkout/pricing-table#handle-fulfillment-with-the-stripe-api
And all this API stuff like the routes create-payment-session, that's not needed for this approach, only for integrating payment directly into my website
Not sure what you're referring to?
That has nothing at all to do with the Pricing Table.
That would be something that's completely separate.
yeah that's the completely alternative approach to doing it right?
Yes.
And what's the point of the pricing table? Can't you just add that yourself and direct users to a checkout page?
You mean build your own pricing table and create Checkout Sessions on your server?
oh you'd have to create checkout sessions yourself that way, so the github i sent before?
That's one way to do it, yeah. I'm just trying to clarify what you're asking.
Is there an equivelent for this when creating my own checkout session? Or do I just pass the identifiable id into my callback url?
Sorry I'm just trying to wrap my head around it all.
I'm a first-timer for most of this stuff
Yes, you can set the client_reference_id when creating a Checkout Session via the API: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-client_reference_id
And where can I retrieve this? The webhook subscription.created?
You'll get it back in checkout.session.completed or anytime you retrieve the Checkout Session from the API.
Would you be able to validate the correctness of the create checkout session route I've created?
No, we can't provide code reviews here. The best way to validate your code is to run it in test mode.
I got the checkout session to create in postman, but when I try and view the html response I get. How am I supposed to view the response before the frontend is working?
Can you give me the request ID showing the creation of the Checkout Session? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
oh sorry I was being very dumb and was viewing the redirects contents and not viewing the redirect myself
Think I've actually got the payment flow working now, thanks for persevering with me.
Awesome!
Oh sorry I do have another question, I shouldn't grant subscription stuff to my users in the successful callback, I should use the webhook for that, right? If so, which one?
and:
invoide.paid for renewing the subscription, aka re-provisioning every month
customer.subscription.deleted for cancelling the subscription
would I need any others?
some of these webhooks seem to do the same thing:
customer.subscription.updated says it is called when it's renewed, as well as other things,
and invoice.paid seems to also do this
is there an example project somewhere that demonstrates how to implement this?
We don't have any example projects that I know of for this
For customer.subscriptin.updated vs invoice.paid it really depends on what you're specifially trying to do. An integration that is really sensitive to payment would want to listen for invoice.paid to ensure that payment is actually successful, but the customer.subscription.updated event may have information (like metadata or the renewal date) thatyou need
and I assume I should get my user account through the customer id on both of these webhooks
yup!
and is there any point of using subscription created hook for something basic like this, or just stick with updated
Again, it's really up to you - you shouldn't need it if you're using checkout.session.completed
Sorry more questions. I'm trying to use the stripe cli to imitate an event, but I want it to use a specific customer id that matches into my database, I'm using the override like this:
stripe trigger customer.subscription.created --override invoice:customer=cus_OsH2hwlbgX0iK7
``` but this doesn't work, I'm sure I've misunderstood
No, that's not how overrides work - you need to be looking at the trigger for customer.subscription.created in our stripe-cli github package and seeing which specific param/resource you need to be overriding.
Here's the trigger for customer.subscription.created (https://github.com/stripe/stripe-cli/blob/9b57bd9e86eea272e1c4a9edbfc0997cc01b303d/pkg/fixtures/triggers/customer.subscription.created.json) and you need to be overriding the customer on the Subscription resource at line 43 (https://github.com/stripe/stripe-cli/blob/9b57bd9e86eea272e1c4a9edbfc0997cc01b303d/pkg/fixtures/triggers/customer.subscription.created.json#L43)
You'd do that like this stripe trigger customer.subscription.created --override subscription:customer=cus_OsH2hwlbgX0iK7
Personally, I think it's much easier to trigger subscription events without using the CLI (you can just create the Subscription yourself so you have complete control over the request)
Personally, I think it's much easier to trigger subscription events without using the CLI (you can just create the Subscription yourself so you have complete control over the request)
my api stuff is still completely local, it's not open to the internet for stripe servers to call upon