#daveglo
1 messages · Page 1 of 1 (latest)
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.
Thanks so much. so im going by this https://github.com/stripe/stripe-go/blob/master/README.md#testing-webhook-signing does the GenerateTestSignedPayload method not do that?
👋 taking over for my colleague. Let me catch up.
you can always refer to this doc https://stripe.com/docs/webhooks/quickstart
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?
it's not really possible to unit test a Stripe-Signature verification
since it's time dependent
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.
no worries