@0to1pay/fulfillment-sdk 3.1.2 → 3.1.4
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 +30 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,21 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
Verify signed payment webhooks, commit them to a PostgreSQL inbox, and grant a digital entitlement with the matching order in a single merchant transaction. Node.js 22.20.0+.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Next.js quickstart
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The Next.js example takes a 0.01 test USDC payment on Base Sepolia and grants the buyer one access pass from a signed webhook. Follow the [Next.js quickstart](https://0to1pay.com/docs#nextjs-quickstart) or [한국어 빠른 시작](https://0to1pay.com/docs?lang=ko#nextjs-quickstart). To make a [test purchase](https://0to1pay.com/demo/base-usdc), use a Base Sepolia wallet with test USDC and test ETH for gas. If you have already sent the payment, reopen your original order.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
To run the example on your server, prepare Node.js 22.20+, writable PostgreSQL, a public HTTPS webhook and a separate continuously running worker. Create a test project and issue a scoped server key. [Merchant dashboard](https://pay.0to1pay.com/merchant)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```sh
|
|
12
|
+
curl -fsSLO https://0to1pay.com/examples/nextjs-base-usdc.zip
|
|
13
|
+
unzip nextjs-base-usdc.zip
|
|
14
|
+
cd nextjs-base-usdc
|
|
15
|
+
npm ci
|
|
16
|
+
cp .env.example .env
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Set `DATABASE_URL`, `ZERO_TO_ONE_PAY_API_KEY`, `MERCHANT_ID` and `PROJECT_ID`. Use the exact browser origin for `APP_ORIGIN` (local default `http://localhost:3000`) and the public HTTPS URL forwarding the original request bytes to `POST /api/webhooks/0to1pay` for `WEBHOOK_URL`. Run the app in one terminal and the worker in another, from the same directory.
|
|
12
20
|
|
|
13
21
|
```sh
|
|
14
|
-
npm
|
|
22
|
+
npm run setup
|
|
23
|
+
npm run dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm run worker
|
|
15
28
|
```
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
Preserve the merchant database and private `.merchant/` directory. The example associates one entitlement with its original order and guest. A signed recovery challenge lets the original paying wallet regain access after cookie loss. [Setup and purchase recovery](https://0to1pay.com/guides/nextjs-base-usdc) · [Machine-readable guide](https://0to1pay.com/guides/nextjs-base-usdc.md)
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
## Add signed fulfillment to an existing app
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm install @0to1pay/server-sdk @0to1pay/fulfillment-sdk pg
|
|
36
|
+
```
|
|
20
37
|
|
|
21
38
|
1. Register an HTTPS webhook endpoint for `fulfillment.requested`. Save the returned signing key ID and base64url secret in your backend's secret store. Configure `FulfillmentInbox` with the merchant ID, project ID and environment of the same project, and decode the signing secret with `Buffer.from(secret, 'base64url')`.
|
|
22
39
|
2. Call `migrateFulfillmentInbox(pool)` on your merchant database. Pass the original HTTP body bytes and headers to `FulfillmentInbox.receive`. Acknowledge delivery after the call resolves.
|
|
@@ -26,4 +43,10 @@ Apply each command at most once and keep entitlements for distinct orders indepe
|
|
|
26
43
|
|
|
27
44
|
For direct USDC and USDT orders, the platform emits fulfillment commands after it verifies the buyer-approved transfer or records an authorized review. Integrate the [buyer approval steps in the public server SDK guide](https://www.npmjs.com/package/@0to1pay/server-sdk#buyer-approval-for-on-chain-checkout) before offering checkout.
|
|
28
45
|
|
|
46
|
+
## Plans and usage
|
|
47
|
+
|
|
48
|
+
The project can use Sandbox for free with 1,000 metered requests per UTC calendar month. Prepay for 30 days with Starter (9 test tokens / 1,000 requests), Growth (29 / 5,000), or Scale (99 / 25,000). The beta accepts test USDC or USDT at zero real cost. All paid plans include Ethereum Sepolia, Base Sepolia, TRON Nile, the core APIs, webhooks and recovery. Pricing is independent of settled volume and successful payment count.
|
|
49
|
+
|
|
50
|
+
One order creation plus one quote creation uses two requests. With no other metered calls, 500 fresh checkouts consume Starter’s 1,000 requests. Include metered list/configuration reads in your estimate. Same-project, same-key, same-content creation retries count once. At 80% and 95% the API flags usage. At 100%, new starts stop and existing verification, fulfillment and redelivery continue. A manual upgrade charges the difference and retains usage and expiry. Renewals require a manual payment. The service does not bill overages. [Estimate your 30-day cost](https://0to1pay.com/pricing)
|
|
51
|
+
|
|
29
52
|
The SDK is available under the MIT license. See the `LICENSE` file included in the package.
|