@sapiom/browser-pay intercepts the card request that carries a Sapiom placeholder and relays it through Sapiom. It needs Node.js 18 or later and has no runtime dependencies. For a walkthrough, see Pay in your browser.
attachInterceptor(target, options)
Connects to the browser and starts intercepting. Resolves to anInterceptorHandle once interception is active. Fill card fields only after it resolves.
target is one of:
- a CDP WebSocket URL
- an object with
wsEndpoint(), such as a Puppeteer browser - a page whose
browser()orcontext().browser()returns one
AttachOptions
InterceptorHandle
httpPaymentRelay(options)
Builds a relay that posts toPOST /v1/transactions/{transactionId}/payment/relay.
Events
Event URLs contain only the origin.
Retries
Timeouts, network errors, HTTP 502, 503 and 504, andrelay_in_progress are retried with the same idempotency key until timeoutMs. Any other refusal fails the request. A relay that returns outcome: "unknown" is never sent again.
RefusalReason
unknown_injection, injection_expired, payment_released, key_rotated, already_relayed, relay_in_progress, card_removed, payment_not_authorized, total_changed, destination_not_allowed, card_fields_invalid, merchant_mismatch, provider_unavailable, and unrecognized for any other value. The relay can also refuse with payments_stopped, which this version reports as unrecognized. Each reason’s meaning is in Relay refusals.
FailureReason
intercept_unavailable, unknown_session, unreadable_body, detached, page_origin, unknown, timeout, network, response_credential.
Other exports
Types:AttachOptions, InterceptorEvent, InterceptorHandle, InterceptorTarget, PaymentRelay, RelayCallOptions, RelayRequest, RelayResponse, HeldPlaceholder, PayLogger, HttpRelayOptions, FailureReason, RefusalReason.