#isxander

1 messages ยท Page 1 of 1 (latest)

heavy shoalBOT
gentle dawn
#

Hello! The recommended way would be to listen for webhooks generated by Subscription/Payment.

ember hearth
#

Yes I understand that, but in this webhook, where or how can I identify which user created this request on my end?

gentle dawn
#

The checkout.session.completed Event will contain Customer information.

#

There's also Customer information on the Events that contain a Subscription.

ember hearth
#

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?

gentle dawn
#

Not sure what you mean by "just email"?

ember hearth
#

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

gentle dawn
#

Gotcha. Yeah, that makes sense.

ember hearth
#

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

gentle dawn
ember hearth
#

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

gentle dawn
#

Not sure what you're referring to?

gentle dawn
#

That has nothing at all to do with the Pricing Table.

#

That would be something that's completely separate.

ember hearth
#

yeah that's the completely alternative approach to doing it right?

gentle dawn
#

Yes.

ember hearth
#

And what's the point of the pricing table? Can't you just add that yourself and direct users to a checkout page?

gentle dawn
#

You mean build your own pricing table and create Checkout Sessions on your server?

ember hearth
#

oh you'd have to create checkout sessions yourself that way, so the github i sent before?

gentle dawn
#

That's one way to do it, yeah. I'm just trying to clarify what you're asking.

ember hearth
#

Sorry I'm just trying to wrap my head around it all.

#

I'm a first-timer for most of this stuff

gentle dawn
ember hearth
#

And where can I retrieve this? The webhook subscription.created?

gentle dawn
#

You'll get it back in checkout.session.completed or anytime you retrieve the Checkout Session from the API.

ember hearth
#

Would you be able to validate the correctness of the create checkout session route I've created?

gentle dawn
#

No, we can't provide code reviews here. The best way to validate your code is to run it in test mode.

ember hearth
#

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?

heavy shoalBOT
gentle dawn
ember hearth
#

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.

gentle dawn
#

Awesome!

ember hearth
#

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?

vital willow
#

๐Ÿ‘‹ You'll want to use the checkout.session.completed webhook for that

ember hearth
#

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?

vital willow
#

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

ember hearth
#

and I assume I should get my user account through the customer id on both of these webhooks

vital willow
#

yup!

ember hearth
#

and is there any point of using subscription created hook for something basic like this, or just stick with updated

vital willow
#

Again, it's really up to you - you shouldn't need it if you're using checkout.session.completed

ember hearth
#

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
vital willow
#

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)

ember hearth
#

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

vital willow
#

That's different though (I assume you're referring to your webhook still being local) - you can still call stripe's API yourself instead of doing the triggers and then using stripe listen to test your local webhook

#

Using stripe listen doesn't require you to use stripe trigger