npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@payfanout/adapter-paysafe

v0.4.3

Published

Client-side Paysafe adapter for PayFanout (Paysafe.js hosted iframe fields, tokenize-first). No secrets, no server code.

Readme

@payfanout/adapter-paysafe

Client-side Paysafe adapter for PayFanout: Paysafe.js hosted iframe fields, tokenize-first, rendered embedded in your UI.

No secrets, no server code. This package holds only a browser-safe public key.

It implements the ClientPaymentAdapter contract from @payfanout/core and plugs into @payfanout/react, which renders the fields and drives the pay flow. Paysafe.js is loaded lazily via a <script> tag only when this adapter is actually mounted, there is nothing extra to install and no SDK download during SSR.

📖 Documentation: https://donapulse.github.io/payfanout/ · React usage · Set up Paysafe

Installation

pnpm add @payfanout/react @payfanout/adapter-paysafe react react-dom

Usage

import { PayFanoutProvider, PaymentFields, PayButton } from "@payfanout/react";
import { PaysafeClientAdapter } from "@payfanout/adapter-paysafe";

const paysafe = new PaysafeClientAdapter({
  apiKey: "base64-public-key",   // public single-use-token key
  environment: "sandbox",        // never inferred
});

<PayFanoutProvider adapters={[paysafe]} initialPsp="paysafe">
  <PaymentFields clientSecret={session.clientSecret} appearance={designTokens} />
  <PayButton
    onResult={(result) => …}
    onServerCompletion={(clientToken) => postToMyApi("/api/complete", { clientToken })}
  >
    Pay
  </PayButton>
</PayFanoutProvider>

This is a tokenize-first PSP: the client tokenizes first, then your server finalizes via completePayment (called through the onServerCompletion route). <PayButton> branches into that path automatically, so the UI code is identical to a confirm-on-client PSP.

Split-field layouts are yours

Paysafe uses separate iframe fields (card number, expiry, CVV). Own the layout with named slots, any grid, rows, and labels:

<PaymentFields clientSecret={secret} fieldOptions={{ fields: { cardNumber: { placeholder: "Card number" } } }}>
  <div className="my-grid">
    <div data-payfanout-field="cardNumber" />
    <div className="row">
      <div data-payfanout-field="expiryDate" />
      <div data-payfanout-field="cvv" />
    </div>
  </div>
</PaymentFields>

Setup and tokenize

  • Setup takes the currency and, when the session names a numeric one, the merchant account (Paysafe.js accounts.default) from the signed session. fieldOptions cannot override the currency, and the session's account replaces any fieldOptions.accounts. Paysafe.js show() runs right after setup, as Paysafe documents.
  • Each card tokenize sends a fresh merchantRefNum, which Paysafe.js requires: the session id when set, then a random suffix, 255 characters at most. A card retried after a decline never reuses one.

Content-Security-Policy

On CSP-enforcing pages, allow every host Paysafe.js touches, or the hosted fields fail quietly: the script (hosted.paysafe.com), the card-field iframes (hosted.paysafe.com in live, hosted.test.paysafe.com in sandbox), and its parent-page XHRs (telemetry to the hosted hosts, config and BIN lookups to api.paysafe.com / api.test.paysafe.com):

script-src  https://hosted.paysafe.com
frame-src   https://hosted.paysafe.com https://hosted.test.paysafe.com
connect-src https://hosted.paysafe.com https://hosted.test.paysafe.com
            https://api.paysafe.com https://api.test.paysafe.com

The .test hosts are used only by environment: "sandbox". On a nonce-based policy, pass the nonce as cspNonce and the adapter puts it on the Paysafe.js <script> it injects. See Set up Paysafe for the per-directive failure modes and what Paysafe.js still needs beyond the nonce.

What's inside

  • PaysafeClientAdapter, mounts the hosted fields, tokenizes, and resolves the tokenize-first completion.
  • decodeSessionPayload and the structural PaysafeJsLike / PaysafeFieldsInstanceLike types so the adapter is testable without the real SDK.

Pair it on the server with @payfanout/adapter-paysafe-server, which issues the signed session context this adapter consumes.

Documentation

License

MIT