@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/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; a local-disk example lives in
13
- `apps/playground-api/src/storage.ts`.
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. Its session URL is the success URL, and
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.4.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.4.0"
27
+ "@develemit/commerce-contracts": "0.6.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "drizzle-orm": "^0.45.0",