Documentation
¶
Overview ¶
Package contracttest is the shared suite every payment adapter passes, like the sending adapters' (internal/providers/contracttest): the catalog entry, the key rules (restricted keys only, secret keys refused before any call), the permission check, the webhook's registration and signature (bad signatures and replays refused), checkout, products and prices, and an outage — against the adapter's fake of the provider's API, with no network.
func TestContract(t *testing.T) {
contracttest.Run(t, contracttest.Suite{Adapter: "stripe", Env: newEnv})
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Env ¶
type Env struct {
// Open connects to the fake with key.
Open func(key string) (payments.Client, error)
// Keys the fake knows: a live and a test restricted key, a restricted
// key that lacks MissingPermission, and one the provider rejects.
LiveKey, TestKey, MissingKey, RejectedKey string
MissingPermission string
// SecretKey is an unrestricted secret key of the provider's format.
SecretKey string
// Requests counts the calls the fake received.
Requests func() int
// Event is a recorded event (raw body) and Sign signs a body with a
// webhook secret at ts, as the provider's request headers would.
Event func(t *testing.T, c payments.Client) []byte
Sign func(secret string, body []byte, ts time.Time) http.Header
// Outage makes the fake answer 5xx to every call.
Outage func()
}
Env is the adapter's fake provider for one test.
Click to show internal directories.
Click to hide internal directories.