#ByteFox

1 messages · Page 1 of 1 (latest)

vernal lintelBOT
rancid yew
#

Hi! Let me help you with this.

#

Could you please share the exact error?

hallow rapids
#

Error verifying webhook signature: webhook had no valid signature

rancid yew
#

And you say it works on local?

hallow rapids
#

yes

rancid yew
#

Do you have any proxies in front of your server on production that might change the headers/body?

hallow rapids
#

no

#

its just a unbuntu sever vanila from hetnzer

rancid yew
#

Could you please share the relevant code?

hallow rapids
#

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

rancid yew
hallow rapids
#

whyes i have created the end

#

but i cant find a end point secret that works

rancid yew
#

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.

hallow rapids
#

we_1NJ0HrEZ9ROppwY922hwQYSh

rancid yew
#

You can find the secret here

hallow rapids
#

i dont have that

#

what is the wbpage

#

i found it

#

thanks you i will see if this works thank you for hellping

rancid yew
#

Happy to help!

hallow rapids
#

thank you