WrapFetchParams
このコンテンツはまだ日本語訳がありません。
Defined in: src/x402/fetch.ts:50
Parameters for wrapFetch.
Properties
fetch?
readonlyoptionalfetch?:X402Fetch
Defined in: src/x402/fetch.ts:59
Optional underlying fetch implementation. Defaults to globalThis.fetch.
hooks?
readonlyoptionalhooks?: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?
readonlyoptionalonPayment?: (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
paymentRequired
Returns
boolean | Promise<boolean | undefined> | undefined
selectRequirements?
readonlyoptionalselectRequirements?: (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
readonlysigner:X402PaymentSigner
Defined in: src/x402/fetch.ts:55
The signer used to produce X402PaymentPayloads when the server returns 402. Bound to one EOA.