Opt-in gates and events for customers-only (wholesale) stores - #837
Open
vitorrgg wants to merge 6 commits into
Open
Opt-in gates and events for customers-only (wholesale) stores#837vitorrgg wants to merge 6 commits into
vitorrgg wants to merge 6 commits into
Conversation
… config Stores that must approve customers before selling can now subscribe to `customers-staffSignatureSet` and `customers-enabledSet` API events (mapped with `modified_fields`, same pattern as `products-priceSet`) and declare `passport.newCustomer` / `checkout.*` gates in config. - `parseEventName` moved to its own side-effect-free module with unit tests - new `CheckoutGatesConfig` and `PassportConfig` types on `config.get()` Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Customers auto-created on first social/email-link login are merged with
`config.passport.newCustomer` (e.g. `{ enabled: false }`), so approval-based
stores don't hand out purchase-enabled accounts by default. The issued token
now respects those `login`/`enabled` defaults like existing customers.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
With `config.checkout` set, `@checkout` can reject orders from unknown
customers or customers not enabled (`CKT804`), without staff approval
(`staff_signature`, `CKT805`) or below a minimum subtotal (`CKT806`).
Without the config nothing changes: unknown customers are still created.
- `readOrSaveCustomer` accepts `{ canCreate: false }` and returns null
- gates isolated in `customer-gates.ts` with unit tests
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Stores that hide prices (wholesale, quote-based) strip `price` from the SSR product doc; the structured data must not advertise `price: 0`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Rewrites declared in the store `conf/firebase.json` for functions that don't exist in the base config (e.g. a custom `/_api/<name>/**` endpoint) were appended after the `**` catch-all and never matched. They are now inserted right before it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`cloudcommerce deploy --only functions:<codebase>` (what CI runs when a single codebase changes) went without `--force`, so the first deploy of a pub/sub function with failure policy aborted with "Pass the --force option". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opt-in support for stores that only sell to registered/approved customers (wholesale, B2B). Nothing changes for stores without the new config keys.
customers-enabledSetandcustomers-staffSignatureSet(mapped withmodified_fields, likeproducts-priceSet);parseEventNameextracted to a side-effect-free module with tests;CheckoutGatesConfig/PassportConfigtypes onconfig.get().config.passport.newCustomeris merged into customers auto-created on first login (e.g.{ enabled: false }); the issued token respects thoselogin/enableddefaults.config.checkout.customersOnlyrejects unknown or not-enabled customers (CKT804),requireStaffSignature(CKT805) andminSubtotal(CKT806);readOrSaveCustomeraccepts{ canCreate: false }.offerswhen the product has no price > 0 (stores that strip prices from SSR must not advertiseprice: 0).conf/firebase.jsonare inserted before the SSR**catch-all instead of appended after it (they never matched).First consumer: the O Porto da Música wholesale store (
functions/config.jsonwithpassport.newCustomer,checkout.customersOnly,checkout.minSubtotal,apps.atacado).Test plan
turbo run buildfor types, firebase, passport, modules, storefront (31 tasks ok)packages/modules/tests/3-customer-gates.test.ts,packages/firebase/tests/parse-event-name.test.ts,packages/passport/tests/new-customer.test.ts(vitest, 11 tests)tsc -p tsconfig.test.json, eslint on changed files🤖 Generated with Claude Code