#theguy99
1 messages · Page 1 of 1 (latest)
can you share with me the request_log_url ?
yuh
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
You passed the wrong Checkout Session ID.
func HandleWebhook(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
fmt.Println(err)
return
}
stripe.Key = utils.StripeKey
event, err := webhook.ConstructEvent(body, r.Header.Get("Stripe-Signature"), utils.StripeWebhookSecret)
if err != nil {
fmt.Println(err)
return
}
s, err := session.Get(event.ID, nil)
if err != nil {
fmt.Println(err)
return
}
switch event.Type {
case "payment_intent.succeeded":
//run this
}
}```
would it be event.ID thats wrong?
No, it's not the event ID.
And since you are listening to payment-intent.succeed, you'll get a payment_intent object, not a checkout session object, from this event.
https://stripe.com/docs/api/payment_intents/retrieve#retrieve_payment_intent you should retrieve a paymentIntent instead.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ohhh ok
how would the proper way to get metadata be should it be s.Metadata["id"] ?
Which resource did you set the metadat to? paymentIntent?
paymentLink
OK
So you'll like to listen to checout.session.completed event, and retrieve the paymentLink object (https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-payment_link) from the checkout session.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
From there you can get the metadata that you set on the paymentLink.