#daveglo

1 messages · Page 1 of 1 (latest)

safe sigilBOT
lone girder
#

Hi! Let me help you with this.

#

I don't think you can reproduce this unless you mock the Stripe method. The whole idea of signature is to make sure it comes from Stripe and not someone else.

cursive sundial
safe sigilBOT
tawny jasper
#

👋 taking over for my colleague. Let me catch up.

cursive sundial
#

Hey Tarzan, thanks, I have the webhook running fine, it's just the unit test im trying to figure out. So in the example above, on line 48 event, err = webhook.ConstructEvent(payload, signatureHeader, endpointSecret) im getting "webhook has invalid Stripe-Signature header" on the unit test. But im building the payload by following this https://github.com/stripe/stripe-go/blob/master/README.md#testing-webhook-signing so it seems like when im sending the test request either im providing the wrong secret key but I cant find any more docs on the implementation so im not sure. Should the webhook.GenerateTestSignedPayload() method require a specific secret key? ifso what key should I give it for a unit test? or should it just work?

GitHub

Go library for the Stripe API. . Contribute to stripe/stripe-go development by creating an account on GitHub.

tawny jasper
#

it's not really possible to unit test a Stripe-Signature verification

#

since it's time dependent

cursive sundial
#

ahh, ok that makes sense. I assumed the GenerateTestSignedPayload had some sort of workaround but looking at the code it seems like there is nothing we can do. Thanks a mill for your time, have a great day.

tawny jasper
#

no worries