#ByteFox
1 messages · Page 1 of 1 (latest)
Error verifying webhook signature: webhook had no valid signature
And you say it works on local?
yes
Do you have any proxies in front of your server on production that might change the headers/body?
no
its just a unbuntu sever vanila from hetnzer
i used the exmple from from https://dashboard.stripe.com/test/webhooks/create?endpoint_location=hosted
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Could you please share the relevant code?
sure how do i use mark down
func WebhookTest(c echo.Context) error {
fmt.Println("webhook request made")
payload, _ := ioutil.ReadAll(c.Request().Body)
// This is your Stripe CLI webhook secret for testing your endpoint locally.
myString := string(payload[:])
// Pass the request body and Stripe-Signature header to ConstructEvent, along
// with the webhook signing key.
fmt.Println(myString)
endpointSecret := "secrte"
// Pass the request body and Stripe-Signature header to ConstructEvent, along
// with the webhook signing key.
event, err := webhook.ConstructEvent(payload, c.Request().Header.Get("Stripe-Signature"), endpointSecret)
if err != nil {
fmt.Fprintf(os.Stderr, "Error verifying webhook signature: %v\n", err)
return nil
}
switch event.Type {
case "checkout.session.completed":
fmt.Println("checkout.session.completed")
case "mandate.updated":
fmt.Println("mandate.updated")
case "payment_intent.created":
fmt.Println("payment_intent.created")
case "payment_intent.succeeded":
fmt.Println("payment_intent.succeeded")
case "charge.succeeded":
// `&myStoredVariable` is the address of the variable we want to store our
// parsed data in
var paymentStruct payemntSessoionStrut
json.Unmarshal(payload[:], &paymentStruct)
//paymentStruct.Object.PaymentStatus
fmt.Println("cus " + paymentStruct.Data.Object.BillingDetails.Email)
fmt.Println(paymentStruct.Data.Object.Amount)
CreateHetznerServerFromPaymentMenu(paymentStruct.Data.Object.BillingDetails.Email, paymentStruct.Data.Object.Amount)
// Then define and call a function to handle the event checkout.session.completed
// ... handle other event types
return c.Redirect(http.StatusFound, "/controlpanel")
default:
fmt.Fprintf(os.Stderr, "Unhandled event type: %s\n", event.Type)
}
return nil
}
i dont know where to find the endpointSecret
for production
Oh, is this the issue?
You can find it in your Dashboard: https://dashboard.stripe.com/webhooks
Could you please share the endpoint ID? we_xxx
You can find it in the browser URL line when you click on one webhook endpoint.
we_1NJ0HrEZ9ROppwY922hwQYSh
You can find the secret here
i dont have that
what is the wbpage
i found it
thanks you i will see if this works thank you for hellping
Happy to help!
thank you