@develemit/commerce-server 0.8.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/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 @@
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;