#B33fb0n3-Checkout
1 messages ยท Page 1 of 1 (latest)
hii @chrome vector ๐
I'm not really following what you're trying to achieve, could you please explain your use case?
sure. Give me a second, I gonna paint it ๐
the webhook signature are not specific to an event
the signature is related to the Webhook Endpoint you create on the dashboard
if I send this from my backend, I wont have this: const sig = request.headers['stripe-signature'];
(https://stripe.com/docs/webhooks/signatures)
what are you using as a programming language?
node js in backend and react in frontend
could you please share your webhook code?
from my backend?
could you please take a look at this guide
https://stripe.com/docs/webhooks/signatures#verify-official-libraries ?
you're missing the bodyParser.raw({type: 'application/json'}),
I do here: ```
var app = express()
app.use(bodyParser.json({
verify: function (req, res, buf) {
req.rawBody = buf.toString()
}
}))
app.use(awsServerlessExpressMiddleware.eventContext())
you're using the json bodyParser and not the raw bodyParser
you need to specifically use the raw body parser as described in the guide I sent u
where is the problem? If I just use the black way, everything would work fine.
my problem is currently the missing webhook signature, when I dont use a webhook. ๐
do you have a checkout session id I could look at?
sure. Can I send u the event?
thats an session id: cs_test_b1QAiNXcVCyfovx6P9Bmh2QdmaFyEhX1mcARzi9erRAxOzKCktuHGmYocl
I'll take a look
ok, thank u ๐
sorry it took me a while to reply
no problem
my problem is currently the missing webhook signature, when I dont use a webhook
what do you mean by when I don't use a webhook?
are you using this endpoint for something other than receiving events from Stripe?
when a session is created, there is no event for the creation. So I cant use a webhook
yes
you shouldn't be
it's a rest api
oh u mean the endpoint /webhook?
yes
are you sending a POST request to that endpoint to tell it that you have created a Checkout Session?
I would, yes.
that's what I meant by you shouldn't be using that endpoint other than for the events you receive from Stripe
you can't send a POST request to your /webhook endpoint with a signature
./webhook just handle stripe events
yeah, I cant. Because I have no signature
โ๏ธ there is the problem ๐
so why are you POSTing to it then?
if it's for testing you can use stripe-cli for that
Because I have no signature
โ๏ธ
e.g. run stripe trigger checkout.session.completed to generate an event to send to the endpoint.
that's circular reasoning though
first testing and after that publish it.
cool, so what's the problem really?
this event does not exists: checkout.session.completed
ah wait
it exsits
I use it. But I searching for the event, when I create a session
there's no such thing
to update my backend securely
you don't need an event for htat, since you create the Session synchronously by calling the API
there u can see my problem ๐
so you know it exists and can update whatever you need at that point
I can and I do.
ok, but there isn't one
but not securely.
I have
you have code on that server to call the CheckoutSession create API
yes (public access)
after calling that, you can update your database or whatever to say "I have created a CheckoutSession for customer X and I expect to see a checkout.session.completed event later", right?
yes, I can. BUT: than its public and have no secure. So every person can create for example hundreds of session and can manipulate my backend.
how would the event help? it's just adding a step.
Like, every person creates hundreds of sessions. You get hundreds of hypothetical "checkout.sesssion.created" events, and your backend is manipulated. How would that be any different?
hm, u r right... ๐ค
so I have one last question: why do we check the signature from stripe webhooks?
I think u want, that I read this part: https://stripe.com/docs/payments/checkout/fulfill-orders#verifizieren-sie,-dass-die-ereignisse-von-stripe-stammen
why dont we check this also by checkout creation?
because you don't need to. Creating a session is a synchronous API call, you get the API response immediately, you know it came from Stripe since that's where you sent the HTTP request.
The webhook is the async notification later that the customer has finished paying, and since that is just an incoming HTTP request we make to your server, so you might want to verify its origin.
ohhh got it ๐คฆโโ๏ธ