@siglume/direct-request-payment 0.4.25 → 0.4.27

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.
@@ -29,8 +29,8 @@ pip install siglume-direct-request-payment
29
29
 
30
30
  For FastAPI projects, the Python package supplies `init`, `preflight`, and
31
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.
32
+ CLI, so install Node.js 20.19+ or 22.12+ with npm as well when you want local
33
+ sandbox checkout verification.
34
34
 
35
35
  ## 1. Optional live preflight
36
36
 
@@ -177,6 +177,61 @@ const order_store = createPrismaSiglumeOrderStore(prisma, {
177
177
  });
178
178
  ```
179
179
 
180
+ For NoSQL products, install the driver you already use and choose the matching
181
+ adapter:
182
+
183
+ ```bash
184
+ # DynamoDB
185
+ npm install @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb
186
+
187
+ # MongoDB
188
+ npm install mongodb
189
+
190
+ # Firestore
191
+ npm install @google-cloud/firestore
192
+ ```
193
+
194
+ ```ts
195
+ // DynamoDB
196
+ import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
197
+ import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
198
+ import {
199
+ createDynamoDbSiglumeOrderStore,
200
+ createDynamoDbSiglumeTables,
201
+ } from "./siglume/siglume-order-store.dynamodb.js";
202
+
203
+ const dynamo = new DynamoDBClient({ region: "ap-northeast-1" });
204
+ const dynamoDoc = DynamoDBDocumentClient.from(dynamo, {
205
+ marshallOptions: { removeUndefinedValues: true, convertEmptyValues: true },
206
+ });
207
+ await createDynamoDbSiglumeTables({ client: dynamo, include_orders_table: false });
208
+ const order_store = createDynamoDbSiglumeOrderStore({ client: dynamoDoc });
209
+ ```
210
+
211
+ ```ts
212
+ // MongoDB
213
+ import { MongoClient } from "mongodb";
214
+ import {
215
+ createMongoSiglumeIndexes,
216
+ createMongoSiglumeOrderStore,
217
+ } from "./siglume/siglume-order-store.mongodb.js";
218
+
219
+ const mongo = new MongoClient(process.env.MONGODB_URI!);
220
+ await mongo.connect();
221
+ const db = mongo.db("shop");
222
+ await createMongoSiglumeIndexes({ db });
223
+ const order_store = createMongoSiglumeOrderStore({ db });
224
+ ```
225
+
226
+ ```ts
227
+ // Firestore
228
+ import { Firestore } from "@google-cloud/firestore";
229
+ import { createFirestoreSiglumeOrderStore } from "./siglume/siglume-order-store.firestore.js";
230
+
231
+ const db = new Firestore({ projectId: process.env.GOOGLE_CLOUD_PROJECT });
232
+ const order_store = createFirestoreSiglumeOrderStore({ db });
233
+ ```
234
+
180
235
  FastAPI:
181
236
 
182
237
  ```py
@@ -222,10 +277,11 @@ order_store = AsyncSQLAlchemySiglumeOrderStore(SessionLocal)
222
277
  `create_sqlalchemy_siglume_schema(engine)` creates only SDRP-owned tables by
223
278
  default. Use `include_orders_table=True` only for the sample `orders` table.
224
279
 
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.
280
+ The SQL, DynamoDB, MongoDB, Firestore, and SQLAlchemy adapters persist one
281
+ active checkout attempt per order, reuse an unexpired checkout URL on network
282
+ retries, create a new attempt after expiry/failure, record webhook event ids
283
+ only after the order update/review write succeeds, and keep duplicate
284
+ deliveries from double-fulfilling an order.
229
285
 
230
286
  ## 6. Start your app and run sandbox verify
231
287
 
@@ -278,7 +334,8 @@ Your product is integrated when:
278
334
  - `npx siglume-check verify --sandbox` passes against your local product,
279
335
  - `npx siglume-check verify` passes against live Siglume credentials,
280
336
  - your product has mounted checkout and webhook routes,
281
- - your order database uses the SQL/ORM adapter or an equivalent transactional store,
337
+ - your order database uses the SQL/ORM, DynamoDB, MongoDB, Firestore, or
338
+ SQLAlchemy adapter, or an equivalent transactional store,
282
339
  - the signed webhook verifies against the raw body,
283
340
  - `standard_settled` marks the order paid once,
284
341
  - a failed webhook handler is retried and duplicate webhook deliveries do not double-fulfill the order.
