@itpay/cli 2.0.1 → 2.0.3

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/README.md CHANGED
@@ -8,7 +8,7 @@ itpay readyz
8
8
  itpay docs show quickstart
9
9
  ```
10
10
 
11
- This test release defaults to `https://test.itpay.ai`. Set
11
+ The CLI defaults to the production app at `https://app.itpay.ai`. Set
12
12
  `ITPAY_BACKEND_URL` only when intentionally using another backend.
13
13
 
14
14
  ## Commands
@@ -36,7 +36,7 @@ This test release defaults to `https://test.itpay.ai`. Set
36
36
  - `itpay pay --checkout <id> --method alipay|wechatpay` — CLI escape hatch for operator/manual testing only; normal buyer flow opens the ItPay checkout page first
37
37
  - `itpay order <order_id>` — read one V3 order
38
38
  - `itpay orders [--limit 20] [--status <status>]` — list account-scoped orders (requires `ITPAY_BEARER_TOKEN`)
39
- - `itpay refund --order <id> --payment-intent <id> --amount-minor <n> --currency <code>` request a refund
39
+ - `itpay refund --order <id> [--reason <reason>]` — request a refund with an account-scoped `ITPAY_BEARER_TOKEN`; payment and amount are derived by the backend
40
40
 
41
41
  ## Hosts
42
42
 
@@ -54,7 +54,7 @@ Aliases: `tg` and `openclaw-telegram` map to `telegram`; `feishu_im` and `fs` ma
54
54
 
55
55
  ## Environment
56
56
 
57
- - `ITPAY_BACKEND_URL` — optional backend override (test-release default `https://test.itpay.ai`)
57
+ - `ITPAY_BACKEND_URL` — optional backend override (default `https://app.itpay.ai`)
58
58
  - `ITPAY_BEARER_TOKEN` — account-scoped session token (only needed for `orders`)
59
59
  - `ITPAY_AGENT_DEVICE_ID` — agent device id, used for cart/service execution quota identity and `client_context`
60
60
  - `ITPAY_CURRENCY` — checkout currency (default `CNY`)
@@ -62,8 +62,8 @@ export class BackendClient {
62
62
  return this.http.get(`/v1/me/orders?${qs}`, bearer ? { bearer } : {});
63
63
  }
64
64
  // --- Refund ---
