@0to1pay/server-sdk 3.1.3 → 3.1.5
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 +17 -22
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
# 0to1pay Server SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use this server SDK to sell digital goods or one-time paid access in a Next.js or Node.js app. Create a checkout that sends USDC or USDT directly to your merchant wallet. The hosted beta uses test USDC on Base Sepolia and Ethereum Sepolia and test USDT on TRON Nile. Requires Node.js 22.20.0+.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Choosing how to accept payment for an access pass? [Compare payment options for a Next.js app](https://0to1pay.com/guides/nextjs-access-pass-payments).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Next.js quickstart
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **Make a test purchase.** Connect a Base Sepolia wallet with 0.01 test USDC and test ETH for gas. If you already sent the payment, recover that order and sign its proof. [Live checkout](https://0to1pay.com/demo/base-usdc)
|
|
9
|
+
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.
|
|
11
10
|
|
|
12
|
-
To run the
|
|
11
|
+
To run the [Next.js checkout and webhook example from source](https://github.com/0to1pay/nextjs-usdc-access-pass), 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)
|
|
13
12
|
|
|
14
13
|
```sh
|
|
15
14
|
curl -fsSLO https://0to1pay.com/examples/nextjs-base-usdc.zip
|
|
@@ -30,7 +29,7 @@ npm run dev
|
|
|
30
29
|
npm run worker
|
|
31
30
|
```
|
|
32
31
|
|
|
33
|
-
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. [
|
|
32
|
+
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)
|
|
34
33
|
|
|
35
34
|
## Use the server client in an existing app
|
|
36
35
|
|
|
@@ -51,29 +50,25 @@ const { data } = await client.call('listChainAssets', {});
|
|
|
51
50
|
const baseUsdc = data.find(asset => asset.network_id === 'eip155:84532' && asset.symbol === 'USDC');
|
|
52
51
|
```
|
|
53
52
|
|
|
54
|
-
##
|
|
53
|
+
## Plans and usage
|
|
55
54
|
|
|
56
55
|
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.
|
|
57
56
|
|
|
58
57
|
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)
|
|
59
58
|
|
|
60
|
-
A single controlled run on Node 22.23.5/PostgreSQL 17 measured 6.534 s for cold-cache package installation and 10.810 s from setup to ready HTTP with database, HTTPS and credentials prepared. Three public Base Sepolia purchases granted three original-buyer passes with zero duplicate grants. First-merchant self-install time remains unmeasured. [Completed-order evidence](https://0to1pay.com/guides/nextjs-base-usdc#completed-order)
|
|
61
|
-
|
|
62
59
|
For integration tools and coding assistants, start with the [Markdown quickstart](https://0to1pay.com/guides/nextjs-base-usdc.md), [public OpenAPI JSON](https://api.0to1pay.com/openapi.json), [API reference](https://0to1pay.com/docs), and [SDK reference](https://0to1pay.com/sdk).
|
|
63
60
|
|
|
64
61
|
Use `call` for the full merchant API. Use the same idempotency key when retrying a mutation for the same logical request. The client validates requests and responses against the bundled OpenAPI contract. The hosted API also serves the contract at `/openapi.json`. Keep the scoped key on your server and route browser actions through your merchant backend.
|
|
65
62
|
|
|
66
63
|
## Create a stablecoin checkout
|
|
67
64
|
|
|
68
|
-
|
|
|
65
|
+
| Beta network | `network_id` | Test asset |
|
|
69
66
|
| --- | --- | --- |
|
|
70
|
-
| Ethereum | `eip155:
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
74
|
-
Call `listChainAssets` for the assets enabled in the key's environment. The platform can offer a subset of the live combinations. Register a scoped chain connection and its merchant-owned recipient addresses through `createChainConnection` and `registerChainRecipients`. Create a payment using `policy_ref: 'digital_goods_standard_v1'` and a price in `stable:USDC` or `stable:USDT` with scale `6`. Ten USDC uses `{ asset: 'stable:USDC', amount_atomic: '10000000', scale: 6 }`. The atomic amount must be positive and below `2^64`. Every connection in `allowed_connections` must support the selected price denomination.
|
|
67
|
+
| Ethereum Sepolia | `eip155:11155111` | USDC |
|
|
68
|
+
| Base Sepolia | `eip155:84532` | USDC |
|
|
69
|
+
| TRON Nile | `tron:3448148188` | USDT |
|
|
75
70
|
|
|
76
|
-
|
|
71
|
+
Call `listChainAssets` to see which assets your project can accept. Register a test connection and its merchant-owned receiving addresses through `createChainConnection` and `registerChainRecipients`. Create a payment using `policy_ref: 'digital_goods_standard_v1'` and a price in `stable:USDC` or `stable:USDT` with scale `6`. For example, 0.01 USDC is `{ asset: 'stable:USDC', amount_atomic: '10000', scale: 6 }`. The atomic amount must be positive and below `2^64`. Each connection in `allowed_connections` must support the selected asset. Use a webhook from the same test project.
|
|
77
72
|
|
|
78
73
|
Call `createQuote` with the matching denomination or its registered asset on the selected chain. Then call `createAttempt` with `connection_id` and `quote_id` to read the reserved destination and transfer instructions. Finish checkout with the buyer authorization and signed transaction steps below.
|
|
79
74
|
|
|
@@ -94,20 +89,20 @@ The merchant backend authenticates the buyer and checks their access to the quot
|
|
|
94
89
|
|
|
95
90
|
Use the wallet's UTF-8 message signing for the chain. Ethereum and Base use the EVM personal-message signature. TRON uses `signMessageV2`, which returns a `0x`-prefixed signature. EVM and TRON transaction hashes must contain 64 hexadecimal digits. The claim helper accepts `0x` or `0X` and normalizes to lowercase `0x`-prefixed hex. TRON also accepts bare hex.
|
|
96
91
|
|
|
97
|
-
The platform compares the finalized transaction's actual token source with the approved wallet and checks the exact token, destination, amount, and timing.
|
|
92
|
+
The platform compares the finalized transaction's actual token source with the approved wallet and checks the exact token, destination, amount, and timing. If a buyer has already sent funds, resume the existing order and use the original transaction hash to finish the wallet proof. The buyer can share their order reference and hash with the merchant for help. Access is granted after the payment is confirmed and the signed fulfillment command is processed.
|
|
98
93
|
|
|
99
94
|
## Subscription and API request allowance
|
|
100
95
|
|
|
101
|
-
To integrate with billing directly, use a dedicated billing key on your server.
|
|
96
|
+
To integrate with billing directly, use a dedicated billing key on your server. A test billing key with `billing:write` can issue a Sandbox server key via `client.call('issueTestBillingKey', { body: {}, idempotencyKey })`. The returned key belongs to the test environment. Save its token in your server's secret store. If the response is lost, retry with the same billing credential and idempotency key. A project can issue five Sandbox keys per rolling 24 hours and hold five active Sandbox keys. `SANDBOX_KEY_LIMIT_REACHED` indicates that limit was reached.
|
|
102
97
|
|
|
103
|
-
|
|
98
|
+
To purchase a prepaid subscription for your beta project and issue a server key, use the billing API from your backend.
|
|
104
99
|
|
|
105
|
-
1. Call `listBillingPlans` and `getBillingSubscription` to read plan terms, current request usage, and available collection networks. Each collection option identifies
|
|
100
|
+
1. Call `listBillingPlans` and `getBillingSubscription` to read plan terms, current request usage, and available collection networks. Each collection option identifies the network and test token to use.
|
|
106
101
|
2. Call `createBillingInvoice` with a paid `plan_id`, wallet `payer_address` and an opaque `checkout_session_ref`. Choose an offered `network_id` or omit it for the default configured collector.
|
|
107
102
|
3. Sign the invoice intent, call `authorizeBillingInvoice`, then send the exact token and amount in the quote on its specified network. TRON wallets sign the intent and transaction claim using the TRON V2 message format. Sign the transaction claim and call `submitBillingInvoice` with the same checkout session. Each mutation uses its own stable idempotency key.
|
|
108
103
|
4. Use `listBillingInvoices` to resume recent invoices and poll `getBillingInvoice` for a single invoice. During `reconciling`, wait for final reconciliation before paying again. An active invoice reflects verified payment and a current prepaid period. An early renewal can be scheduled for the end of the current period.
|
|
109
104
|
5. Call `issueBillingKey` with `body: {}` and a stable idempotency key. Store the returned token on the server.
|
|
110
105
|
|
|
111
|
-
|
|
106
|
+
`API_REQUEST_LIMIT_REACHED` indicates that the project has used its allowance for the period. Payment completion and fulfillment operations remain available to keys with the appropriate scopes.
|
|
112
107
|
|
|
113
108
|
The SDK is available under the MIT license. See the `LICENSE` file included in the package.
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0to1pay/server-sdk",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Stablecoin checkout for Next.js and Node.js apps selling digital goods. Accept USDC or USDT in a merchant wallet for paid access.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/0to1pay/sdk.git",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"tron",
|
|
42
42
|
"nextjs",
|
|
43
43
|
"webhooks",
|
|
44
|
-
"checkout"
|
|
44
|
+
"checkout",
|
|
45
|
+
"digital-goods",
|
|
46
|
+
"paid-access"
|
|
45
47
|
]
|
|
46
48
|
}
|