@fayz-ai/plugin-payments

中文文档
0.9.49发布于 2026/11/11MITTypeScriptES Module近 30 天下载 5199

[experimental] Fayz SDK — payments plugin (Pix charge provider + website surface)

原始使用文档
文档目录4 节
  1. What's inside
  2. Install
  3. Usage
  4. Part of the Fayz SDK

@fayz-ai/plugin-payments

A Pix charge provider (and website payment surface) for Fayz apps and storefronts.

npm license

Status: early / beta — pre-1.0. Ships a working Pix mock provider plus React hooks and a public payment surface; the real gateway (Supabase / MercadoPago) is deferred and not yet implemented — apps run on the mock until a gateway is wired. APIs may change before 1.0.

Taking money is the one thing every commerce build cannot fake, and in Brazil that means Pix. plugin-payments gives Fayz apps a single PaymentProvider abstraction for Pix charges — create a charge, get a QR / copy-paste code, poll its status — behind the same safe mock/real resolver used across the SDK. Build and demo the whole checkout flow today on the mock; swap in a real gateway later without touching the UI.

What's inside

  • Payment provider — createSafePaymentProvider() resolves a real gateway when configured, else createMockPaymentProvider(); PaymentProvider / PixCharge / CreateChargeInput / ChargeStatus types re-exported from @fayz-ai/core
  • Working mock — generates a Pix BR code, auto-pays after a configurable delay (default 6s) and expires after a window (default 5min), so status polling is realistic
  • Public payment surface (@fayz-ai/plugin-payments/public) — createPublicPaymentPlugin(options) returns { manifest, Provider, paymentProvider }, plus usePixCharge, useChargeStatus, and PaymentProviderContext / usePaymentContext
  • Deferred real provider — createSupabasePaymentProvider() is a stub that throws until the Supabase/MercadoPago gateway lands

Install

npm install @fayz-ai/plugin-payments

Runtime dep: @fayz-ai/core. The ./public subpath additionally needs react / react-dom.

Usage

// Headless: a charge provider anywhere
import { createSafePaymentProvider } from '@fayz-ai/plugin-payments'

const payments = createSafePaymentProvider()
const charge = await payments.createCharge({ amount: 49.9, currency: 'BRL', orderId: 'abc' })
// charge.pixCopyPaste, charge.pixQrCode, then poll payments.getChargeStatus(charge.chargeId)
// Website surface: the payment plugin bundle
import { createPublicPaymentPlugin } from '@fayz-ai/plugin-payments/public'

const paymentPlugin = createPublicPaymentPlugin({ currency: 'BRL' })
// wrap your checkout tree in <paymentPlugin.Provider> and use usePixCharge()/useChargeStatus()

Part of the Fayz SDK

The money seam. Feeds the storefront/checkout surfaces and pairs with @fayz-ai/plugin-orders and @fayz-ai/plugin-shop; composes alongside @fayz-ai/plugin-blog in bespoke website builds.

版本与发布记录

@fayz-ai/plugin-payments 共发布 60 个版本,首次发布于 2026/07/13;过去 12 个月发布了 60 个版本。

版本发布日期距今
0.9.49latest2026/11/112 天前
0.9.482026/11/113 天前
0.9.472026/11/068 天前
0.9.462026/11/059 天前
0.9.452026/11/0410 天前
0.9.442026/10/3015 天前

其他发布通道:next → 0.9.0-next.1,canary → 0.9.44-canary.20261028153856。

关于 @fayz-ai/plugin-payments 的常见问题

@fayz-ai/plugin-payments 是什么?

[experimental] Fayz SDK — payments plugin (Pix charge provider + website surface)

如何安装 @fayz-ai/plugin-payments?

在项目目录运行 npm install @fayz-ai/plugin-payments,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fayz-ai/plugin-payments 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fayz-ai/plugin-payments 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fayz-ai/plugin-payments 可以商用吗?

@fayz-ai/plugin-payments 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fayz-ai/plugin-payments 的下载量有多少?

根据 npm 官方下载统计,@fayz-ai/plugin-payments 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,199 次,日均约 173 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fayz-ai/plugin-payments 还在维护吗?

最新版本 0.9.49 发布于 2026/11/11(2 天前);至今共发布 60 个版本,其中过去 12 个月发布了 60 个;首次发布于 2026/07/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。