@develemit/commerce-server 0.4.0 → 0.6.0
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 +27 -0
- package/dist/index.d.ts +71 -2
- package/dist/index.js +382 -120
- package/dist/index.js.map +1 -1
- package/docs/admin.md +5 -2
- package/docs/payments.md +18 -1
- package/package.json +2 -2
package/docs/admin.md
CHANGED
|
@@ -9,8 +9,11 @@ management under `/admin`. Without it, no admin routes exist (404).
|
|
|
9
9
|
The kit owns no identity: check a session, token or header yourself.
|
|
10
10
|
- `storage` implements `FileStorage` (`put(key, stream, contentType)` and
|
|
11
11
|
`delete(key)`). Keys look like `products/<productId>/<uuid>.<ext>`.
|
|
12
|
-
`createMemoryStorage()` is for tests
|
|
13
|
-
`
|
|
12
|
+
`createMemoryStorage()` is for tests. `createDiskStorage({ dir, publicUrl })`
|
|
13
|
+
is a development-grade local disk store that rejects keys escaping `dir`
|
|
14
|
+
(`..`, absolute paths, encoded traversal, NUL bytes, symlinks out); serve its
|
|
15
|
+
files with `openStoredFile(dir, key)`, which returns `{ stream, contentType,
|
|
16
|
+
size }` or `null` (answer 404).
|
|
14
17
|
|
|
15
18
|
| Route | Purpose |
|
|
16
19
|
| ---------------------------------------- | ------------------------------------------------------ |
|
package/docs/payments.md
CHANGED
|
@@ -10,13 +10,30 @@ Two ship with the package:
|
|
|
10
10
|
- `createStripeGateway({ secretKey, webhookSecret })` loads `stripe` lazily, so
|
|
11
11
|
it's an optional peer. Refunds look up the session's PaymentIntent and call
|
|
12
12
|
`refunds.create` with the idempotency key.
|
|
13
|
-
- `createFakeGateway()` for tests
|
|
13
|
+
- `createFakeGateway()` for tests and local development. By default its
|
|
14
|
+
session URL is the success URL (see [Local checkout](#local-checkout-without-stripe)
|
|
15
|
+
for a click-through flow), and
|
|
14
16
|
`completed(sessionId)` / `expired(sessionId)` / `asyncPaid(sessionId)` /
|
|
15
17
|
`asyncFailed(sessionId)` return signed webhook bodies to
|
|
16
18
|
post to the webhook route. `refunds` lists the refunds it made (one per
|
|
17
19
|
key), `refundCalls` every call, and `failNextRefund()` makes the next one
|
|
18
20
|
throw.
|
|
19
21
|
|
|
22
|
+
## Local checkout without Stripe
|
|
23
|
+
|
|
24
|
+
Pass `devCheckout: true` (or `{ apiUrl: 'http://localhost:3301' }` when the
|
|
25
|
+
browser reaches the api on another origin) to `commercePlugin` while using the
|
|
26
|
+
fake gateway. Checkout then returns a session URL pointing at
|
|
27
|
+
`GET <prefix>/checkout/dev/:sessionId/complete`, which applies a paid
|
|
28
|
+
`checkout.completed` event through the same path the webhook uses (holds and
|
|
29
|
+
discount redemptions commit, `onOrderPaid` runs) and answers 302 to
|
|
30
|
+
`urls.success(sessionId)`. `?outcome=expired` releases the order instead and
|
|
31
|
+
redirects to `urls.cancel`. The route is only registered for the fake gateway,
|
|
32
|
+
only knows sessions created since the process started (404 otherwise), and
|
|
33
|
+
`commercePlugin` throws at registration when `NODE_ENV=production`. Gate the
|
|
34
|
+
option on `NODE_ENV !== 'production'` so one config works in every
|
|
35
|
+
environment.
|
|
36
|
+
|
|
20
37
|
## Discounts
|
|
21
38
|
|
|
22
39
|
A discount code is an amount off the merchandise subtotal, never shipping. The
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@develemit/commerce-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"file-type": "^22.2.0",
|
|
27
|
-
"@develemit/commerce-contracts": "0.
|
|
27
|
+
"@develemit/commerce-contracts": "0.6.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"drizzle-orm": "^0.45.0",
|