#spinningCat
1 messages · Page 1 of 1 (latest)
👋 @dense path How can we help?
there is some syntax typo here my code is like that
if(event_type === "payment_intent_created"){
const paymentIntent = event.data.object;
console.log('[${event.id] payment intent created ($[paymentIntent.id]): ($[paymentIntent.status)')
}
there will print output to terminal yes?
can i send thos output to browser's console?
hope my question is clear
Webhook should be hosted in your backend server not browser. If you put a log, it'll likely will be on your server.
In addition, there's no such payment_intent_created event type. It will be payment_intent.created
There should be log output on your backend log if payment_intent.created is checked
I ınderstand
okay so i should insert the result of webhook into sql table
this is the best i can do i guess
it is so clear to me
Yup! Webhook is independent from your frontend/browser. You could save the information in your database and retrieve it for your frontend later.
This will be up to your business decision on how you would like to share the information to your frontend
SURE
Out of curiosity, when you create a payment intent via API, why don't you just return the information in the response to your frontend? Is there any specific use case that you have to use Webhook instead?
actually it is first time i do something like that
i am newbie here i just try to understand the stuff
I see! I'd recommend following the guide for collecting payment here: https://stripe.com/docs/payments/quickstart
payment_intent.created event is generally not required as you will be able to get the same information in the response when you create a Payment Intent via API.
As mentioned in the above doc, payment_intent.succeeded, payment_intent.payment_failed and payment_intent.processing events are the events to listen to determine the payment process and results.
I see
i actually write all codes now and it worked
const { clientSecret } = await fetch("/create-payment-intent", {
method : "POST",
headers: {
"Content-Type" :"application/json"
},
body: JSON.stringify({
"currency": "eur",
"amount": "1000",
"payment_method" : "card"
})
}).then(r => r.json())
it is called documentloaded event but parameter will send from external sources
so probably they should send me clientsecret
Yup! /create-payment-intent endpoint should return the client_secret and it's not necessary to use payment_intent.created event to retrieve it.