@@ -5,5 +5,5 @@ requires-python = ">=3.11"
5
5
  dependencies = [
6
6
  "Flask>=3.0,<4",
7
7
  "python-dotenv>=1.0,<2",
8
- "siglume-direct-request-payment>=0.4.25,<0.5",
8
+ "siglume-direct-request-payment>=0.4.27,<0.5",
9
9
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siglume/direct-request-payment",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "SDK for the Siglume Direct Request Payment SDRP payment protocol",
5
5
  "keywords": [
6
6
  "siglume",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "type": "module",
29
29
  "engines": {
30
- "node": ">=18"
30
+ "node": "^20.19.0 || >=22.12.0"
31
31
  },
32
32
  "sideEffects": false,
33
33
  "main": "./dist/index.cjs",
@@ -78,9 +78,13 @@
78
78
  "test": "npm run build && vitest run",
79
79
  "prisma:generate:test": "prisma generate --schema test/prisma/schema.prisma",
80
80
  "test:orm-matrix": "vitest run test/express-orm-matrix.integration.test.ts",
81
+ "test:nosql-matrix": "vitest run test/express-nosql-matrix.integration.test.ts",
81
82
  "pack:check": "npm pack --json"
82
83
  },
83
84
  "devDependencies": {
85
+ "@aws-sdk/client-dynamodb": "^3.1073.0",
86
+ "@aws-sdk/lib-dynamodb": "^3.1073.0",
87
+ "@google-cloud/firestore": "^8.6.0",
84
88
  "@prisma/client": "^6.19.3",
85
89
  "@types/express": "^5.0.6",
86
90
  "@types/node": "^20.16.5",
@@ -89,6 +93,7 @@
89
93
  "drizzle-orm": "^0.45.2",
90
94
  "esbuild": "^0.28.1",
91
95
  "express": "^5.2.1",
96
+ "mongodb": "6.21.0",
92
97
  "mysql2": "^3.22.5",
93
98
  "pg": "^8.22.0",
94
99
  "prisma": "^6.19.3",
@@ -96,7 +101,7 @@
96
101
  "sequelize": "^6.37.8",
97
102
  "sql.js": "^1.14.1",
98
103
  "tsup": "^8.3.0",
99
- "typeorm": "^1.0.0",
104
+ "typeorm": "0.3.29",
100
105
  "typescript": "^5.6.3",
101
106
  "vitest": "^4.1.9"
102
107
  },
@@ -40,11 +40,24 @@ app.use(express.json());
40
40
  app.use("/payments", createSiglumeSdrpCheckoutRouter(siglumeOptions));
41
41
  ```
42
42
 
43
- Use `siglume-order-store.sql.ts` for a durable database-backed adapter. It
44
- supports Prisma, TypeORM, Sequelize, Drizzle, and any driver that can implement
45
- the small `SiglumeSqlExecutor` interface. Run
46
- `createSiglumeSdrpSqlSchema({ dialect: "postgres" })` once in a migration or
47
- translate the returned SQL into your migration tool.
43
+ Use one of the durable database-backed adapters before opening checkout to
44
+ users:
45
+
46
+ - `siglume-order-store.sql.ts`: Prisma, TypeORM, Sequelize, Drizzle, or any
47
+ driver that can implement the small `SiglumeSqlExecutor` interface. For an
48
+ existing product database, run
49
+ `createSiglumeSdrpSqlSchema({ dialect: "postgres", include_orders_table: false })`
50
+ once in a migration or translate the returned SQL into your migration tool.
51
+ Your own order table must expose the mapped `id`, `amount_minor`, and
52
+ `currency` columns. `status` and `updated_at` are optional but recommended
53
+ when you want the adapter to write paid/fulfilled state back to your table.
54
+ Use `include_orders_table: true` only for the sample `orders` table.
55
+ - `siglume-order-store.dynamodb.ts`: DynamoDB with conditional writes and
56
+ `TransactWrite`.
57
+ - `siglume-order-store.mongodb.ts`: MongoDB with unique indexes for the active
58
+ checkout attempt, challenge hash, and webhook event id.
59
+ - `siglume-order-store.firestore.ts`: Firestore transactions and single-field
60
+ challenge lookup.
48
61
 
49
62
  Keep `processWebhookEventOnce()` transactional: record the webhook event as
50
63
  processed only after the order update or review write succeeds. The generated