65
- createRefund(orderID, input, idempotencyKey) {
66
- const options = idempotencyKey ? { idempotencyKey } : {};
65
+ createRefund(orderID, input, bearer, idempotencyKey) {
66
+ const options = { bearer, ...(idempotencyKey ? { idempotencyKey } : {}) };
67
67
  return this.http.post(`/v1/orders/${encodeURIComponent(orderID)}/refunds`, input, options);
68
68
  }
69
69
  // --- Service Execution ---
@@ -7,14 +7,11 @@ import { hintFor } from "../render/status.js";
7
7
  import { resolveOutput } from "../render/sink.js";
8
8
  export async function runRefund(backend, config, options) {
9
9
  const out = resolveOutput(options.output);
10
- const request = {
11
- payment_intent_id: options.paymentIntentID,
12
- amount_minor: options.amountMinor,
13
- currency: options.currency,
14
- ...(options.reason ? { reason: options.reason } : {}),
15
- ...(options.createdBy ? { created_by: options.createdBy } : {}),
16
- };
17
- const refund = await backend.createRefund(options.orderID, request, await operationID(config, `refund.create:${options.orderID}:${options.paymentIntentID}:${options.amountMinor}:${options.currency}`));
10
+ if (!config.bearerToken) {
11
+ throw new Error("ITPAY_BEARER_TOKEN is required to refund an account order");
12
+ }
13
+ const reason = options.reason?.trim() || "buyer_requested";
14
+ const refund = await backend.createRefund(options.orderID, { reason }, config.bearerToken, await operationID(config, `refund.create:${options.orderID}:${reason}`));
18
15
  out(renderRefund(refund) + "\n");
19
16
  out(`hint: ${hintFor("refund", refund.status)}\n`);
20
17
  }
package/dist/src/main.js CHANGED
@@ -24,7 +24,7 @@ program
24
24
  .name("itpay")
25
25
  .description("V3 ItPay CLI — checkout, payment, order, and refund commands")
26
26
  .option("--agent-type <type>", "agent runtime type used for device enrollment and client-specific guidance")
27
- .version("2.0.1");
27
+ .version("2.0.3");
28
28
  function withHost(value) {
29
29
  const host = normalizeHost(value);
30
30
  if (!host) {
@@ -428,21 +428,13 @@ program
428
428
  .command("refund")
429
429
  .description("Create a V3 refund request for an order")
430
430
  .requiredOption("--order <order_id>")
431
- .requiredOption("--payment-intent <payment_intent_id>")
432
- .requiredOption("--amount-minor <n>", "amount in minor units", (value) => Number.parseInt(value, 10))
433
- .requiredOption("--currency <currency>")
434
431
  .option("--reason <reason>")
435
- .option("--created-by <created_by>")
436
432
  .action(async (options) => {
437
433
  const config = loadConfig();
438
434
  const backend = newBackendClient(config);
439
435
  const refundOptions = {
440
436
  orderID: options.order,
441
- paymentIntentID: options.paymentIntent,
442
- amountMinor: options.amountMinor,
443
- currency: options.currency,
444
437
  ...(options.reason ? { reason: options.reason } : {}),
445
- ...(options.createdBy ? { createdBy: options.createdBy } : {}),
446
438
  };
447
439
  await runRefund(backend, config, refundOptions);
448
440
  });
@@ -8,9 +8,9 @@ import { HttpClient } from "../client/http.js";
8
8
  import { BackendClient } from "../client/backend.js";
9
9
  import { DeviceAuthority } from "./device_authority.js";
10
10
  import { OperationJournal } from "./operation_journal.js";
11
- export const DEFAULT_BASE_URL = "https://test.itpay.ai";
12
- export const CLI_VERSION = "2.0.1";
13
- export const API_CONTRACT_REVISION = "sha256:2c2829f4618c47bc505efc0ded853cf639d775585ba13aa23012197e39efa31f";
11
+ export const DEFAULT_BASE_URL = "https://app.itpay.ai";
12
+ export const CLI_VERSION = "2.0.3";
13
+ export const API_CONTRACT_REVISION = "sha256:d2870f3ee6fa4ee8a0a3ee75ae272a1a476935aae824123cf46607d62168f1f2";
14
14
  const CART_SESSION_DEFAULT_DIR = ".itpay-v3";
15
15
  const CART_SESSION_FILENAME = "cart.json";
16
16
  const OPERATION_JOURNAL_FILENAME = "operations.json";
@@ -29,7 +29,7 @@
29
29
  "env_vars": {
30
30
  "ITPAY_BACKEND_URL": {
31
31
  "required": false,
32
- "description": "Optional V3 backend override. This test release defaults to https://test.itpay.ai.",
32
+ "description": "Optional V3 backend override. The CLI defaults to https://app.itpay.ai.",
33
33
  "examples": ["http://localhost:18080", "https://test.itpay.ai"]
34
34
  },
35
35
  "ITPAY_BEARER_TOKEN": {
@@ -63,7 +63,7 @@
63
63
  "lark": "Use --host lark --target <open_id>. Same as feishu format."
64
64
  },
65
65
  "agent_rules": [
66
- "Use the built-in https://test.itpay.ai test-release default; override ITPAY_BACKEND_URL only for another deliberate environment.",
66
+ "Use the built-in https://app.itpay.ai production default; override ITPAY_BACKEND_URL only for another deliberate environment.",
67
67
  "Install globally with npm install -g @itpay/cli for all hosts.",
68
68
  "Identify the real runtime with --agent-type or ITPAY_AGENT_TYPE; do not invent a new type to obtain quota.",
69
69
  "Run `itpay install` without arguments to see all supported targets.",
@@ -13,10 +13,10 @@
13
13
  "required_state": {
14
14
  "needs": [
15
15
  "order_id for order or refund flows",
16
- "payment_intent_id for refund flows"
16
+ "ITPAY_BEARER_TOKEN for refund flows"
17
17
  ],
18
18
  "optional": [
19
- "ITPAY_BEARER_TOKEN for account order listing"
19
+ "refund reason; defaults to buyer_requested"
20
20
  ]
21
21
  },
22
22
  "commands": [
@@ -37,7 +37,7 @@
37
37
  },
38
38
  {
39
39
  "intent": "request a refund for an order",
40
- "command": "itpay refund --order <order_id> --payment-intent <payment_intent_id> --amount-minor <n> --currency CNY --reason buyer_requested",
40
+ "command": "ITPAY_BEARER_TOKEN=<account_scoped_token> itpay refund --order <order_id> --reason buyer_requested",
41
41
  "success_signal": "refund request id and refund status are printed"
42
42
  }
43
43
  ],
@@ -45,7 +45,7 @@
45
45
  "Use itpay order when you already know the exact order id.",
46
46
  "Use itpay orders only with an account-scoped bearer token. Missing or wrong scope should be surfaced as an error, not guessed away.",
47
47
  "Treat itpay pay as an operator escape hatch. The checkout handoff remains the preferred path.",
48
- "Refund amounts are minor units. For CNY, 100 means CNY 1.00.",
48
+ "Never ask the user or client to supply refund payment ids, amount, currency, buyer id, or actor; the backend derives them from the owned order.",
49
49
  "The refund response is the current source of truth; do not assume success locally."
50
50
  ],
51
51
  "forbidden": [
@@ -12,7 +12,7 @@
12
12
  "required_state": {
13
13
  "needs": [
14
14
  "itpay CLI installed",
15
- "test-release API at https://test.itpay.ai, or an intentional ITPAY_BACKEND_URL override",
15
+ "production app at https://app.itpay.ai, or an intentional ITPAY_BACKEND_URL override",
16
16
  "catalog item id, variant id, and offer id from `itpay catalog list`",
17
17
  "real agent runtime type supplied through --agent-type or ITPAY_AGENT_TYPE"
18
18
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itpay/cli",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "ItPay CLI for V3 checkout, payment, order, refund, and agent-facing render flows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@ itpay readyz
20
20
  itpay docs show quickstart
21
21
  ```
22
22
 
23
- This test release defaults to `https://test.itpay.ai`. Set `ITPAY_BACKEND_URL`
23
+ The CLI defaults to `https://app.itpay.ai`. Set `ITPAY_BACKEND_URL`
24
24
  only for an intentional override.
25
25
 
26
26
  Every commerce flow must identify the real runtime. Pass the global option