@agenzo/merchant-cli 0.6.0 → 0.8.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm](https://img.shields.io/npm/v/@agenzo/merchant-cli.svg)](https://www.npmjs.com/package/@agenzo/merchant-cli) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../../LICENSE) ![node](https://img.shields.io/badge/node-%3E%3D22-brightgreen.svg)
4
4
 
5
5
  > **Merchant-fulfillment CLI** for the Agenzo platform — binary `agenzo-merchant-cli`.
6
- > Agents fulfill commerce services here. Each capability is a noun and the set grows over time — use `services` to discover what's available; today's capabilities are ride-hailing (`ride-elife`) and hotel booking (`hotel-redaug`).
6
+ > Agents fulfill commerce services here. Each capability is a noun and the set grows over time — use `services` to discover what's available; today's capabilities are ride-hailing (`ride-elife`), hotel booking (`hotel-redaug`), and flight booking (`flight-flink`).
7
7
 
8
8
  **[Overview](#overview)** · **[Features](#features)** · **[Quick Start](#quick-start)** · **[Global flags](#global-flags)** · **[Errors](#output-and-error-contract)** · **[Idempotency-Key](#idempotency-key)**
9
9
 
@@ -16,6 +16,7 @@
16
16
  - **`services`** (capability discovery): list what's currently available and how to call it — run this first to learn the current capability set.
17
17
  - **`ride-elife`** (ride-hailing): the full loop of quote → book → query/poll → cancel → list-orders.
18
18
  - **`hotel-redaug`** (hotel booking): search, find-destination, hotel-filters, list-cities, hotel-detail, quote, create-order, pay-order, get (status/poll), cancel, checkout, get-checkout, list-orders. Supports both **monthly_settlement** (on-account deduction) and **pay_per_call** (user pays via EVO using the order_id as the merchantTransID).
19
+ - **`flight-flink`** (flight booking): search, verify, create-order, pay-order, get-order, cancel, list-orders, and refund operations, including `upi_agent` payment-token passthrough.
19
20
 
20
21
  More fulfillment capabilities are added as new nouns over time; `services list` always reflects the current set.
21
22
 
@@ -104,10 +105,14 @@ agenzo-merchant-cli ride-elife cancel --api-key "$API_KEY" --yes \
104
105
  ### Hotel booking end-to-end example
105
106
 
106
107
  The core Agent loop is `search → quote → create-order → pay-order → get`. Amounts are decimal currency
107
- units (e.g. `320.00` = 320.00 yuan). `pay-order` takes only `--order-id`; the billing path is chosen
108
- server-side by the developer's `billing_mode`:
109
- - **monthly_settlement**: deducted from the monthly-settlement account.
110
- - **pay_per_call**: the user pays via shared EVO parameters using the `order_id` as the EVO merchantTransID; the platform verifies that payment for the same `order_id` before confirming.
108
+ units (e.g. `320.00` = 320.00 yuan). **`create-order` settles payment AND locks the room** — the funds
109
+ path is chosen server-side by the developer's `billing_mode`:
110
+
111
+ - **monthly_settlement**: the total is deducted from the developer's monthly-settlement account balance.
112
+ - **pay_per_call**: the total is authorized + captured on the developer's bound card via the platform's own EVO integration (server-side; no EVO parameters pass through this CLI).
113
+
114
+ `pay-order` takes only `--order-id` and triggers supplier confirmation / ticket issuance — funds were
115
+ already settled in `create-order`, so both billing modes use the same `pay-order` call.
111
116
 
112
117
  ```bash
113
118
  # 1. Search hotels by coordinates + stay dates (or use --destination-id from find-destination).
@@ -123,7 +128,7 @@ agenzo-merchant-cli hotel-redaug quote --api-key "$API_KEY" \
123
128
  --check-in 2026-02-10 --check-out 2026-02-12 \
124
129
  --adults 2 --room-num 1 --nationality CN
125
130
 
126
- # 3. Create Order (write op: locks rate, no charge; returns order_id + payable amount).
131
+ # 3. Create Order (write op: settles payment + locks the room; returns order_id + fc_order_code).
127
132
  agenzo-merchant-cli hotel-redaug create-order --api-key "$API_KEY" --yes \
128
133
  --product-token "$PRODUCT_TOKEN" \
129
134
  --total-amount 640.00 --currency CNY \
@@ -138,8 +143,8 @@ agenzo-merchant-cli hotel-redaug pay-order --api-key "$API_KEY" --yes \
138
143
  --order-id "$ORDER_ID" \
139
144
  --idempotency-key "hotel-pay-$(date +%s)"
140
145
 
141
- # 4b. Pay Order — pay_per_call path (user already paid via EVO using order_id
142
- # as the EVO merchantTransID). Same command, no other flag.
146
+ # 4b. Pay Order — pay_per_call path (funds already captured on the bound card in
147
+ # create-order; pay-order just triggers supplier confirmation). Same command.
143
148
  agenzo-merchant-cli hotel-redaug pay-order --api-key "$API_KEY" --yes \
144
149
  --order-id "$ORDER_ID" \
145
150
  --idempotency-key "hotel-pay-$(date +%s)"
@@ -182,6 +187,72 @@ agenzo-merchant-cli hotel-redaug get-checkout --api-key "$API_KEY" \
182
187
  --task-order-code "$TASK_ORDER_CODE" --watch --watch-interval 10 --watch-timeout 600
183
188
  ```
184
189
 
190
+ ### Flight booking end-to-end example (flight-flink)
191
+
192
+ The flow is `find-airport → search → verify → create-order → pay-order → get-order (poll until TICKETED)`.
193
+ Amounts are decimal currency units (e.g. `1200.00` = 1200.00 yuan). `create-order` locks the fare without
194
+ charging; `pay-order` settles + triggers ticketing (asynchronous — poll `get-order` until status=TICKETED).
195
+
196
+ ```bash
197
+ # 1. Resolve a city/airport keyword to IATA codes.
198
+ agenzo-merchant-cli flight-flink find-airport --api-key "$API_KEY" --keyword "beijing"
199
+
200
+ # 2. Search one-way flights (trip-type 1=OW, 2=RT, 3=multi-city).
201
+ # journeys always carries ALL legs; for multi-city, relay --journey-id from each result.
202
+ agenzo-merchant-cli flight-flink search --api-key "$API_KEY" \
203
+ --trip-type 1 \
204
+ --journeys '[{"date":"2026-08-01","origin":"PEK","originType":"2","destination":"SHA","destinationType":"2"}]'
205
+
206
+ # 3. Verify price (returns authoritative product_token; if price_changed, re-confirm with user).
207
+ agenzo-merchant-cli flight-flink verify --api-key "$API_KEY" \
208
+ --product-token "$PRODUCT_TOKEN"
209
+
210
+ # 4. Create Order (write op: locks fare, NO charge; status → AWAITING_PAYMENT).
211
+ agenzo-merchant-cli flight-flink create-order --api-key "$API_KEY" --yes \
212
+ --product-token "$VERIFIED_TOKEN" \
213
+ --total-amount 1200.00 --currency CNY \
214
+ --contact-name "ZHANG SAN" --contact-region 86 \
215
+ --contact-phone "13800138000" --contact-email "a@example.com" \
216
+ --passengers '[{"firstName":"SAN","lastName":"ZHANG","gender":"1","birthday":"1990-01-01","id_type":"1","id_number":"E12345678","nationality":"CN","type":"adult","expiration":"2032-01-01"}]' \
217
+ --idempotency-key "flight-create-$(date +%s)"
218
+
219
+ # 5. Pay Order (settles + triggers ticketing; status → PAID).
220
+ agenzo-merchant-cli flight-flink pay-order --api-key "$API_KEY" --yes \
221
+ --order-no "$ORDER_NO" \
222
+ --idempotency-key "flight-pay-$(date +%s)"
223
+
224
+ # 6. Poll status until TICKETED (ticket_infos populated). Single-pax ~100s, multi-pax ~150s+.
225
+ agenzo-merchant-cli flight-flink get-order --api-key "$API_KEY" --order-no "$ORDER_NO" \
226
+ --watch --watch-interval 10 --watch-timeout 300
227
+
228
+ # 7. List flight orders (local read, pagination + optional status filter).
229
+ agenzo-merchant-cli flight-flink list-orders --api-key "$API_KEY" --page 1 --page-size 20
230
+
231
+ # 8. Cancel an un-ticketed order (ticketed orders → use refund-apply instead).
232
+ agenzo-merchant-cli flight-flink cancel-order --api-key "$API_KEY" --yes \
233
+ --order-no "$ORDER_NO" \
234
+ --idempotency-key "flight-cancel-$(date +%s)"
235
+
236
+ # 9. Change (rebooking): search → apply → detail; confirm via pay-order or cancel via change-cancel.
237
+ agenzo-merchant-cli flight-flink change-search --api-key "$API_KEY" \
238
+ --order-no "$ORDER_NO" --date 2026-08-05 --passenger P1 --segment-id S1
239
+ agenzo-merchant-cli flight-flink change-apply --api-key "$API_KEY" --yes \
240
+ --order-no "$ORDER_NO" --passenger P1 --segment-id S1 \
241
+ --product-token "$CHANGE_TOKEN" \
242
+ --contact-name "ZHANG SAN" --contact-region 86 --contact-phone 138 --contact-email a@b.com \
243
+ --idempotency-key "flight-change-$(date +%s)"
244
+
245
+ # 10. Refund: apply → detail → confirm (--confirm 1 to proceed, 2 to cancel).
246
+ agenzo-merchant-cli flight-flink refund-apply --api-key "$API_KEY" --yes \
247
+ --order-no "$ORDER_NO" --passenger P1 --segment-id S1 \
248
+ --reason-type 1 \
249
+ --contact-name "ZHANG SAN" --contact-region 86 --contact-phone 138 --contact-email a@b.com \
250
+ --idempotency-key "flight-refund-$(date +%s)"
251
+ agenzo-merchant-cli flight-flink refund-confirm --api-key "$API_KEY" --yes \
252
+ --refund-order-no "$REFUND_ORDER_NO" --confirm 1 \
253
+ --idempotency-key "flight-refund-confirm-$(date +%s)"
254
+ ```
255
+
185
256
  ## Global flags
186
257
 
187
258
  | Flag | Default | Description |
@@ -257,13 +328,15 @@ merchant-cli **has no host / config commands** and does not govern environments.
257
328
 
258
329
  ## Machine-readable verb schema
259
330
 
260
- Every `ride-elife` and `hotel-redaug` verb supports `--help --format json`, emitting that verb's machine-readable schema (`cli` / `noun` / `verb` / `description` / `flags` / `response` / `example`, some with `error_recovery` / `polling`):
331
+ Every `ride-elife`, `hotel-redaug`, and `flight-flink` verb supports `--help --format json`, emitting that verb's machine-readable schema (`cli` / `noun` / `verb` / `description` / `flags` / `response` / `example`, some with `error_recovery` / `polling`):
261
332
 
262
333
  ```bash
263
334
  agenzo-merchant-cli ride-elife quote --help --format json
264
335
  agenzo-merchant-cli ride-elife book --help --format json
265
336
  agenzo-merchant-cli hotel-redaug quote --help --format json
266
337
  agenzo-merchant-cli hotel-redaug create-order --help --format json # write verb: error_recovery
338
+ agenzo-merchant-cli flight-flink search --help --format json
339
+ agenzo-merchant-cli flight-flink create-order --help --format json
267
340
  agenzo-merchant-cli hotel-redaug pay-order --help --format json # write verb: error_recovery
268
341
  agenzo-merchant-cli hotel-redaug get --help --format json # long-running: polling block
269
342
  ```