Documentation ¶
Overview ¶
Index ¶
- Constants
- Variables
- func ConstructEvent(payload []byte, header string, secret string) (stripe.Event, error)
- func ConstructEventIgnoringTolerance(payload []byte, header string, secret string) (stripe.Event, error)
- func ConstructEventWithTolerance(payload []byte, header string, secret string, tolerance time.Duration) (stripe.Event, error)
Examples ¶
Constants ¶
const ( // Signatures older than this will be rejected by ConstructEvent DefaultTolerance time.Duration = 300 * time.Second )
Variables ¶
var ( ErrNotSigned error = errors.New("Webhook has no Stripe-Signature header") ErrInvalidHeader error = errors.New("Webhook has invalid Stripe-Signature header") ErrTooOld error = errors.New("Timestamp wasn't within tolerance") ErrNoValidSignature error = errors.New("Webhook had no valid signature") )
Functions ¶
func ConstructEvent ¶
Initializes an Event object from a JSON webhook payload, validating the Stripe-Signature header using the specified signing secret. Returns an error if the body or Stripe-Signature header provided are unreadable, if the signature doesn't match, or if the timestamp for the signature is older than DefaultTolerance.
NOTE: Stripe will only send Webhook signing headers after you have retrieved your signing secret from the Stripe dashboard: https://dashboard.stripe.com/webhooks
func ConstructEventIgnoringTolerance ¶
func ConstructEventIgnoringTolerance(payload []byte, header string, secret string) (stripe.Event, error)
Initializes an Event object from a JSON webhook payload, validating the Stripe-Signature header using the specified signing secret. Returns an error if the body or Stripe-Signature header provided are unreadable or if the signature doesn't match. Does not check the signature's timestamp.
NOTE: Stripe will only send Webhook signing headers after you have retrieved your signing secret from the Stripe dashboard: https://dashboard.stripe.com/webhooks
func ConstructEventWithTolerance ¶
func ConstructEventWithTolerance(payload []byte, header string, secret string, tolerance time.Duration) (stripe.Event, error)
Initializes an Event object from a JSON webhook payload, validating the signature in the Stripe-Signature header using the specified signing secret and tolerance window. Returns an error if the body or Stripe-Signature header provided are unreadable, if the signature doesn't match, or if the timestamp for the signature is older than the specified tolerance.
NOTE: Stripe will only send Webhook signing headers after you have retrieved your signing secret from the Stripe dashboard: https://dashboard.stripe.com/webhooks
Types ¶
This section is empty.