Skip to main content

Module hooks

Module hooks 

Source
Available on crate feature client only.
Expand description

Lifecycle hooks for the x402 client payment creation pipeline.

Hooks allow applications to intercept and customize the payment creation lifecycle. This mirrors the Go SDK’s client_hooks.go design, using the same HookDecision / FailureRecovery enums as the server-side hooks for a consistent API.

§Hook Lifecycle

  1. before_payment_creation — Run before payment creation; can abort it.
  2. Payment signing executes
  3. after_payment_creation (on success) — Observes the result.
  4. on_payment_creation_failure (on error) — Can recover with substitute headers.

§Usage

Implement ClientHooks with only the hooks you need — all methods have default no-op implementations.

Structs§

PaymentCreationContext
Context passed to client payment creation lifecycle hooks.

Traits§

ClientHooks
Lifecycle hooks for client-side payment creation.