@siglume/direct-request-payment 0.4.24 → 0.4.26
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 +26 -0
- package/README.md +5 -3
- 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/pricing.md +1 -1
- package/docs/quickstart-10-minutes.md +62 -5
- package/examples/hosted-checkout-python/pyproject.toml +1 -1
- package/package.json +19 -2
- package/templates/express/README.md +13 -5
- package/templates/express/siglume-order-store.dynamodb.ts +691 -0
- package/templates/express/siglume-order-store.firestore.ts +418 -0
- package/templates/express/siglume-order-store.mongodb.ts +431 -0
- package/templates/express/siglume-order-store.sql.ts +45 -4
|
@@ -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
|
|
226
|
-
checkout
|
|
227
|
-
|
|
228
|
-
|
|
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
|
|
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.
|
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.26",
|
|
4
4
|
"description": "SDK for the Siglume Direct Request Payment SDRP payment protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"siglume",
|
|
@@ -76,20 +76,37 @@
|
|
|
76
76
|
"prepublishOnly": "npm run build",
|
|
77
77
|
"typecheck": "tsc --noEmit",
|
|
78
78
|
"test": "npm run build && vitest run",
|
|
79
|
+
"prisma:generate:test": "prisma generate --schema test/prisma/schema.prisma",
|
|
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",
|
|
79
82
|
"pack:check": "npm pack --json"
|
|
80
83
|
},
|
|
81
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",
|
|
88
|
+
"@prisma/client": "^6.19.3",
|
|
82
89
|
"@types/express": "^5.0.6",
|
|
83
90
|
"@types/node": "^20.16.5",
|
|
91
|
+
"@types/pg": "^8.20.0",
|
|
84
92
|
"@types/sql.js": "^1.4.11",
|
|
93
|
+
"drizzle-orm": "^0.45.2",
|
|
85
94
|
"esbuild": "^0.28.1",
|
|
86
95
|
"express": "^5.2.1",
|
|
96
|
+
"mongodb": "^7.3.0",
|
|
97
|
+
"mysql2": "^3.22.5",
|
|
98
|
+
"pg": "^8.22.0",
|
|
99
|
+
"prisma": "^6.19.3",
|
|
100
|
+
"reflect-metadata": "^0.2.2",
|
|
101
|
+
"sequelize": "^6.37.8",
|
|
87
102
|
"sql.js": "^1.14.1",
|
|
88
103
|
"tsup": "^8.3.0",
|
|
104
|
+
"typeorm": "^1.0.0",
|
|
89
105
|
"typescript": "^5.6.3",
|
|
90
106
|
"vitest": "^4.1.9"
|
|
91
107
|
},
|
|
92
108
|
"overrides": {
|
|
93
|
-
"esbuild": "^0.28.1"
|
|
109
|
+
"esbuild": "^0.28.1",
|
|
110
|
+
"uuid": "^11.1.1"
|
|
94
111
|
}
|
|
95
112
|
}
|
|
@@ -40,11 +40,19 @@ app.use(express.json());
|
|
|
40
40
|
app.use("/payments", createSiglumeSdrpCheckoutRouter(siglumeOptions));
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
Use
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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. Run
|
|
48
|
+
`createSiglumeSdrpSqlSchema({ dialect: "postgres" })` once in a migration or
|
|
49
|
+
translate the returned SQL into your migration tool.
|
|
50
|
+
- `siglume-order-store.dynamodb.ts`: DynamoDB with conditional writes and
|
|
51
|
+
`TransactWrite`.
|
|
52
|
+
- `siglume-order-store.mongodb.ts`: MongoDB with unique indexes for the active
|
|
53
|
+
checkout attempt, challenge hash, and webhook event id.
|
|
54
|
+
- `siglume-order-store.firestore.ts`: Firestore transactions and single-field
|
|
55
|
+
challenge lookup.
|
|
48
56
|
|
|
49
57
|
Keep `processWebhookEventOnce()` transactional: record the webhook event as
|
|
50
58
|
processed only after the order update or review write succeeds. The generated
|