@itpay/cli 0.2.9 → 0.2.10

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
@@ -240,7 +240,7 @@ Payment QR rules:
240
240
  - Use `mobile_wallet_url` only as a human mobile fallback.
241
241
  - Do not generate your own QR from payment URLs.
242
242
  - If you know the current chat channel and `render_plan.platforms.<channel>` exists, use that branch before `render_plan.selected`.
243
- - In OpenClaw Telegram, send `render_plan.platforms.telegram.openclaw_message` with OpenClaw `message send --media ... --presentation ...`; do not put legacy inline media directives inside human prose.
243
+ - In OpenClaw Telegram, send `render_plan.platforms.telegram.openclaw_message.command_args` with `openclaw message send`; its `presentation.blocks[].buttons[]` uses native `text/url/callback_data`.
244
244
  - If the channel is unsupported, use `render_plan.selected.fallback` / plain chat. Do not rewrite the chosen plan into a custom table or omit the real URL.
245
245
  - If status is `payment_handoff_required`, `next` is the human reply step, not payment wait.
246
246
  - Treat only `payment_intent.verified` as payment success.
@@ -46,7 +46,7 @@
46
46
  "Do not rewrite the chosen render plan into a custom table. Use its text/markdown, media, links, and buttons as provided.",
47
47
  "If selected.links exists, include the real URL. Do not only show the link label.",
48
48
  "If selected.buttons exists but the current adapter cannot render native buttons, degrade to selected.links plus short text; do not fake payment success or skip the status check.",
49
- "In OpenClaw Telegram, prefer response.render_plan.platforms.telegram.openclaw_message: send its message/media/presentation through OpenClaw message send. Do not place legacy inline media directives inside prose; that fallback cannot render inline buttons.",
49
+ "In OpenClaw Telegram, prefer response.render_plan.platforms.telegram.openclaw_message.command_args with openclaw message send. Its presentation.blocks[].buttons[] uses native text/url/callback_data; do not simulate buttons in normal prose.",
50
50
  "In Codex or Claude Code app clients, send response.human_visible_markdown or response.render_plan.platforms.codex_app.markdown to the human first. Do not start a hidden long wait before the human-visible message is sent.",
51
51
  "For Telegram-style message clients, use response.render_plan.platforms.telegram: send photo media first, include links, and expose native buttons for refresh/status when the adapter supports them.",
52
52
  "For plain chat clients, show response.human_visible_markdown and stop unless the human asks you to check status or returns with a payment question.",
@@ -68,7 +68,7 @@
68
68
  "Show the returned payment QR exactly as provided before starting payment wait.",
69
69
  "Payment truth comes only from payment_intent.verified.",
70
70
  "Secure delivery goes to the human first; report redacted delivery status only.",
71
- "When a response includes render_plan, first use render_plan.platforms.<current channel> if it exists. If selected.platform is current_channel_required, selected.fallback is only for unsupported plain chat. In OpenClaw Telegram, use render_plan.platforms.telegram.openclaw_message instead of handwritten legacy media directive prose."
71
+ "When a response includes render_plan, first use render_plan.platforms.<current channel> if it exists. If selected.platform is current_channel_required, selected.fallback is only for unsupported plain chat. In OpenClaw Telegram, pass render_plan.platforms.telegram.openclaw_message.command_args to openclaw message send instead of handwritten prose."
72
72
  ],
73
73
  "forbidden": [
74
74
  "Do not call ops commands from the buyer path.",
@@ -389,16 +389,16 @@ function openclawTelegramMessage({ action = {}, media = [], links = [], buttons
389
389
  const text = action.kind === "payment_qr"
390
390
  ? "请扫码或点击链接完成支付。付款完成后点“我已付款,查询状态”,或直接回复“我已付款”。"
391
391
  : "请打开 ItPay 授权入口,完成后回到当前对话。";
392
- const presentationButtons = links.map((link) => ({ label: link.label, url: link.url }));
392
+ const presentationButtons = links.map((link) => openclawURLButton(link.label, link.url));
393
393
  if (action.kind === "payment_qr") {
394
394
  presentationButtons.push(
395
- { label: "支付遇到问题 / 刷新", action: { type: "command", command: "刷新付款二维码" } },
396
- { label: "我已付款,查询状态", action: { type: "command", command: "我已付款,查询状态" } }
395
+ openclawCallbackButton("支付遇到问题 / 刷新", "refresh_payment_qr", action),
396
+ openclawCallbackButton("我已付款,查询状态", "check_payment_status", action)
397
397
  );
398
398
  } else {
399
399
  for (const button of buttons) {
400
400
  if (button.url && !presentationButtons.some((item) => item.url === button.url)) {
401
- presentationButtons.push({ label: button.text || "打开链接", url: button.url });
401
+ presentationButtons.push(openclawURLButton(button.text || "打开链接", button.url));
402
402
  }
403
403
  }
404
404
  }
@@ -419,10 +419,23 @@ function openclawTelegramMessage({ action = {}, media = [], links = [], buttons
419
419
  message: text,
420
420
  media: mediaURL || undefined,
421
421
  presentation
422
- })
422
+ }),
423
+ callbacks: action.kind === "payment_qr" ? {
424
+ refresh_payment_qr: "收到 callback_data 后刷新或重新发送同一个 payment_intent 的付款入口。",
425
+ check_payment_status: "收到 callback_data 后运行 buyer payment wait/status,只信 payment_intent.verified。"
426
+ } : undefined
423
427
  });
424
428
  }
425
429
 
430
+ function openclawURLButton(text, url) {
431
+ return compactObject({ text, url });
432
+ }
433
+
434
+ function openclawCallbackButton(text, intent, action = {}) {
435
+ const id = action.payment_intent_id || action.id || "current";
436
+ return { text, callback_data: `itp:${intent}:${id}` };
437
+ }
438
+
426
439
  function selectedRenderPlatform(host = "") {
427
440
  const normalized = String(host || "").toLowerCase().replaceAll("-", "_");
428
441
  if (["codex", "codex_app", "codex_cli"].includes(normalized)) return "codex_app";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itpay/cli",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "ItPay CLI, buyer skill, and agent-readable docs for agent-native commerce.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -214,8 +214,9 @@ local QR image path for clients that cannot render remote SVG reliably. In
214
214
  agent/chat clients, prefer `--no-wait-payment`: if you know the current channel
215
215
  and `render_plan.platforms.<channel>` exists, use that branch first. In Codex
216
216
  or Claude Code app clients, send the platform markdown exactly. In OpenClaw
217
- Telegram, use `render_plan.platforms.telegram.openclaw_message` so media and
218
- native buttons are sent through the adapter. If `selected.platform` is
217
+ Telegram, pass `render_plan.platforms.telegram.openclaw_message.command_args`
218
+ to `openclaw message send` so media and native `text/url/callback_data` buttons
219
+ are sent through the adapter. If `selected.platform` is
219
220
  `current_channel_required`, `selected.fallback` is only for unsupported plain
220
221
  chat clients. Do not invent a table or rewrite the UI plan.
221
222