HTTP transport for facilitator verify and settle requests.
Summary
Functions
Performs a facilitator HTTP POST request.
Returns recommended Finch pool options with TLS peer verification enabled.
Types
@type response() :: {:ok, %{status: non_neg_integer(), body: map()}} | {:error, X402.Facilitator.Error.t()}
Functions
Performs a facilitator HTTP POST request.
opts supports:
:max_retries(default:2):retry_backoff_ms(default:100):receive_timeout_ms(default:5_000)
TLS Verification
REQUIRED: TLS peer verification must be configured when starting your Finch pool. Failure to do so leaves your application vulnerable to MITM attacks.
Example configuration:
Finch.start_link(
name: MyFinch,
pools: %{
default: [
conn_opts: [
transport_opts: [
verify: :verify_peer,
# Note: requires OTP 25+, see https://www.erlang.org/doc/apps/public_key/public_key.html#cacerts_get/0
cacerts: :public_key.cacerts_get()
]
]
]
}
)See secure_pool_opts/0 for a ready-to-use configuration.
@spec secure_pool_opts() :: keyword()
Returns recommended Finch pool options with TLS peer verification enabled.
Use these when starting your Finch pool to ensure facilitator connections are verified against the system CA store:
Finch.start_link(
name: MyFinch,
pools: %{default: X402.Facilitator.HTTP.secure_pool_opts()}
)Requires OTP 25+ for :public_key.cacerts_get/0.