@develemit/commerce-server 0.7.0 → 0.9.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
@@ -18,16 +18,17 @@ management under `/admin`. Without it, no admin routes exist (404).
18
18
  files with `openStoredFile(dir, key)`, which returns `{ stream, contentType,
19
19
  size }` or `null` (answer 404).
20
20
 
21
- | Route | Purpose |
22
- | ---------------------------------------- | -------------------------------------------------------- |
23
- | `GET/POST /admin/products` | List all statuses / create (`adminProductInputSchema`) |
24
- | `GET /admin/products/counts` | `{ all, live, draft, sold, archived, incompleteDrafts }` |
25
- | `GET/PATCH /admin/products/:id` | Read / edit; `{ sold: true }` sets quantity to 0 |
26
- | `POST /admin/products/:id/images` | Multipart `file` (+ optional `alt`), 8MB max |
27
- | `PATCH /admin/products/:id/images/order` | `{ imageIds }`, every image exactly once |
28
- | `PATCH /admin/products/:id/images/:id` | `{ alt }` (trimmed, max 500); 404 for unknown image |
29
- | `DELETE /admin/products/:id/images/:id` | Removes the row and the stored file |
30
- | `GET/PUT /admin/shipping-rates` | `PUT` replaces the full set of rates |
21
+ | Route | Purpose |
22
+ | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
23
+ | `GET/POST /admin/products` | List all statuses / create (`adminProductInputSchema`) |
24
+ | `GET /admin/products/counts` | `{ all, live, draft, sold, archived, incompleteDrafts }` |
25
+ | `GET/PATCH /admin/products/:id` | Read / edit; `{ sold: true }` sets quantity to 0 |
26
+ | `DELETE /admin/products/:id` | Deletes a never-live draft with no order lines (204), its files and holds; else 409 `PRODUCT_NOT_DELETABLE` (`reason`) |
27
+ | `POST /admin/products/:id/images` | Multipart `file` (+ optional `alt`), 8MB max |
28
+ | `PATCH /admin/products/:id/images/order` | `{ imageIds }`, every image exactly once |
29
+ | `PATCH /admin/products/:id/images/:id` | `{ alt }` (trimmed, max 500); 404 for unknown image |
30
+ | `DELETE /admin/products/:id/images/:id` | Removes the row and the stored file |
31
+ | `GET/PUT /admin/shipping-rates` | `PUT` replaces the full set of rates |
31
32
 
32
33
  Stored image keys are `products/<productId>/<uuid>.<ext>` and are never
33
34
  overwritten, so their URLs are safe to cache forever. Serve `FileStorage` URLs
package/docs/payments.md CHANGED
@@ -58,6 +58,43 @@ buyer is charged the undiscounted price while the order records the discount.
58
58
  `duration: 'once'`, `max_redemptions: 1`) and passes it in `discounts`.
59
59
  `createFakeGateway` records the discount on `sessions`.
60
60
 
61
+ ## Sales tax (Stripe Tax)
62
+
63
+ Pass `tax` to `createStripeGateway` (or `resolvePayment(env, { tax })`):
64
+
65
+ ```ts
66
+ createStripeGateway({
67
+ secretKey,
68
+ webhookSecret,
69
+ tax: {
70
+ enabled: true,
71
+ behavior: 'exclusive',
72
+ shippingTaxCode: 'txcd_92010001',
73
+ },
74
+ });
75
+ ```
76
+
77
+ With tax on, Checkout Sessions get `automatic_tax: { enabled: true }` and a
78
+ `tax_behavior` (`exclusive` by default; `inclusive` for VAT-style prices) on
79
+ every line and shipping option. A `CheckoutLine.taxCode` is sent as the
80
+ product's `tax_code`. The completed-session webhook stores
81
+ `total_details.amount_tax` as the order's `taxCents`; `shippingCents` stays
82
+ pre-tax, so `subtotal - discount + shipping + tax = total`. The discount
83
+ applies before tax. Without the option, sessions are exactly as before.
84
+
85
+ A product can carry an optional `taxCode` (a Stripe tax code such as
86
+ `txcd_20010000`, see [Stripe's list](https://docs.stripe.com/tax/tax-categories)),
87
+ set through the admin API (`taxCode` on create and patch, `null` clears it) and
88
+ shown in `AdminProductFlow` when the host passes `taxCodes`. Checkout puts it on
89
+ that line; products without one use the account's default tax code. The public
90
+ catalog never exposes it. Migration `0011` adds `commerce_products.tax_code`.
91
+
92
+ The host sets up Stripe Tax in the Stripe dashboard (origin address and tax
93
+ registrations); the kit does neither.
94
+
95
+ For local checkout, `createFakeGateway({ tax: { rate: 0.0825 } })` taxes
96
+ merchandise less discount plus shipping, and `devCheckout` records it.
97
+
61
98
  ## Manual Stripe test-mode purchase
62
99
 
63
100
  Uses the playground apps in this repo and a Stripe account in test mode.
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "commerce_products" ADD COLUMN "published_at" timestamp with time zone;--> statement-breakpoint
2
+ UPDATE "commerce_products" SET "published_at" = "updated_at" WHERE "status" <> 'draft';
@@ -0,0 +1 @@
1
+ ALTER TABLE "commerce_orders" ADD COLUMN "tax_cents" integer DEFAULT 0 NOT NULL;
@@ -0,0 +1 @@
1
+ ALTER TABLE "commerce_products" ADD COLUMN "tax_code" text;