@fayz-ai/plugin-payments 0.1.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @fayz-ai/plugin-payments
|
|
2
|
+
|
|
3
|
+
> A Pix charge provider (and website payment surface) for Fayz apps and storefronts.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fayz-ai/plugin-payments)
|
|
6
|
+
[](https://github.com/FayaLabs/fayz-sdk/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
**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.
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
## What's inside
|
|
13
|
+
- **Payment provider** — `createSafePaymentProvider()` resolves a real gateway when configured, else `createMockPaymentProvider()`; `PaymentProvider` / `PixCharge` / `CreateChargeInput` / `ChargeStatus` types re-exported from `@fayz-ai/core`
|
|
14
|
+
- **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
|
|
15
|
+
- **Public payment surface** (`@fayz-ai/plugin-payments/public`) — `createPublicPaymentPlugin(options)` returns `{ manifest, Provider, paymentProvider }`, plus `usePixCharge`, `useChargeStatus`, and `PaymentProviderContext` / `usePaymentContext`
|
|
16
|
+
- **Deferred real provider** — `createSupabasePaymentProvider()` is a stub that throws until the Supabase/MercadoPago gateway lands
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
```bash
|
|
20
|
+
npm install @fayz-ai/plugin-payments
|
|
21
|
+
```
|
|
22
|
+
Runtime dep: `@fayz-ai/core`. The `./public` subpath additionally needs `react` / `react-dom`.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
```ts
|
|
26
|
+
// Headless: a charge provider anywhere
|
|
27
|
+
import { createSafePaymentProvider } from '@fayz-ai/plugin-payments'
|
|
28
|
+
|
|
29
|
+
const payments = createSafePaymentProvider()
|
|
30
|
+
const charge = await payments.createCharge({ amount: 49.9, currency: 'BRL', orderId: 'abc' })
|
|
31
|
+
// charge.pixCopyPaste, charge.pixQrCode, then poll payments.getChargeStatus(charge.chargeId)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// Website surface: the payment plugin bundle
|
|
36
|
+
import { createPublicPaymentPlugin } from '@fayz-ai/plugin-payments/public'
|
|
37
|
+
|
|
38
|
+
const paymentPlugin = createPublicPaymentPlugin({ currency: 'BRL' })
|
|
39
|
+
// wrap your checkout tree in <paymentPlugin.Provider> and use usePixCharge()/useChargeStatus()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Part of the Fayz SDK
|
|
43
|
+
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fayz-ai/plugin-payments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "[experimental] Fayz SDK — payments plugin (Pix charge provider + website surface)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@fayz-ai/core": "^0.
|
|
32
|
+
"@fayz-ai/core": "^0.8.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "^18.3.0",
|