webhook

package
v34.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Example
Output:

Index

Examples

Constants

View Source
const (
	// Signatures older than this will be rejected by ConstructEvent
	DefaultTolerance time.Duration = 300 * time.Second
)

Variables

View Source
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

func ConstructEvent(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, 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL