Skip to main content
The forwardToArbiter() function creates an onAfterSettle hook that forwards the response body and reconstructed PaymentInfoWire to an arbiter service. It runs fire-and-forget so it never blocks the response to the client.
  • Only fires for successful auth-capture scheme settlements
  • POSTs { responseBody, transaction, paymentInfoWire } to {arbiterUrl}/verify
  • The hook catches errors internally so an unreachable arbiter cannot break the payment flow

Usage

Function signature

Parameters

Options

Payload shape

When an auth-capture settlement succeeds, the hook POSTs the following JSON to {arbiterUrl}/verify:
The helper reconstructs PaymentInfoWire from the verified SettleResultContext using the reconstructPaymentInfoWire() helper. The arbiter consumes req.body.paymentInfoWire and runs it through PaymentInfo.fromWire(...) (from @x402r/sdk or @x402r/core) to get the bigint-typed PaymentInfo struct expected by SDK actions.

Error handling

By default, the hook logs fetch errors with console.warn. Override this with a custom handler:
The hook wraps each error in an X402rError carrying the arbiter endpoint and request details for easier debugging.

Skipped scenarios

The hook returns without making a request when:
  • The settlement was not successful (context.result.success === false)
  • The scheme is not auth-capture
  • No response body is available in the transport context

Address re-exports

The @x402r/helpers package re-exports chain-invariant address constants from @x402r/core for convenience:
Plus the @x402r/evm wire-format types and guards:
And the x402rDefaults builder for hand-constructing extra in PaymentRequirements:
x402rDefaults(input) returns an AuthCaptureExtra populated with sensible defaults, useful when you want to build PaymentRequirements outside the merchant client.

Next steps

Examples

See working merchant server examples.