コンテンツにスキップ

WrapFetchParams

このコンテンツはまだ日本語訳がありません。

Defined in: src/x402/fetch.ts:50

Parameters for wrapFetch.

Properties

fetch?

readonly optional fetch?: X402Fetch

Defined in: src/x402/fetch.ts:59

Optional underlying fetch implementation. Defaults to globalThis.fetch.


hooks?

readonly optional hooks?: ObservabilityHooks

Defined in: src/x402/fetch.ts:86

Optional observability callbacks. wrapFetch emits an onClientPayment event for every paywall round-trip — success when the retry returns 2xx with a PAYMENT-RESPONSE header, failure otherwise (including onPayment declining the retry).


onPayment?

readonly optional onPayment?: (requirements, paymentRequired) => boolean | Promise<boolean | undefined> | undefined

Defined in: src/x402/fetch.ts:76

Optional hook invoked just before the retry request goes out. Receives the chosen requirements and the parsed 402 body so the caller can log spending, prompt the user, or enforce a budget.

Returning false aborts the retry — the original 402 is returned.

Parameters

requirements

X402PaymentRequirements

paymentRequired

X402PaymentRequiredResponse

Returns

boolean | Promise<boolean | undefined> | undefined


selectRequirements?

readonly optional selectRequirements?: (accepts, response) => X402PaymentRequirements | null

Defined in: src/x402/fetch.ts:65

Optional policy for choosing one entry from the server’s accepts list. Defaults to the first entry. Return null to abort — the original 402 response is returned without retry.

Parameters

accepts

readonly X402PaymentRequirements[]

response

Response

Returns

X402PaymentRequirements | null


signer

readonly signer: X402PaymentSigner

Defined in: src/x402/fetch.ts:55

The signer used to produce X402PaymentPayloads when the server returns 402. Bound to one EOA.