@relyon/kit 0.0.0-stage → 1.0.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/AGENTS.md +75 -0
- package/CHANGELOG.md +1053 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +239 -0
- package/README.md +117 -2
- package/dist/adapters/express.d.ts +39 -0
- package/dist/adapters/express.js +106 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +15 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +38 -0
- package/dist/agent-card.d.ts +14 -0
- package/dist/agent-card.js +58 -0
- package/dist/agent-docs.d.ts +36 -0
- package/dist/agent-docs.js +78 -0
- package/dist/agent-hooks.d.ts +66 -0
- package/dist/agent-hooks.js +280 -0
- package/dist/agents.d.ts +24 -0
- package/dist/agents.js +120 -0
- package/dist/api-key.d.ts +6 -0
- package/dist/api-key.js +33 -0
- package/dist/cache.d.ts +46 -0
- package/dist/cache.js +86 -0
- package/dist/cart-tokens.d.ts +31 -0
- package/dist/cart-tokens.js +58 -0
- package/dist/cart-transfer.d.ts +95 -0
- package/dist/cart-transfer.js +387 -0
- package/dist/catalog-enrichment.d.ts +6 -0
- package/dist/catalog-enrichment.js +71 -0
- package/dist/catalog-reads.d.ts +126 -0
- package/dist/catalog-reads.js +104 -0
- package/dist/catalog.d.ts +78 -0
- package/dist/catalog.js +288 -0
- package/dist/charge-claims.d.ts +11 -0
- package/dist/charge-claims.js +47 -0
- package/dist/check.d.ts +44 -0
- package/dist/check.js +152 -0
- package/dist/checklist-manifest.d.ts +72 -0
- package/dist/checklist-manifest.js +341 -0
- package/dist/checkout.d.ts +222 -0
- package/dist/checkout.js +353 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +727 -0
- package/dist/confirmation.d.ts +78 -0
- package/dist/confirmation.js +124 -0
- package/dist/context.d.ts +81 -0
- package/dist/context.js +10 -0
- package/dist/discovery.d.ts +151 -0
- package/dist/discovery.js +346 -0
- package/dist/doctor-cart-transfer.d.ts +33 -0
- package/dist/doctor-cart-transfer.js +186 -0
- package/dist/doctor-catalog.d.ts +8 -0
- package/dist/doctor-catalog.js +47 -0
- package/dist/doctor-evidence.d.ts +22 -0
- package/dist/doctor-evidence.js +57 -0
- package/dist/doctor-merchant.d.ts +48 -0
- package/dist/doctor-merchant.js +74 -0
- package/dist/doctor-source.d.ts +5 -0
- package/dist/doctor-source.js +142 -0
- package/dist/doctor-variants.d.ts +70 -0
- package/dist/doctor-variants.js +102 -0
- package/dist/doctor.d.ts +215 -0
- package/dist/doctor.js +1689 -0
- package/dist/events.d.ts +95 -0
- package/dist/events.js +200 -0
- package/dist/feed-mapping.d.ts +114 -0
- package/dist/feed-mapping.js +152 -0
- package/dist/feed-values.d.ts +13 -0
- package/dist/feed-values.js +40 -0
- package/dist/feeds.d.ts +104 -0
- package/dist/feeds.js +366 -0
- package/dist/identify.d.ts +102 -0
- package/dist/identify.js +124 -0
- package/dist/identity.d.ts +37 -0
- package/dist/identity.js +54 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +41 -0
- package/dist/init.d.ts +157 -0
- package/dist/init.js +912 -0
- package/dist/kit-config.d.ts +19 -0
- package/dist/kit-config.js +43 -0
- package/dist/kit-environment.d.ts +20 -0
- package/dist/kit-environment.js +32 -0
- package/dist/kit-updates.d.ts +47 -0
- package/dist/kit-updates.js +77 -0
- package/dist/kit-version-project.d.ts +18 -0
- package/dist/kit-version-project.js +214 -0
- package/dist/kit-version.d.ts +37 -0
- package/dist/kit-version.js +162 -0
- package/dist/kit.d.ts +516 -0
- package/dist/kit.js +1309 -0
- package/dist/layers/pages.d.ts +3 -0
- package/dist/layers/pages.js +5 -0
- package/dist/layers/payments.d.ts +7 -0
- package/dist/layers/payments.js +9 -0
- package/dist/layers/products.d.ts +10 -0
- package/dist/layers/products.js +13 -0
- package/dist/live.d.ts +13 -0
- package/dist/live.js +52 -0
- package/dist/mcp.d.ts +270 -0
- package/dist/mcp.js +312 -0
- package/dist/next-steps.d.ts +101 -0
- package/dist/next-steps.js +257 -0
- package/dist/order-pending.d.ts +57 -0
- package/dist/order-pending.js +127 -0
- package/dist/orders.d.ts +12 -0
- package/dist/orders.js +21 -0
- package/dist/payments-init.d.ts +19 -0
- package/dist/payments-init.js +70 -0
- package/dist/payments-routes.d.ts +54 -0
- package/dist/payments-routes.js +123 -0
- package/dist/payments.d.ts +165 -0
- package/dist/payments.js +192 -0
- package/dist/pnpm-workspace.d.ts +58 -0
- package/dist/pnpm-workspace.js +250 -0
- package/dist/policies.d.ts +111 -0
- package/dist/policies.js +317 -0
- package/dist/preview-hosts.d.ts +64 -0
- package/dist/preview-hosts.js +175 -0
- package/dist/private-config.d.ts +169 -0
- package/dist/private-config.js +820 -0
- package/dist/progress.d.ts +54 -0
- package/dist/progress.js +153 -0
- package/dist/protocol-inputs.d.ts +22 -0
- package/dist/protocol-inputs.js +151 -0
- package/dist/public-origin.d.ts +50 -0
- package/dist/public-origin.js +180 -0
- package/dist/refusals.d.ts +86 -0
- package/dist/refusals.js +157 -0
- package/dist/relay.d.ts +107 -0
- package/dist/relay.js +655 -0
- package/dist/release-notes.d.ts +2 -0
- package/dist/release-notes.js +290 -0
- package/dist/relyon-cart-tokens.d.ts +101 -0
- package/dist/relyon-cart-tokens.js +521 -0
- package/dist/relyon.d.ts +141 -0
- package/dist/relyon.js +238 -0
- package/dist/robots.d.ts +27 -0
- package/dist/robots.js +127 -0
- package/dist/rules.d.ts +144 -0
- package/dist/rules.js +347 -0
- package/dist/sdk/generated/public-api.d.ts +4816 -0
- package/dist/sdk/generated/public-api.js +1 -0
- package/dist/sdk/index.d.ts +24 -0
- package/dist/sdk/index.js +34 -0
- package/dist/sdk/signatures.d.ts +17 -0
- package/dist/sdk/signatures.js +33 -0
- package/dist/setup.d.ts +37 -0
- package/dist/setup.js +94 -0
- package/dist/signatures.d.ts +112 -0
- package/dist/signatures.js +443 -0
- package/dist/state.d.ts +185 -0
- package/dist/state.js +96 -0
- package/dist/store-payments.d.ts +48 -0
- package/dist/store-payments.js +143 -0
- package/dist/structured-fields.d.ts +26 -0
- package/dist/structured-fields.js +200 -0
- package/dist/templates.d.ts +19 -0
- package/dist/templates.js +193 -0
- package/dist/test-checkout-command.d.ts +32 -0
- package/dist/test-checkout-command.js +161 -0
- package/dist/test-checkout.d.ts +88 -0
- package/dist/test-checkout.js +292 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.js +18 -0
- package/dist/ucp-versions.d.ts +57 -0
- package/dist/ucp-versions.js +129 -0
- package/dist/util.d.ts +23 -0
- package/dist/util.js +68 -0
- package/dist/variants.d.ts +67 -0
- package/dist/variants.js +146 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.js +10 -0
- package/dist/waiting.d.ts +43 -0
- package/dist/waiting.js +57 -0
- package/dist/webhook-command.d.ts +48 -0
- package/dist/webhook-command.js +367 -0
- package/dist/webhook-registration.d.ts +47 -0
- package/dist/webhook-registration.js +69 -0
- package/dist/webmcp-schema.d.ts +14 -0
- package/dist/webmcp-schema.js +140 -0
- package/dist/webmcp-script.d.ts +3 -0
- package/dist/webmcp-script.js +176 -0
- package/dist/webmcp-store.d.ts +102 -0
- package/dist/webmcp-store.js +116 -0
- package/dist/webmcp.d.ts +242 -0
- package/dist/webmcp.js +866 -0
- package/dist/wire-names.d.ts +85 -0
- package/dist/wire-names.js +109 -0
- package/package.json +118 -4
- package/release-notes.json +290 -0
- package/scripts/install-notice.cjs +7 -0
- package/skills/relyon-agents/SKILL.md +327 -0
- package/skills/relyon-catalog/SKILL.md +499 -0
- package/skills/relyon-catalog/references/example-store.md +218 -0
- package/skills/relyon-checkout/SKILL.md +603 -0
- package/skills/relyon-checkout/references/checkout-flow.md +257 -0
- package/skills/relyon-checkout/references/checkout-page.md +315 -0
- package/skills/relyon-go-live/SKILL.md +344 -0
- package/skills/relyon-orders/SKILL.md +191 -0
- package/skills/relyon-orders/references/webhook-receiver.md +113 -0
- package/skills/relyon-payments/SKILL.md +117 -0
- package/skills/relyon-setup/SKILL.md +1061 -0
- package/skills/relyon-setup/references/QUICKSTART.md +239 -0
- package/skills/relyon-setup/references/durable-state.md +209 -0
- package/skills/relyon-setup/references/express-server.md +388 -0
- package/skills/relyon-setup/references/next-app-router.md +251 -0
- package/templates/common/STORE-README.md +67 -0
- package/templates/common/gitignore +8 -0
- package/templates/common/scripts/check-pricing.ts +22 -0
- package/templates/common/scripts/serve.mjs +13 -0
- package/templates/common/server/catalog.ts +79 -0
- package/templates/common/server/checkout-flow.d.ts +34 -0
- package/templates/common/server/pages.ts +184 -0
- package/templates/common/server/storage.ts +114 -0
- package/templates/common/server/store.ts +67 -0
- package/templates/express/server/express.ts +20 -0
- package/templates/express/tsconfig.build.json +6 -0
- package/templates/express/tsconfig.json +9 -0
- package/templates/next/app/[[...path]]/route.ts +24 -0
- package/templates/next/next.config.mjs +19 -0
- package/templates/next/tsconfig.json +12 -0
- package/templates/payments/express.ts +39 -0
- package/templates/payments/next.ts +38 -0
- package/templates/payments/node.ts +39 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: relyon-go-live
|
|
3
|
+
description: Get a @relyon/store-kit store ready for Live - what a Test run proves and doesn't, domain verification without routing, store policies, the processor account Relyon staff enter, the hand-over checklist, and the ordered Live activation steps once staff approve and the merchant asks.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Relyon go-live
|
|
7
|
+
|
|
8
|
+
<!-- BEGIN relyon-store-first-rules (generated from the shared rules source; edit it there) -->
|
|
9
|
+
Before building, ask the user: 'Do you want to (1) accept card payments in your own app — no Relyon product catalog or shopping pages; (2) also list products so AI shopping agents can find and buy them; or (3) also have Relyon's kit build the shopping pages for you?' Don't choose for them. Then follow the matching quickstart.
|
|
10
|
+
|
|
11
|
+
## Choose the integration before applying kit guidance
|
|
12
|
+
|
|
13
|
+
Payments: https://core.getrelyon.com/docs/payments-quickstart and `relyon-payments`.
|
|
14
|
+
Products and agent selling: https://core.getrelyon.com/docs (catalog,
|
|
15
|
+
agent checkout and AI visibility are optional additions).
|
|
16
|
+
Shopping pages: https://core.getrelyon.com/docs/quickstart and `relyon-setup`.
|
|
17
|
+
Never install the kit or build catalog, /cart or shopping pages for payments only.
|
|
18
|
+
The kit-specific rules below apply only after the user chooses shopping pages.
|
|
19
|
+
Live payments support human buyers and agents in every integration after staff
|
|
20
|
+
approval and processor onboarding, with existing payment safety checks intact.
|
|
21
|
+
Keep the secret key server-side as RELYON_API_KEY; only the publishable key is public.
|
|
22
|
+
|
|
23
|
+
When using the optional kit and uncertain about its version, run `npm view @relyon/store-kit version`.
|
|
24
|
+
Compare it with the store project's actually installed version; never downgrade.
|
|
25
|
+
Install the exact returned version with the project's package manager (npm install
|
|
26
|
+
--save-exact, pnpm add --save-exact, yarn add --exact, or bun add --exact), then run
|
|
27
|
+
`npx @relyon/store-kit doctor` afterward. If the lookup fails, say it is unavailable;
|
|
28
|
+
do not guess a latest version. Respect package-age holds without changing settings.
|
|
29
|
+
|
|
30
|
+
## Test setup and hand-over
|
|
31
|
+
|
|
32
|
+
- Start the store as a separate detached background process, using the host's
|
|
33
|
+
process manager or `setsid nohup npm run start >store.log 2>&1 < /dev/null &`.
|
|
34
|
+
Never run it in the agent's own foreground session. Stop a recorded PID;
|
|
35
|
+
never use a `pkill` pattern that can match the shell issuing it.
|
|
36
|
+
- On a public Test URL, call `kit.ensureDomain(hostname)` and then
|
|
37
|
+
`kit.verifyDomain(domain.hostname)` after the verification route is reachable.
|
|
38
|
+
Domain verification is not only for Live.
|
|
39
|
+
- Say exactly “Test mode: no real money moves” when handing over a Test store.
|
|
40
|
+
Never say shoppers can buy or pay for real while the store is in Test.
|
|
41
|
+
- Server-only `loadTestConfig` supplies both `apiKey` and `webhookSecret`.
|
|
42
|
+
Wire them into `relyon.apiKey` and `rules.webhookSecret`; never expose either
|
|
43
|
+
in browser code or agent prompts.
|
|
44
|
+
- With an environment API key, `webhook` never writes a secret file.
|
|
45
|
+
A set `RELYON_WEBHOOK_SECRET` in environment or dotenv overrides key-only
|
|
46
|
+
runtime recovery. Unset it, or update it in host settings, then restart.
|
|
47
|
+
Rotation exits 1 if an override differs from the current secret. Do not
|
|
48
|
+
treat that exit as a failed rotation: the endpoint may already be rotated.
|
|
49
|
+
Never read or print the override value; never ask for it in an agent prompt.
|
|
50
|
+
|
|
51
|
+
## Relyon store-first rules
|
|
52
|
+
|
|
53
|
+
These seven kit rules are identical in every Relyon skill. They apply only to the shopping-pages integration, never to payments-only apps.
|
|
54
|
+
|
|
55
|
+
1. Install `@relyon/store-kit@0.1.52` from npm and mount its handlers on the app's own server (Express `@relyon/store-kit/express`, Next.js `@relyon/store-kit/next`, Hono `@relyon/store-kit/hono`).
|
|
56
|
+
2. Catalog, cart and pricing stay in the app: the app owns `listProducts`, `getProduct`, `priceCart` and `createOrder`. Relyon never prices a cart. It charges exactly the final amount the store sends.
|
|
57
|
+
3. Checkout runs on the store's own domain. The only Relyon element in the shopper's browser is the card fields component. Card numbers never touch the app's code, server or logs.
|
|
58
|
+
4. The app calls Relyon only from its server, and only for payment, agent verification, fraud and limits, and recording.
|
|
59
|
+
5. Agent activity reporting stays on: never stub, disable or throttle-to-zero the kit's event reporting.
|
|
60
|
+
6. Start in Test. Live is enabled by Relyon staff, never approved by the agent; after staff approval, the agent activates it at the merchant's explicit instruction (set the env vars by name, redeploy, run the Live doctor for shopping pages) and never asks for or pastes a Live secret key. Build before requesting keys: missing credentials defer credential-dependent verification, never the local build. Show checkout as **waiting for a Test secret key**, record pending checks honestly, and resume them after configuring a real Test secret key without rebuilding. Never fabricate a credential, payment or order.
|
|
61
|
+
7. No Relyon-hosted checkout, redirect to a Relyon page, CNAME, proxy, forwarding Worker or `quote.request`/pricing endpoint.
|
|
62
|
+
|
|
63
|
+
### Test defaults — not merchant policy
|
|
64
|
+
|
|
65
|
+
| Item | Test default |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| Brand | Store name, unless the merchant supplies another brand. |
|
|
68
|
+
| MPN | SKU, unless the merchant supplies another MPN. |
|
|
69
|
+
| Stock | Available unless told otherwise; no invented inventory count. |
|
|
70
|
+
| Returns/support | Pending merchant items. Never invent them or submit placeholders as real policy data. |
|
|
71
|
+
|
|
72
|
+
Explicit merchant facts override these Test defaults. Proceed with local Test
|
|
73
|
+
building; ask before asserting missing merchant promises or syncing policies.
|
|
74
|
+
Never invent supplier claims, GTINs, tax treatment or policy terms. Pending
|
|
75
|
+
merchant information blocks only the checks that require it, not the build.
|
|
76
|
+
<!-- END relyon-store-first-rules -->
|
|
77
|
+
|
|
78
|
+
Reference only. Open a section when the quick start names it. Hand over in
|
|
79
|
+
Test; activate Live only after staff approval and the merchant's explicit
|
|
80
|
+
instruction.
|
|
81
|
+
|
|
82
|
+
Contract: the approved public v1 contract dated **2026-10-30**, at
|
|
83
|
+
`https://core.getrelyon.com/v1/openapi.yaml` (another deployment:
|
|
84
|
+
`<service origin>/v1/openapi.yaml`).
|
|
85
|
+
|
|
86
|
+
The canonical API base is `https://core.getrelyon.com/api`; `/v1/domains`
|
|
87
|
+
therefore means `https://core.getrelyon.com/api/v1/domains`. The download URL
|
|
88
|
+
above and the store's own routes are separate. Retain operator-confirmed API
|
|
89
|
+
base overrides for other deployments.
|
|
90
|
+
|
|
91
|
+
**In the Start here flow** (`relyon-setup`) this is step 6: review the
|
|
92
|
+
troubleshooting table, recheck policies and domain verification already wired
|
|
93
|
+
in setup, run the public scan, record unresolved blockers and give the
|
|
94
|
+
Test-to-Live hand-over. Return terms and support contacts come from the merchant: ask, and
|
|
95
|
+
check what `relyon-store-brief.md` says, but never write placeholder policies.
|
|
96
|
+
|
|
97
|
+
## What this error means
|
|
98
|
+
|
|
99
|
+
| You see | What it means | What to do |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| Doctor `PASS` | That check worked from outside, on the store's public URL. | Nothing. |
|
|
102
|
+
| Doctor `PENDING merchant` | Test-only missing merchant policy facts, or an exact missing webhook on a positively identified preview/loopback store. Agent checkout stays unavailable until merchant confirmation and policy setup. | Ask the listed questions; keep them separate from technical failures. Never invent return terms, contacts or webhook addresses. |
|
|
103
|
+
| Doctor `FAIL` | Something the store's own code, content or setup causes; the line names the route and what was wrong. | Fix it in the store and run the doctor again. |
|
|
104
|
+
| Doctor `UNVERIFIED` | The doctor couldn't check it (no `RELYON_API_KEY`, or Relyon couldn't be asked). It isn't a store failure, and it isn't a pass. | Read the line. Record it as open if it doesn't clear. |
|
|
105
|
+
| Doctor `N/A` | The check doesn't apply to this store (for example a feed that isn't selected). | Nothing. |
|
|
106
|
+
| Doctor: "Relyon's server answered with a web page instead of data" | Relyon's API sent a web page (or a 3xx status pointing at a sign-in or protection page) where data was expected. The line shows the URL and status. Relyon may be behind access protection or temporarily unavailable; the store and its network didn't cause it. | Don't change or publish the store again. Check that `RELYON_BASE_URL` (or `--base-url`) is `https://core.getrelyon.com/api`, try later, and if it stays, record it as an open item with the URL and status. |
|
|
107
|
+
| Doctor: Relyon's server had an error (HTTP 5xx) | Relyon is temporarily unavailable. | Try again in a few minutes. |
|
|
108
|
+
| Doctor: DNS failure, timeout, connection refused or blocked | The machine running the doctor couldn't reach Relyon. | Check that machine's internet access and the Relyon base URL. |
|
|
109
|
+
| `unavailable` at checkout (`service_unavailable`, HTTP 503, "Checkout is temporarily unavailable") | The kit couldn't get a usable answer from Relyon or couldn't read the store's agent rules, so it refused instead of guessing. Nothing was charged. | Check the server's `RELYON_API_KEY` and `RELYON_API_BASE_URL` and that the server can reach `core.getrelyon.com` over HTTPS; the server log names the failure. Never bypass the kit. |
|
|
110
|
+
| `PaymentUnavailableError` from `kit.cardFields` | Card fields couldn't be created. Nothing was charged. | Show "try again shortly"; same checks as above. |
|
|
111
|
+
| HTTP 503 on `/.well-known/ucp` | The kit couldn't read the store's UCP profile from Relyon (key, base URL or Relyon unreachable). | Same checks as above; the store's domain must also be added in Relyon. |
|
|
112
|
+
| HTTP 503 on `/.well-known/relyon-verification` | The kit couldn't read the store's domains from Relyon. After a failure it waits briefly before asking again. | Same checks as above, then request the file again a minute later. |
|
|
113
|
+
| HTTP 503 "Store discovery is temporarily unavailable." (llms.txt, the sitemap, feeds) | The store's own `catalog.source` callback threw. | Fix the callback; the server log has the error. |
|
|
114
|
+
| HTML instead of JSON from Relyon (in the app's own calls, or the kit reports an answer that isn't JSON) | The request didn't reach Relyon's API: the base URL is wrong (the service origin without `/api`, or the store's own URL), or Relyon answered with a sign-in or protection page. | Use `https://core.getrelyon.com/api` as the base. If it is already right, it is on Relyon's side: try later and record it. |
|
|
115
|
+
|
|
116
|
+
## Before approval, the agent's job ends in Test
|
|
117
|
+
|
|
118
|
+
Relyon staff enable Live for the merchant after their own review. Before that
|
|
119
|
+
approval, the agent's job is to leave a store that works end to end in Test
|
|
120
|
+
and a clear hand-over — never to flip Live.
|
|
121
|
+
|
|
122
|
+
- Never ask for, accept, paste or configure a `rly_live_…` key. The kit runs
|
|
123
|
+
Live only with a double opt-in, a Live key **and** `relyon.live: true`; a
|
|
124
|
+
Live key alone, or the option with a Test key, is refused when the kit is
|
|
125
|
+
created. The generated template sets neither `relyon.live` nor
|
|
126
|
+
`store.publicUrl`; whoever activates Live after staff review wires both deliberately. Live mode also needs
|
|
127
|
+
`STORE_PUBLIC_URL` to be an `https` origin naming one of the store's
|
|
128
|
+
hostnames, never `localhost`, an IP address or a `*.replit.dev` preview host.
|
|
129
|
+
Even then Relyon refuses Live payments until **Relyon staff** approve the
|
|
130
|
+
store and attach its processor account.
|
|
131
|
+
- `npx @relyon/store-kit doctor` checks Live only with `--live` (or
|
|
132
|
+
`RELYON_LIVE=true`) and a Live key; it has no `--allow-live` flag. The
|
|
133
|
+
separate `relyon` CLI refuses Live keys unless given `--allow-live`. Before
|
|
134
|
+
approval the agent passes none of these.
|
|
135
|
+
- Never change code to work around a Test-only refusal.
|
|
136
|
+
- When everything below is done, hand over to the merchant for the staff
|
|
137
|
+
review.
|
|
138
|
+
|
|
139
|
+
## Activating Live after staff approval
|
|
140
|
+
|
|
141
|
+
Staff approval gates Live; no agent action changes that. Once the merchant
|
|
142
|
+
says Live was approved and **explicitly asks you to activate it**, follow this
|
|
143
|
+
exact order:
|
|
144
|
+
|
|
145
|
+
1. The merchant creates the Live key on the dashboard's Developer page and
|
|
146
|
+
puts the value in the deployment environment as `RELYON_API_KEY`. You
|
|
147
|
+
reference the variable name only — never ask for, see or paste the value.
|
|
148
|
+
2. Set `RELYON_LIVE=true` so the generated template maps it to `relyon.live`.
|
|
149
|
+
3. Set `STORE_PUBLIC_URL` to the store's verified `https` domain.
|
|
150
|
+
4. Redeploy the store.
|
|
151
|
+
5. Run `npx @relyon/store-kit doctor --live` and interpret the result: Live
|
|
152
|
+
treats unmet requirements as FAIL, never merchant-pending. Fix each FAIL
|
|
153
|
+
in the store and re-run until it passes, then report the outcome.
|
|
154
|
+
|
|
155
|
+
Never activate Live without the merchant's explicit instruction.
|
|
156
|
+
|
|
157
|
+
## What a Test run proves
|
|
158
|
+
|
|
159
|
+
- The kit is mounted on the store's own server, before body parsers, and
|
|
160
|
+
answers its routes on the store's hostnames.
|
|
161
|
+
- `priceCart` prices carts that add up, refuses bad ones with `StoreRefusal`,
|
|
162
|
+
and the checkout page charges exactly the store's total through the card
|
|
163
|
+
fields and `kit.createPayment` (Test processor, no real money).
|
|
164
|
+
- `createOrder` runs once per succeeded payment, retries are safe, and
|
|
165
|
+
fulfillment reports reach Relyon for agent orders.
|
|
166
|
+
- Source-backed feeds, llms and sitemap share explicit agent visibility,
|
|
167
|
+
selected formats serve on the store, and product pages carry JSON-LD.
|
|
168
|
+
The synced index holds the products agent checkout can buy.
|
|
169
|
+
- Agent requests reach Relyon through the kit and agent events are reported.
|
|
170
|
+
|
|
171
|
+
## What it doesn't prove
|
|
172
|
+
|
|
173
|
+
- That real cards are approved: Test uses the Test processor or a mock
|
|
174
|
+
payment method. Never try a real card in Test.
|
|
175
|
+
- That Live processor settlement, payouts, fees or disputes work: those
|
|
176
|
+
depend on the merchant's processor account and Relyon staff.
|
|
177
|
+
- That agent platforms list the store: channel approval (Google, ChatGPT) is
|
|
178
|
+
the platforms' and Relyon's decision, outside the app.
|
|
179
|
+
- That feed export implies destination registration, acceptance, activation or
|
|
180
|
+
agent payment permission. Use real supplier facts; diagnostics can exclude
|
|
181
|
+
incomplete POD/dropship listings.
|
|
182
|
+
- That the app is ready for production traffic, unless `state`,
|
|
183
|
+
`events.store`, store orders/checkouts and source product data are durable
|
|
184
|
+
(plus `catalog.persistence` for the synced index; see `relyon-setup`).
|
|
185
|
+
- Sandbox access, generated keys, a passing `relyon doctor` and installed
|
|
186
|
+
skills do not make a store live.
|
|
187
|
+
|
|
188
|
+
## Domain verification: ownership, not routing
|
|
189
|
+
|
|
190
|
+
Agents and Relyon need to know the store owns its hostnames. Verification
|
|
191
|
+
proves ownership only. The store's traffic keeps going straight to the app;
|
|
192
|
+
nothing about the store's DNS routing or hosting changes.
|
|
193
|
+
|
|
194
|
+
- With the store's Test key, `kit.ensureDomain()` adds its configured primary
|
|
195
|
+
hostname and `kit.verifyDomain(domain.hostname)` requests verification using the returned domain's hostname. These helpers ship
|
|
196
|
+
in kit **0.1.0**; neither helper declares ownership itself.
|
|
197
|
+
- Equivalent requests use `catalog:write` and a fresh `Idempotency-Key` per action:
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
curl -X POST https://core.getrelyon.com/api/v1/domains \
|
|
201
|
+
-H "Authorization: Bearer $RELYON_API_KEY" \
|
|
202
|
+
-H 'Idempotency-Key: example-domain-create-1' \
|
|
203
|
+
-H 'Content-Type: application/json' -d '{"hostname":"shop.example.com"}'
|
|
204
|
+
curl -X POST https://core.getrelyon.com/api/v1/domains/DOMAIN_ID/verify \
|
|
205
|
+
-H "Authorization: Bearer $RELYON_API_KEY" \
|
|
206
|
+
-H 'Idempotency-Key: example-domain-verify-1'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Replace `DOMAIN_ID` with the returned row ID. The key needs `catalog:read`
|
|
210
|
+
to list/read domains and serve the HTTPS challenge. Live key domain management
|
|
211
|
+
is refused; dashboard admins can manage their environment's domains.
|
|
212
|
+
- Proof is one of:
|
|
213
|
+
- a **TXT record** with the value Relyon shows, on the hostname, or
|
|
214
|
+
- the **HTTPS file** `https://<hostname>/.well-known/relyon-verification`,
|
|
215
|
+
which the kit serves from the domain record its key can read.
|
|
216
|
+
- If the verification route fails, check `catalog:read`, the configured hostname
|
|
217
|
+
and HTTPS serving, or use the TXT proof. Fix the cause before retrying verification.
|
|
218
|
+
- Ignore any other value the domain response shows; the store never needs to
|
|
219
|
+
send traffic to Relyon.
|
|
220
|
+
- `/.well-known/ucp` serves the store's profile only after the domain is
|
|
221
|
+
verified.
|
|
222
|
+
|
|
223
|
+
## Store policies and channels
|
|
224
|
+
|
|
225
|
+
- Project space policies (`GET`/`PUT /v1/project_space_policies`: returns, support and optional
|
|
226
|
+
consumer notices) must be complete before any channel offers checkout. Incomplete
|
|
227
|
+
policies block every channel. Write the merchant's real policies, never
|
|
228
|
+
placeholder text.
|
|
229
|
+
- Completeness is unchanged: `returns`, `returns.policy_url` and `support`.
|
|
230
|
+
Shipping is **not** a required policy category. Optional shipping-policy,
|
|
231
|
+
privacy and terms links do not affect completeness. Actual checkout shipping
|
|
232
|
+
options, amounts and address rules still come from the store's `priceCart`.
|
|
233
|
+
- Live mode requires https policy URLs on the store's published domain. Plain
|
|
234
|
+
http on the loopback host is accepted in Test only; a Live kit refuses it and
|
|
235
|
+
the doctor says so.
|
|
236
|
+
- The kit's `policies` option exposes the merchant's real shipping/privacy/terms/contact
|
|
237
|
+
links and return scope on discovery and protocol surfaces. Construction and reads
|
|
238
|
+
never save them to Relyon: explicitly call `kit.replaceStorePolicies(input)`.
|
|
239
|
+
Local options fill omitted fields; caller values win; fields omitted from both
|
|
240
|
+
are cleared by whole-document replacement. Supply the real return cost, never
|
|
241
|
+
assume free returns. `defective_only` means only defective/damaged goods, not
|
|
242
|
+
ordinary returns; keep its window and conditions qualified to those goods.
|
|
243
|
+
- For own-brand goods, explicitly set `brand`, the store's SKU as `mpn`, and
|
|
244
|
+
`feed.ownBrand: true`; the kit never invents identifiers from the store name or
|
|
245
|
+
product ID. Made-to-order goods with no GTIN or MPN at all use
|
|
246
|
+
`feed.customGoods: true` alone. Own-brand goods made to order (no GTIN, but
|
|
247
|
+
the store's own SKU as MPN) may set both `feed.customGoods: true` and
|
|
248
|
+
`feed.ownBrand: true` with `brand` and `mpn`: since 0.1.1 that is an
|
|
249
|
+
own-brand item, not a conflict. Never set `customGoods` on a product with a
|
|
250
|
+
GTIN, and never set an attestation the merchant hasn't confirmed. See the
|
|
251
|
+
example-store reference bundled
|
|
252
|
+
with `relyon-catalog`; its identifiers are synthetic, not merchant facts.
|
|
253
|
+
- `GET /v1/channels` shows each agent channel's state. Pausing and resuming
|
|
254
|
+
are the merchant's choice; the agent doesn't enable channels.
|
|
255
|
+
|
|
256
|
+
## The processor account
|
|
257
|
+
|
|
258
|
+
Each store has its own processor account and merchant ID per environment.
|
|
259
|
+
**Relyon staff enter it**; the store can only read it with
|
|
260
|
+
`GET /v1/processor_account` (provider, status, the MID's last four
|
|
261
|
+
characters and the fee schedule, never credentials). Before staff enter it,
|
|
262
|
+
it reads `not_configured`. In Live, payments then answer
|
|
263
|
+
`processor_not_configured`. In Test, a sandbox without an account still takes
|
|
264
|
+
payments with the Test card fields' mock payment methods, so the Test purchase
|
|
265
|
+
works; if a Test payment does answer `processor_not_configured` (an account
|
|
266
|
+
staff entered but haven't finished), record the Test purchase as blocked. Either
|
|
267
|
+
way it is expected before hand-over: report it, don't work around it. The operation may answer 404 or 501 on deployments
|
|
268
|
+
that don't implement it yet.
|
|
269
|
+
|
|
270
|
+
## The public scan
|
|
271
|
+
|
|
272
|
+
After the Test purchase and every publish, first check that the store is
|
|
273
|
+
publicly reachable (some hosts publish privately or invite-only by default)
|
|
274
|
+
and that product images load from the public address, as `relyon-setup`'s
|
|
275
|
+
"After you deploy" describes. Then run the free readiness scan on the
|
|
276
|
+
store's public URL yourself (`POST https://core.getrelyon.com/api/scan` with
|
|
277
|
+
`{"url":"https://<host>"}`), or ask the merchant to run it at
|
|
278
|
+
`https://core.getrelyon.com/scan` (it needs the published HTTPS host, not a
|
|
279
|
+
development preview or `localhost`). It reads only what any
|
|
280
|
+
visitor or agent can see on the store's public pages and discovery files
|
|
281
|
+
(such as `llms.txt`, the sitemap and `robots.txt`), and it never buys
|
|
282
|
+
anything. Fix each item it reports as missing, then run the kit's doctor
|
|
283
|
+
again. Items it couldn't check aren't failures; retry later. A good scan is
|
|
284
|
+
not a Live approval.
|
|
285
|
+
|
|
286
|
+
## Hand-over checklist
|
|
287
|
+
|
|
288
|
+
Keep three separate lists: technical `FAIL` items to fix, `PENDING merchant`
|
|
289
|
+
questions for the merchant, and `UNVERIFIED` checks still to run. Copy the doctor's
|
|
290
|
+
deduplicated Merchant to-do questions without filling in answers. Default Test exit
|
|
291
|
+
zero means no technical failure was reported, not that checkout or Live is ready.
|
|
292
|
+
`doctor --strict` promotes merchant-pending items to FAIL; Live always treats the
|
|
293
|
+
same unmet requirements as FAIL. Server authorization, policy completeness and
|
|
294
|
+
Live approval are unchanged.
|
|
295
|
+
|
|
296
|
+
If policy pages still say **"to confirm with the merchant"**, identify them in the
|
|
297
|
+
hand-over. That is visible display text only, never policy synchronization data,
|
|
298
|
+
feed terms, structured policy data or API input. Agent checkout stays off until
|
|
299
|
+
confirmed policies are configured. Do not report a Test purchase as completed if
|
|
300
|
+
merchant policy requirements prevented it; explain the pending questions instead.
|
|
301
|
+
|
|
302
|
+
**Your final chat message lists the owner's to-dos.** End the task with a
|
|
303
|
+
message to the owner (not only a README or a file) that lists what they must
|
|
304
|
+
still do: confirm the store policies (the returns policy, plus any shipping,
|
|
305
|
+
privacy or terms pages; a
|
|
306
|
+
policy link to a page that doesn't exist is an "Owner to fill in" item), give a
|
|
307
|
+
support contact, connect their own domain, and get Live keys. Never tell the
|
|
308
|
+
owner shoppers can pay until checkout is live; in Test, say purchases are Test
|
|
309
|
+
purchases only.
|
|
310
|
+
|
|
311
|
+
Check failure recovery before hand-over: paid-but-unsaved orders say exactly
|
|
312
|
+
"Your payment went through. Your order is still being placed". Unknown payment
|
|
313
|
+
outcomes instead say the payment is being confirmed. Keep Pay disabled and
|
|
314
|
+
replay the same attempt, cart, payment method, reference and Idempotency-Key;
|
|
315
|
+
never start a second charge. Retain known success across reloads and lost
|
|
316
|
+
answers. Do not claim completion or fulfillment before a saved order exists.
|
|
317
|
+
|
|
318
|
+
Give the merchant, in plain words:
|
|
319
|
+
|
|
320
|
+
1. What works in Test, with the order IDs of a Test payment and its order
|
|
321
|
+
(the store's own order and Relyon's `ord_…`).
|
|
322
|
+
2. Every placeholder still marked "to confirm" (return terms, tax handling,
|
|
323
|
+
brand claims) that the merchant must answer before Live.
|
|
324
|
+
3. The hostnames to verify and the TXT values or the HTTPS file path.
|
|
325
|
+
4. Store policies to review, and the `kit.syncStorePolicies()` plan if it
|
|
326
|
+
still lists changes or needs.
|
|
327
|
+
5. Production settings still needed: durable state, the Live webhook signing
|
|
328
|
+
configuration, and the server environment the Live key will go into. In
|
|
329
|
+
Test an environment API key resolves webhook secrets at runtime without
|
|
330
|
+
writing a file; `RELYON_WEBHOOK_SECRET` is an optional explicit override.
|
|
331
|
+
Relyon staff or the
|
|
332
|
+
merchant set the Live key there; the agent never does.
|
|
333
|
+
6. Open items: anything `npx @relyon/store-kit doctor` reports as FAIL (or
|
|
334
|
+
`relyon doctor` for `keys`, `catalog` or `webhook`), anything the public
|
|
335
|
+
scan reports as missing, any operation the deployment didn't implement, and
|
|
336
|
+
every Start here step recorded as blocked, with its code or message.
|
|
337
|
+
7. How to ask for Live: the merchant, signed in to the Relyon dashboard
|
|
338
|
+
(`https://core.getrelyon.com`) with the account that claimed the sandbox,
|
|
339
|
+
requests go-live in its **Go live** section and shares this list with
|
|
340
|
+
Relyon staff if asked. The scan and the doctor don't start a review.
|
|
341
|
+
|
|
342
|
+
Then stop and wait for the staff decision. Once the merchant says Live was
|
|
343
|
+
approved and asks you to activate it, follow "Activating Live after staff
|
|
344
|
+
approval" above.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: relyon-orders
|
|
3
|
+
description: Record orders in a store app with @relyon/store-kit - the app's createOrder and its exactly-once claim, durable state, kit.reportFulfillment for shipped, delivered and canceled orders, and verifying Relyon webhooks on the kit's route.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Relyon orders
|
|
7
|
+
|
|
8
|
+
<!-- BEGIN relyon-store-first-rules (generated from the shared rules source; edit it there) -->
|
|
9
|
+
Before building, ask the user: 'Do you want to (1) accept card payments in your own app — no Relyon product catalog or shopping pages; (2) also list products so AI shopping agents can find and buy them; or (3) also have Relyon's kit build the shopping pages for you?' Don't choose for them. Then follow the matching quickstart.
|
|
10
|
+
|
|
11
|
+
## Choose the integration before applying kit guidance
|
|
12
|
+
|
|
13
|
+
Payments: https://core.getrelyon.com/docs/payments-quickstart and `relyon-payments`.
|
|
14
|
+
Products and agent selling: https://core.getrelyon.com/docs (catalog,
|
|
15
|
+
agent checkout and AI visibility are optional additions).
|
|
16
|
+
Shopping pages: https://core.getrelyon.com/docs/quickstart and `relyon-setup`.
|
|
17
|
+
Never install the kit or build catalog, /cart or shopping pages for payments only.
|
|
18
|
+
The kit-specific rules below apply only after the user chooses shopping pages.
|
|
19
|
+
Live payments support human buyers and agents in every integration after staff
|
|
20
|
+
approval and processor onboarding, with existing payment safety checks intact.
|
|
21
|
+
Keep the secret key server-side as RELYON_API_KEY; only the publishable key is public.
|
|
22
|
+
|
|
23
|
+
When using the optional kit and uncertain about its version, run `npm view @relyon/store-kit version`.
|
|
24
|
+
Compare it with the store project's actually installed version; never downgrade.
|
|
25
|
+
Install the exact returned version with the project's package manager (npm install
|
|
26
|
+
--save-exact, pnpm add --save-exact, yarn add --exact, or bun add --exact), then run
|
|
27
|
+
`npx @relyon/store-kit doctor` afterward. If the lookup fails, say it is unavailable;
|
|
28
|
+
do not guess a latest version. Respect package-age holds without changing settings.
|
|
29
|
+
|
|
30
|
+
## Test setup and hand-over
|
|
31
|
+
|
|
32
|
+
- Start the store as a separate detached background process, using the host's
|
|
33
|
+
process manager or `setsid nohup npm run start >store.log 2>&1 < /dev/null &`.
|
|
34
|
+
Never run it in the agent's own foreground session. Stop a recorded PID;
|
|
35
|
+
never use a `pkill` pattern that can match the shell issuing it.
|
|
36
|
+
- On a public Test URL, call `kit.ensureDomain(hostname)` and then
|
|
37
|
+
`kit.verifyDomain(domain.hostname)` after the verification route is reachable.
|
|
38
|
+
Domain verification is not only for Live.
|
|
39
|
+
- Say exactly “Test mode: no real money moves” when handing over a Test store.
|
|
40
|
+
Never say shoppers can buy or pay for real while the store is in Test.
|
|
41
|
+
- Server-only `loadTestConfig` supplies both `apiKey` and `webhookSecret`.
|
|
42
|
+
Wire them into `relyon.apiKey` and `rules.webhookSecret`; never expose either
|
|
43
|
+
in browser code or agent prompts.
|
|
44
|
+
- With an environment API key, `webhook` never writes a secret file.
|
|
45
|
+
A set `RELYON_WEBHOOK_SECRET` in environment or dotenv overrides key-only
|
|
46
|
+
runtime recovery. Unset it, or update it in host settings, then restart.
|
|
47
|
+
Rotation exits 1 if an override differs from the current secret. Do not
|
|
48
|
+
treat that exit as a failed rotation: the endpoint may already be rotated.
|
|
49
|
+
Never read or print the override value; never ask for it in an agent prompt.
|
|
50
|
+
|
|
51
|
+
## Relyon store-first rules
|
|
52
|
+
|
|
53
|
+
These seven kit rules are identical in every Relyon skill. They apply only to the shopping-pages integration, never to payments-only apps.
|
|
54
|
+
|
|
55
|
+
1. Install `@relyon/store-kit@0.1.52` from npm and mount its handlers on the app's own server (Express `@relyon/store-kit/express`, Next.js `@relyon/store-kit/next`, Hono `@relyon/store-kit/hono`).
|
|
56
|
+
2. Catalog, cart and pricing stay in the app: the app owns `listProducts`, `getProduct`, `priceCart` and `createOrder`. Relyon never prices a cart. It charges exactly the final amount the store sends.
|
|
57
|
+
3. Checkout runs on the store's own domain. The only Relyon element in the shopper's browser is the card fields component. Card numbers never touch the app's code, server or logs.
|
|
58
|
+
4. The app calls Relyon only from its server, and only for payment, agent verification, fraud and limits, and recording.
|
|
59
|
+
5. Agent activity reporting stays on: never stub, disable or throttle-to-zero the kit's event reporting.
|
|
60
|
+
6. Start in Test. Live is enabled by Relyon staff, never approved by the agent; after staff approval, the agent activates it at the merchant's explicit instruction (set the env vars by name, redeploy, run the Live doctor for shopping pages) and never asks for or pastes a Live secret key. Build before requesting keys: missing credentials defer credential-dependent verification, never the local build. Show checkout as **waiting for a Test secret key**, record pending checks honestly, and resume them after configuring a real Test secret key without rebuilding. Never fabricate a credential, payment or order.
|
|
61
|
+
7. No Relyon-hosted checkout, redirect to a Relyon page, CNAME, proxy, forwarding Worker or `quote.request`/pricing endpoint.
|
|
62
|
+
|
|
63
|
+
### Test defaults — not merchant policy
|
|
64
|
+
|
|
65
|
+
| Item | Test default |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| Brand | Store name, unless the merchant supplies another brand. |
|
|
68
|
+
| MPN | SKU, unless the merchant supplies another MPN. |
|
|
69
|
+
| Stock | Available unless told otherwise; no invented inventory count. |
|
|
70
|
+
| Returns/support | Pending merchant items. Never invent them or submit placeholders as real policy data. |
|
|
71
|
+
|
|
72
|
+
Explicit merchant facts override these Test defaults. Proceed with local Test
|
|
73
|
+
building; ask before asserting missing merchant promises or syncing policies.
|
|
74
|
+
Never invent supplier claims, GTINs, tax treatment or policy terms. Pending
|
|
75
|
+
merchant information blocks only the checks that require it, not the build.
|
|
76
|
+
<!-- END relyon-store-first-rules -->
|
|
77
|
+
|
|
78
|
+
Reference only. Open a section when the quick start names it; no whole-skill prerequisite.
|
|
79
|
+
|
|
80
|
+
Contract: the approved public v1 contract dated **2026-10-30**, at
|
|
81
|
+
`https://core.getrelyon.com/v1/openapi.yaml` (another deployment:
|
|
82
|
+
`<service origin>/v1/openapi.yaml`).
|
|
83
|
+
|
|
84
|
+
The canonical API base is `https://core.getrelyon.com/api`; `/v1/orders`
|
|
85
|
+
therefore means `https://core.getrelyon.com/api/v1/orders`. The download URL
|
|
86
|
+
above and the store's own routes are separate. Retain operator-confirmed API
|
|
87
|
+
base overrides for other deployments.
|
|
88
|
+
|
|
89
|
+
For the quick start's purchase evidence and handover, verify
|
|
90
|
+
exactly-once recording, existing-order recovery across retries and restarts,
|
|
91
|
+
and fulfilment reporting for a Test agent order with a real Relyon order ID.
|
|
92
|
+
Use the actual `payment.order_id`, including for a store-page purchase. If no
|
|
93
|
+
order ID is returned, record that specific blocker, never invent an ID or
|
|
94
|
+
claim fulfilment reporting passed.
|
|
95
|
+
|
|
96
|
+
## createOrder: once per succeeded payment
|
|
97
|
+
|
|
98
|
+
The app writes `createOrder(cart, payment)`; the kit calls it after a payment
|
|
99
|
+
succeeds, on the store's own checkout (`kit.createPayment`) and on a paid agent
|
|
100
|
+
checkout (`/ucp`, `/acp`, `/mcp`).
|
|
101
|
+
|
|
102
|
+
- `cart` is the store's own priced cart that was charged. `payment` is the
|
|
103
|
+
payment as Relyon reported it (`id`, `status: "succeeded"`, `amount`,
|
|
104
|
+
`currency`, and more).
|
|
105
|
+
- **Exactly once:** before calling it, the kit claims the payment ID in its
|
|
106
|
+
`state` store (`claimOrder`). Only the claim's winner calls `createOrder`.
|
|
107
|
+
If `createOrder` throws, the kit releases the claim (`releaseOrder`) so a
|
|
108
|
+
retry can create the order; `kit.createPayment` returns `orderError`.
|
|
109
|
+
- The claim is only as strong as the `state` store. The default is one
|
|
110
|
+
process's memory. In production, use a shared store whose `claimOrder` is an
|
|
111
|
+
atomic insert (see `relyon-setup`, `references/durable-state.md`).
|
|
112
|
+
- Make the app's own orders table unique on the payment ID as well, and return
|
|
113
|
+
the existing order when it is already there.
|
|
114
|
+
- Record what the app needs to fulfill: lines, totals, the payment ID and,
|
|
115
|
+
for agent checkouts, Relyon's order ID (below). Never store card data; the
|
|
116
|
+
payment carries only the card brand and last four digits, when present.
|
|
117
|
+
- Fulfill from the order `createOrder` wrote, never from a thank-you page
|
|
118
|
+
load or a browser message.
|
|
119
|
+
|
|
120
|
+
An example is in the `relyon-catalog` skill (`references/example-store.md`).
|
|
121
|
+
|
|
122
|
+
## Paid but the order is not saved
|
|
123
|
+
|
|
124
|
+
A succeeded payment is not a saved order. If `result.orderError` exists or
|
|
125
|
+
there is no saved `result.order.id`, preserve the payment evidence and say
|
|
126
|
+
exactly: "Your payment went through. Your order is still being placed".
|
|
127
|
+
Keep Pay disabled, link to order status, and recover with the same attempt,
|
|
128
|
+
cart, payment method, order reference and Idempotency-Key. A same-attempt
|
|
129
|
+
replay retries order placement without a second charge. Make `createOrder`
|
|
130
|
+
transactional and idempotent by payment ID; return the already saved order
|
|
131
|
+
when it exists. Do not claim completion or start fulfillment until the order
|
|
132
|
+
is saved.
|
|
133
|
+
Never start a second charge to recover an unsaved order.
|
|
134
|
+
|
|
135
|
+
`PaymentOutcomeUnknownError` is different: a charge may or may not have
|
|
136
|
+
succeeded. Preserve and replay the exact recorded attempt; say the payment
|
|
137
|
+
is being confirmed and not to pay again. Never say nothing was charged or
|
|
138
|
+
create an order based only on an uncertain answer. Once payment success is
|
|
139
|
+
known, a later outage must not erase that evidence.
|
|
140
|
+
|
|
141
|
+
## Report fulfillment
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
await kit.reportFulfillment(relyonOrderId, {
|
|
145
|
+
status: "shipped", // "shipped" | "delivered" | "canceled"
|
|
146
|
+
carrier: "ups",
|
|
147
|
+
tracking_number: "1Z999AA10123456784",
|
|
148
|
+
tracking_url: "https://www.ups.com/track?tracknum=1Z999AA10123456784",
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- Shopping agents and dispute evidence read it. Send each change as it
|
|
153
|
+
happens.
|
|
154
|
+
- The `Idempotency-Key` comes from the order and the update, so resending the
|
|
155
|
+
same report is safe. Relyon problems and outages are thrown: keep the
|
|
156
|
+
report in the app's own retry queue and send it again later.
|
|
157
|
+
- `relyonOrderId` is Relyon's order ID (`ord_…`). Relyon creates one for
|
|
158
|
+
every succeeded payment: an agent checkout (UCP, ACP or MCP, including one
|
|
159
|
+
handed off to the store's page) and a payment on the store's own checkout
|
|
160
|
+
page (`pay_…`). The kit passes it to `createOrder` as `payment.order_id`
|
|
161
|
+
(for agent checkouts today's server also uses it as `payment.id`). Save it
|
|
162
|
+
on the app's order and use it to report fulfillment.
|
|
163
|
+
- If a payment ever arrives without `order_id`, there is nothing to report for
|
|
164
|
+
it yet. Don't invent an order ID.
|
|
165
|
+
- Refunds: the contract has no operation for the app to report one. Relyon
|
|
166
|
+
records refunds it makes itself.
|
|
167
|
+
|
|
168
|
+
## Verify Relyon webhooks on the kit's route
|
|
169
|
+
|
|
170
|
+
The kit serves `/relyon/webhooks`. Register it as described in
|
|
171
|
+
`relyon-agents` and set `rules.webhookSecret` from the one-time `secret`.
|
|
172
|
+
On every delivery the kit:
|
|
173
|
+
|
|
174
|
+
- verifies the `Relyon-Signature` (or today's `X-Relyon-Signature`) header, an
|
|
175
|
+
HMAC-SHA256 over the exact raw body with a 300-second timestamp tolerance,
|
|
176
|
+
using a constant-time comparison,
|
|
177
|
+
- answers `400` to a missing or bad signature, and refuses everything when no
|
|
178
|
+
secret is configured,
|
|
179
|
+
- answers Relyon's `doctor.challenge` itself with the signed
|
|
180
|
+
`Relyon-Doctor-Acknowledgement`, so the doctor's `webhook` check passes with
|
|
181
|
+
the kit's route alone,
|
|
182
|
+
- refreshes agent rules on `agent_rules.updated` and answers `200` to other
|
|
183
|
+
valid events without acting on them.
|
|
184
|
+
|
|
185
|
+
So the kit's route is not where orders come from: `createOrder` is. If the app
|
|
186
|
+
needs other events (refunds, disputes), add the app's own receiver as shown in
|
|
187
|
+
[the webhook receiver reference](references/webhook-receiver.md); it answers
|
|
188
|
+
the doctor's challenge too.
|
|
189
|
+
|
|
190
|
+
Keep secrets apart: each endpoint has its own, Test and Live have their own,
|
|
191
|
+
and none of them is ever logged, sent to the browser or committed.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# The app's own webhook receiver (optional)
|
|
2
|
+
|
|
3
|
+
The kit's `/relyon/webhooks` route verifies every Relyon webhook, acts on
|
|
4
|
+
`agent_rules.updated` and answers the doctor's `doctor.challenge` itself (with
|
|
5
|
+
`RELYON_WEBHOOK_SECRET` set, or resolved at runtime from the store's
|
|
6
|
+
key when it is unset, in Test and Live). It answers other valid events with `200` and does
|
|
7
|
+
nothing else. For the doctor's `webhook` check, the kit's route is enough.
|
|
8
|
+
|
|
9
|
+
Add a receiver of the app's own only when the app needs other events (for
|
|
10
|
+
example `refund.succeeded` or `dispute.opened`). It is a separate endpoint
|
|
11
|
+
with its own secret, on the store's server, and it answers the challenge too.
|
|
12
|
+
The helpers below use only Web Crypto, so they run on Node 20+, Deno and edge
|
|
13
|
+
runtimes.
|
|
14
|
+
|
|
15
|
+
```js webhook-receiver.js
|
|
16
|
+
// Verifies Relyon webhooks over the exact raw bytes. Web Crypto only.
|
|
17
|
+
const utf8 = new TextEncoder();
|
|
18
|
+
const hex = (bytes) => [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
19
|
+
|
|
20
|
+
async function hmac(secret, data) {
|
|
21
|
+
const key = await crypto.subtle.importKey("raw", utf8.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
22
|
+
return hex(await crypto.subtle.sign("HMAC", key, data));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function constantTimeEqual(a, b) {
|
|
26
|
+
if (a.length !== b.length) return false;
|
|
27
|
+
let difference = 0;
|
|
28
|
+
for (let i = 0; i < a.length; i++) difference |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
29
|
+
return difference === 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** `t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">`, within 300 seconds. */
|
|
33
|
+
export async function verify(raw, header, secret, now = Math.floor(Date.now() / 1000)) {
|
|
34
|
+
if (!(raw instanceof Uint8Array) || typeof header !== "string" || !secret) return false;
|
|
35
|
+
const match = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header);
|
|
36
|
+
if (!match) return false;
|
|
37
|
+
const timestamp = Number(match[1]);
|
|
38
|
+
if (!Number.isSafeInteger(timestamp) || Math.abs(now - timestamp) > 300) return false;
|
|
39
|
+
const signed = new Uint8Array([...utf8.encode(`${match[1]}.`), ...raw]);
|
|
40
|
+
return constantTimeEqual(await hmac(secret, signed), match[2]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The doctor's challenge answer: no trailing newline. */
|
|
44
|
+
export function acknowledgement(secret, challenge) {
|
|
45
|
+
return hmac(secret, utf8.encode(`relyon.doctor.ack.v1\n${challenge.id}\n${challenge.challenge}\n${challenge.created}`));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A Web Request handler. `endpoint` is { secret, livemode: false }; `inbox.accept`
|
|
50
|
+
* durably stores the event once per event ID (a unique key) before returning.
|
|
51
|
+
*/
|
|
52
|
+
export async function receive(request, endpoint, inbox, now = Math.floor(Date.now() / 1000)) {
|
|
53
|
+
const raw = new Uint8Array(await request.arrayBuffer());
|
|
54
|
+
if (raw.byteLength > 256 * 1024) return new Response(null, { status: 413 });
|
|
55
|
+
const contractHeader = request.headers.get("Relyon-Signature");
|
|
56
|
+
const currentHeader = request.headers.get("X-Relyon-Signature");
|
|
57
|
+
if (contractHeader && currentHeader && contractHeader !== currentHeader) return new Response(null, { status: 400 });
|
|
58
|
+
if (!(await verify(raw, contractHeader ?? currentHeader, endpoint.secret, now))) return new Response(null, { status: 400 });
|
|
59
|
+
let event;
|
|
60
|
+
try {
|
|
61
|
+
event = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(raw));
|
|
62
|
+
} catch {
|
|
63
|
+
return new Response(null, { status: 400 });
|
|
64
|
+
}
|
|
65
|
+
if (event?.type === "doctor.challenge") {
|
|
66
|
+
const valid = event.object === "doctor_challenge" && /^evt_/.test(event.id ?? "")
|
|
67
|
+
&& Number.isSafeInteger(event.created) && Math.abs(now - event.created) <= 300
|
|
68
|
+
&& /^[0-9a-f]{64}$/.test(event.challenge ?? "") && event.livemode === endpoint.livemode;
|
|
69
|
+
if (!valid) return new Response(null, { status: 400 });
|
|
70
|
+
return new Response(null, { status: 204, headers: { "Relyon-Doctor-Acknowledgement": await acknowledgement(endpoint.secret, event) } });
|
|
71
|
+
}
|
|
72
|
+
if (typeof event?.id !== "string" || typeof event.type !== "string") return new Response(null, { status: 400 });
|
|
73
|
+
if (event.livemode !== undefined && event.livemode !== endpoint.livemode) return new Response(null, { status: 400 });
|
|
74
|
+
try {
|
|
75
|
+
await inbox.accept({ id: event.id, type: event.type, payload: event });
|
|
76
|
+
return new Response(null, { status: 204 });
|
|
77
|
+
} catch {
|
|
78
|
+
return new Response(null, { status: 503 }); // Relyon retries
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- Mount it before any JSON body parser: the signature covers the raw bytes.
|
|
84
|
+
- `inbox.accept` inserts into a table unique on the event ID and queues the
|
|
85
|
+
work in the same transaction. A duplicate delivery returns without queuing
|
|
86
|
+
again. Acknowledge only after the insert committed.
|
|
87
|
+
- Events can arrive more than once and out of order. Workers act idempotently
|
|
88
|
+
and read the current state instead of trusting arrival order.
|
|
89
|
+
- Today's server signs ordinary events with `X-Relyon-Signature` and may send
|
|
90
|
+
an older envelope (`createdAt`, no top-level `livemode`). Check a verified
|
|
91
|
+
Test delivery before relying on fields, and never fill in missing payment
|
|
92
|
+
data from unverified sources.
|
|
93
|
+
- `relyon listen` prints the event log for local development; those copies
|
|
94
|
+
are unsigned and are not proof of delivery. `relyon trigger <event-id>`
|
|
95
|
+
re-sends an existing Test event, with the same ID, to every enabled
|
|
96
|
+
endpoint.
|
|
97
|
+
|
|
98
|
+
## The doctor's webhook check with two endpoints
|
|
99
|
+
|
|
100
|
+
The doctor sends its challenge to one active endpoint, even one not
|
|
101
|
+
subscribed to the challenge. The contract names the endpoint with the
|
|
102
|
+
**lowest ID**; the deployed server (as of contract 2026-10-30) differs and
|
|
103
|
+
picks the most recently registered HTTPS endpoint. Until the two agree, don't
|
|
104
|
+
depend on which one: every active endpoint must answer.
|
|
105
|
+
The kit's route does, and so does the receiver above. Register this receiver
|
|
106
|
+
with its own events:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{ "url": "https://shop.example.com/webhooks/relyon-events", "events": ["refund.succeeded", "dispute.opened"] }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Keep each endpoint's secret separate (`RELYON_EVENTS_SECRET` for this one,
|
|
113
|
+
`RELYON_WEBHOOK_SECRET` for the kit's route).
|