@siglume/direct-request-payment 0.4.22 → 0.4.24
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/CHANGELOG.md +36 -0
- package/README.md +23 -12
- package/bin/siglume-sdrp.mjs +302 -19
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/docs/announcement-ja.md +7 -3
- package/docs/api-reference.md +5 -3
- package/docs/merchant-quickstart.md +6 -4
- package/docs/pricing.md +1 -1
- package/docs/quickstart-10-minutes.md +91 -58
- package/docs/sandbox.md +29 -4
- package/docs/troubleshooting.md +12 -8
- package/examples/hosted-checkout-python/pyproject.toml +1 -1
- package/package.json +2 -2
- package/templates/express/siglume-order-store.sql.ts +279 -52
- package/templates/express/siglume-sdrp-routes.ts +43 -9
- package/templates/fastapi/README.md +32 -3
- package/templates/fastapi/siglume_order_store_example.py +15 -0
- package/templates/fastapi/siglume_order_store_sqlalchemy.py +238 -53
- package/templates/fastapi/siglume_order_store_sqlalchemy_async.py +496 -0
- package/templates/fastapi/siglume_sdrp_routes.py +31 -0
package/docs/pricing.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Pricing
|
|
2
2
|
|
|
3
3
|
This page documents the trial-phase merchant pricing for Siglume Direct Request
|
|
4
|
-
Payment as of SDK v0.4.
|
|
4
|
+
Payment as of SDK v0.4.24. Pricing can change by agreement or future product
|
|
5
5
|
release; the Siglume platform response is the source of truth for per-payment
|
|
6
6
|
fee data returned at runtime.
|
|
7
7
|
|
|
@@ -11,45 +11,9 @@ The SDK supplies the readiness check, route files, webhook verification, payment
|
|
|
11
11
|
classification, and the order-store adapter contract. Your app supplies the
|
|
12
12
|
real order lookup and fulfillment writes.
|
|
13
13
|
|
|
14
|
-
## 0.
|
|
14
|
+
## 0. Install the SDK
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
Siglume-compatible API server bundled with the SDK. It creates fake checkout
|
|
18
|
-
sessions, signs webhooks with your sandbox secret, records delivery status, and
|
|
19
|
-
never charges a wallet.
|
|
20
|
-
|
|
21
|
-
In one terminal, point it at your product's local webhook route:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npx siglume-sdrp sandbox \
|
|
25
|
-
--origin http://localhost:3000 \
|
|
26
|
-
--webhook-url http://localhost:3000/payments/webhooks/siglume
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Use the values it prints in your product `.env`:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
SIGLUME_ENV=sandbox
|
|
33
|
-
SIGLUME_API_BASE=http://127.0.0.1:8787/v1
|
|
34
|
-
SIGLUME_MERCHANT_AUTH_TOKEN=sandbox_merchant_token
|
|
35
|
-
SIGLUME_DIRECT_PAYMENT_MERCHANT=sandbox_merchant
|
|
36
|
-
SHOP_PUBLIC_ORIGIN=http://localhost:3000
|
|
37
|
-
SHOP_WEBHOOK_URL=http://localhost:3000/payments/webhooks/siglume
|
|
38
|
-
SIGLUME_WEBHOOK_SECRET=whsec_sandbox_local
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Then run:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npx siglume-check readiness --sandbox
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
The sandbox readiness check proves your local server can receive a signed
|
|
48
|
-
`direct_payment.confirmed` delivery before you use live credentials.
|
|
49
|
-
|
|
50
|
-
## 1. Live readiness
|
|
51
|
-
|
|
52
|
-
Install the SDK in your product.
|
|
16
|
+
Install the SDK in your existing product first.
|
|
53
17
|
|
|
54
18
|
Node / Express:
|
|
55
19
|
|
|
@@ -63,6 +27,13 @@ Python / FastAPI:
|
|
|
63
27
|
pip install siglume-direct-request-payment
|
|
64
28
|
```
|
|
65
29
|
|
|
30
|
+
For FastAPI projects, the Python package supplies `init`, `preflight`, and
|
|
31
|
+
`verify` commands. The local sandbox server is currently provided by the npm
|
|
32
|
+
CLI, so install Node.js/npm as well when you want local sandbox checkout
|
|
33
|
+
verification.
|
|
34
|
+
|
|
35
|
+
## 1. Optional live preflight
|
|
36
|
+
|
|
66
37
|
Set these environment variables in your app or `.env`:
|
|
67
38
|
|
|
68
39
|
```bash
|
|
@@ -73,32 +44,32 @@ SHOP_WEBHOOK_URL=https://api.your-product.example/payments/webhooks/siglume
|
|
|
73
44
|
SIGLUME_WEBHOOK_SECRET=<webhook signing secret from setupCheckout/setup_checkout>
|
|
74
45
|
```
|
|
75
46
|
|
|
76
|
-
|
|
47
|
+
Before mounting routes, you may run a preflight. It checks local config,
|
|
48
|
+
merchant, billing, webhook subscription metadata, and Hosted Checkout access,
|
|
49
|
+
but it intentionally does not send a webhook delivery because your webhook route
|
|
50
|
+
does not exist yet.
|
|
77
51
|
|
|
78
52
|
```bash
|
|
79
53
|
# Node / Express
|
|
80
|
-
npx siglume-check
|
|
54
|
+
npx siglume-check preflight
|
|
81
55
|
|
|
82
56
|
# Python / FastAPI
|
|
83
|
-
siglume-check
|
|
57
|
+
siglume-check preflight
|
|
84
58
|
```
|
|
85
59
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
that `direct_payment.confirmed` is subscribed, verifies the local webhook secret
|
|
90
|
-
against the subscription hint, creates one unpaid expiring Hosted Checkout probe
|
|
91
|
-
session, and queues a signed webhook test delivery. No buyer is charged.
|
|
60
|
+
Use `readiness` or `verify` only after your webhook route is mounted and your
|
|
61
|
+
app is running. Those commands also queue a signed webhook test delivery and
|
|
62
|
+
require it to be delivered.
|
|
92
63
|
|
|
93
64
|
For a CI local-config smoke test:
|
|
94
65
|
|
|
95
66
|
```bash
|
|
96
|
-
npx siglume-check
|
|
67
|
+
npx siglume-check preflight --no-api --json
|
|
97
68
|
```
|
|
98
69
|
|
|
99
70
|
`--no-api` does not prove Hosted Checkout or webhook delivery. Before opening a
|
|
100
|
-
human web checkout path, run
|
|
101
|
-
item.
|
|
71
|
+
human web checkout path, run `siglume-check verify` without `--no-api` and fix
|
|
72
|
+
every FAIL item.
|
|
102
73
|
|
|
103
74
|
## 2. Copy integration files into your product
|
|
104
75
|
|
|
@@ -219,14 +190,76 @@ from .siglume.siglume_order_store_sqlalchemy import (
|
|
|
219
190
|
engine = create_sqlalchemy_engine(os.environ["DATABASE_URL"])
|
|
220
191
|
create_sqlalchemy_siglume_schema(engine)
|
|
221
192
|
SessionLocal = sessionmaker(engine, future=True)
|
|
222
|
-
order_store = SQLAlchemySiglumeOrderStore(
|
|
193
|
+
order_store = SQLAlchemySiglumeOrderStore(
|
|
194
|
+
SessionLocal,
|
|
195
|
+
# Optional for existing products with different order table/column names:
|
|
196
|
+
# orders_table=product_orders,
|
|
197
|
+
# order_id_column="order_id",
|
|
198
|
+
# amount_minor_column="total_cents",
|
|
199
|
+
# currency_column="iso_currency",
|
|
200
|
+
# order_status_column="payment_status",
|
|
201
|
+
)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
If your FastAPI app already uses SQLAlchemy `AsyncSession`, use the async
|
|
205
|
+
adapter instead:
|
|
206
|
+
|
|
207
|
+
```py
|
|
208
|
+
from sqlalchemy.ext.asyncio import async_sessionmaker
|
|
209
|
+
from .siglume.siglume_order_store_sqlalchemy_async import (
|
|
210
|
+
AsyncSQLAlchemySiglumeOrderStore,
|
|
211
|
+
create_async_sqlalchemy_engine,
|
|
212
|
+
create_async_sqlalchemy_siglume_schema,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
engine = create_async_sqlalchemy_engine(os.environ["DATABASE_URL"])
|
|
216
|
+
# Run this during your FastAPI startup/lifespan initialization.
|
|
217
|
+
await create_async_sqlalchemy_siglume_schema(engine)
|
|
218
|
+
SessionLocal = async_sessionmaker(engine, expire_on_commit=False)
|
|
219
|
+
order_store = AsyncSQLAlchemySiglumeOrderStore(SessionLocal)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`create_sqlalchemy_siglume_schema(engine)` creates only SDRP-owned tables by
|
|
223
|
+
default. Use `include_orders_table=True` only for the sample `orders` table.
|
|
224
|
+
|
|
225
|
+
The adapters persist one active checkout attempt per order, reuse an unexpired
|
|
226
|
+
checkout URL on network retries, create a new attempt after expiry/failure,
|
|
227
|
+
record webhook event ids only after the order update/review write succeeds, and
|
|
228
|
+
keep duplicate deliveries from double-fulfilling an order.
|
|
229
|
+
|
|
230
|
+
## 6. Start your app and run sandbox verify
|
|
231
|
+
|
|
232
|
+
Start your product locally with the mounted checkout and webhook routes. Then,
|
|
233
|
+
in another terminal, start the sandbox and point it at your local webhook route:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npx siglume-sdrp sandbox \
|
|
237
|
+
--origin http://localhost:3000 \
|
|
238
|
+
--webhook-url http://localhost:3000/payments/webhooks/siglume
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Use the values it prints in your product `.env`:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
SIGLUME_ENV=sandbox
|
|
245
|
+
SIGLUME_API_BASE=http://127.0.0.1:8787/v1
|
|
246
|
+
SIGLUME_MERCHANT_AUTH_TOKEN=sandbox_merchant_token
|
|
247
|
+
SIGLUME_DIRECT_PAYMENT_MERCHANT=sandbox_merchant
|
|
248
|
+
SHOP_PUBLIC_ORIGIN=http://localhost:3000
|
|
249
|
+
SHOP_WEBHOOK_URL=http://localhost:3000/payments/webhooks/siglume
|
|
250
|
+
SIGLUME_WEBHOOK_SECRET=whsec_sandbox_local
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Restart your product with those values, keep the sandbox running, then verify
|
|
254
|
+
the local webhook delivery:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
npx siglume-check verify --sandbox
|
|
223
258
|
```
|
|
224
259
|
|
|
225
|
-
|
|
226
|
-
retries, record webhook event ids only after the order update/review write
|
|
227
|
-
succeeds, and keep duplicate deliveries from double-fulfilling an order.
|
|
260
|
+
`verify --sandbox` must pass before you switch to live credentials.
|
|
228
261
|
|
|
229
|
-
##
|
|
262
|
+
## 7. Start checkout from your frontend
|
|
230
263
|
|
|
231
264
|
Call your own server route:
|
|
232
265
|
|
|
@@ -238,12 +271,12 @@ curl -X POST https://api.your-product.example/payments/checkout/siglume/start \
|
|
|
238
271
|
|
|
239
272
|
Redirect the shopper to the returned `checkout_url`.
|
|
240
273
|
|
|
241
|
-
##
|
|
274
|
+
## 8. Done means
|
|
242
275
|
|
|
243
276
|
Your product is integrated when:
|
|
244
277
|
|
|
245
|
-
- `npx siglume-check
|
|
246
|
-
- `npx siglume-check
|
|
278
|
+
- `npx siglume-check verify --sandbox` passes against your local product,
|
|
279
|
+
- `npx siglume-check verify` passes against live Siglume credentials,
|
|
247
280
|
- your product has mounted checkout and webhook routes,
|
|
248
281
|
- your order database uses the SQL/ORM adapter or an equivalent transactional store,
|
|
249
282
|
- the signed webhook verifies against the raw body,
|
package/docs/sandbox.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SDRP Sandbox
|
|
2
2
|
|
|
3
|
-
Use the SDK sandbox
|
|
3
|
+
Use the SDK sandbox after your local checkout and webhook routes are mounted,
|
|
4
|
+
and before live Siglume credentials. It is a local
|
|
4
5
|
Siglume-compatible API server for product integration testing. It creates fake
|
|
5
6
|
checkout sessions, signs `direct_payment.confirmed` webhooks, records delivery
|
|
6
7
|
status, and never charges a wallet.
|
|
@@ -28,7 +29,7 @@ SIGLUME_WEBHOOK_SECRET=whsec_sandbox_local
|
|
|
28
29
|
Then verify the integration:
|
|
29
30
|
|
|
30
31
|
```bash
|
|
31
|
-
npx siglume-check
|
|
32
|
+
npx siglume-check verify --sandbox
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
Create a checkout through your own product route:
|
|
@@ -41,6 +42,14 @@ curl -X POST http://localhost:3000/payments/checkout/siglume/start \
|
|
|
41
42
|
|
|
42
43
|
Open the returned `checkout_url` and click the sandbox confirm button. Your
|
|
43
44
|
product should receive a signed webhook and mark the Standard order paid once.
|
|
45
|
+
If the confirm button or confirm endpoint is called again for the same sandbox
|
|
46
|
+
session, the sandbox returns the original confirmation result and does not send
|
|
47
|
+
another webhook. The sandbox checkout page follows the returned `redirect_url`
|
|
48
|
+
after a successful confirmation so your return page is exercised too.
|
|
49
|
+
|
|
50
|
+
The sandbox rejects invalid checkout input early: `amount_minor` must be a
|
|
51
|
+
positive integer, `currency` must be `JPY` or `USD`, and return URLs must be
|
|
52
|
+
HTTPS or local HTTP URLs.
|
|
44
53
|
|
|
45
54
|
Sandbox Micro / Nano behavior follows the same public classifications:
|
|
46
55
|
|
|
@@ -48,13 +57,29 @@ Sandbox Micro / Nano behavior follows the same public classifications:
|
|
|
48
57
|
- JPY 50-500 / USD 0.31-3.00 returns `metered_usage_accepted` with weekly Micro settlement fields.
|
|
49
58
|
- JPY 1-49 / USD 0.01-0.30 returns `metered_usage_accepted` with monthly Nano settlement fields.
|
|
50
59
|
|
|
60
|
+
For Micro / Nano sandbox sessions, the signed webhook and metered summary
|
|
61
|
+
endpoints include seller-borne accounting fields:
|
|
62
|
+
|
|
63
|
+
- `buyer_debit_minor = provider_gross_amount_minor`
|
|
64
|
+
- `protocol_fee_minor` is the Micro / Nano fixed protocol fee
|
|
65
|
+
- `provider_receivable_minor = provider_gross_amount_minor - protocol_fee_minor`
|
|
66
|
+
- `settlement_threshold_minor = 10000` for JPY 10,000 or USD 100.00 fixed-market thresholds
|
|
67
|
+
|
|
68
|
+
You can inspect the sandbox statement shape through the same SDK clients or raw
|
|
69
|
+
API paths:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
curl "http://127.0.0.1:8787/v1/sdrp/metered/provider/summary?plan_type=micro&token_symbol=JPYC"
|
|
73
|
+
curl "http://127.0.0.1:8787/v1/sdrp/metered/my-summary?plan_type=nano&token_symbol=USDC"
|
|
74
|
+
```
|
|
75
|
+
|
|
51
76
|
The generated route defaults to Standard-only, so Micro / Nano checkout returns
|
|
52
77
|
`METERED_INTEGRATION_REQUIRED` until you explicitly enable metered handling.
|
|
53
78
|
|
|
54
79
|
Before live launch:
|
|
55
80
|
|
|
56
|
-
- run `npx siglume-check
|
|
81
|
+
- run `npx siglume-check verify --sandbox` against the local product,
|
|
57
82
|
- run the same checkout path and confirm a sandbox webhook,
|
|
58
83
|
- switch to live `SIGLUME_MERCHANT_AUTH_TOKEN`, `SIGLUME_DIRECT_PAYMENT_MERCHANT`, `SHOP_PUBLIC_ORIGIN`, `SHOP_WEBHOOK_URL`, and `SIGLUME_WEBHOOK_SECRET`,
|
|
59
|
-
- run `npx siglume-check
|
|
84
|
+
- run `npx siglume-check verify` without `--sandbox`,
|
|
60
85
|
- confirm the live webhook subscription and signing secret are for the live product URL.
|
package/docs/troubleshooting.md
CHANGED
|
@@ -7,19 +7,22 @@ Siglume account contact.
|
|
|
7
7
|
|
|
8
8
|
## Hosted Checkout readiness
|
|
9
9
|
|
|
10
|
-
Hosted Checkout is enabled account by account during beta.
|
|
11
|
-
|
|
10
|
+
Hosted Checkout is enabled account by account during beta. Use `preflight`
|
|
11
|
+
before route mounting, then use `verify` after the webhook route is mounted and
|
|
12
|
+
your app is running:
|
|
12
13
|
|
|
13
14
|
```bash
|
|
14
|
-
npx siglume-check
|
|
15
|
-
npx siglume-check
|
|
15
|
+
npx siglume-check preflight
|
|
16
|
+
npx siglume-check verify --sandbox
|
|
17
|
+
npx siglume-check verify
|
|
16
18
|
```
|
|
17
19
|
|
|
18
|
-
Run
|
|
19
|
-
without `--sandbox` against live credentials.
|
|
20
|
+
Run `verify --sandbox` against the local SDK sandbox first. Then run `verify`
|
|
21
|
+
without `--sandbox` against live credentials. `verify` validates local
|
|
20
22
|
configuration, reads the merchant account, checks the active billing mandate,
|
|
21
23
|
confirms the webhook subscription, creates one unpaid expiring checkout session,
|
|
22
|
-
and queues a signed webhook test delivery.
|
|
24
|
+
and queues a signed webhook test delivery. `preflight` skips the delivery probe
|
|
25
|
+
so it can run before your webhook endpoint exists.
|
|
23
26
|
|
|
24
27
|
- The merchant account exists.
|
|
25
28
|
- The merchant billing mandate is active.
|
|
@@ -32,7 +35,8 @@ and queues a signed webhook test delivery.
|
|
|
32
35
|
- The signed webhook test delivery reaches the endpoint and returns success.
|
|
33
36
|
|
|
34
37
|
`--no-api` is only for local config smoke tests. `--no-probe` is a partial API
|
|
35
|
-
check and does not report readiness as ready.
|
|
38
|
+
check and does not report readiness as ready. Prefer `preflight` for the
|
|
39
|
+
intentional no-delivery phase.
|
|
36
40
|
|
|
37
41
|
If sandbox readiness fails, make sure `SIGLUME_ENV=sandbox`,
|
|
38
42
|
`SIGLUME_API_BASE=http://127.0.0.1:8787/v1`, `SHOP_PUBLIC_ORIGIN`, and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siglume/direct-request-payment",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.24",
|
|
4
4
|
"description": "SDK for the Siglume Direct Request Payment SDRP payment protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"siglume",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"prepack": "npm run build",
|
|
76
76
|
"prepublishOnly": "npm run build",
|
|
77
77
|
"typecheck": "tsc --noEmit",
|
|
78
|
-
"test": "vitest run",
|
|
78
|
+
"test": "npm run build && vitest run",
|
|
79
79
|
"pack:check": "npm pack --json"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|