@agenzo/merchant-cli 0.5.2 → 0.7.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/dist/index.js CHANGED
@@ -41,6 +41,15 @@ var CODE_NUM = {
41
41
  QUOTE_EXPIRED: 4202,
42
42
  BOOKING_FAILED: 4203,
43
43
  CANCELLATION_NOT_ALLOWED: 4204,
44
+ PRICE_MISMATCH: 4205,
45
+ VEHICLE_CLASS_MISMATCH: 4206,
46
+ PAYMENT_METHOD_REQUIRED: 4207,
47
+ QUOTE_CACHE_UNAVAILABLE: 4208,
48
+ ARREARS_OUTSTANDING: 4209,
49
+ CONTACT_REQUIRED: 4210,
50
+ INVALID_PHONE: 4211,
51
+ SEAT_LIMIT_EXCEEDED: 4213,
52
+ RIDE_NOT_FOUND: 4212,
44
53
  NO_AVAILABILITY: 4301,
45
54
  PRICE_CHANGED: 4302,
46
55
  NAME_FORMAT_INVALID: 4303,
@@ -210,6 +219,15 @@ var STABLE_MESSAGE = {
210
219
  VEHICLE_UNAVAILABLE: "No vehicle is available for the requested trip. Please try a different time or class.",
211
220
  QUOTE_EXPIRED: "The quote has expired. Please request a new quote and retry.",
212
221
  BOOKING_FAILED: "The booking could not be completed. Please retry.",
222
+ PRICE_MISMATCH: "The price does not match the quote. Re-quote and use the exact amount from the quote response.",
223
+ VEHICLE_CLASS_MISMATCH: "The vehicle class does not match the quote. Use the vehicle class from the quote response.",
224
+ PAYMENT_METHOD_REQUIRED: "Pay-per-call billing requires an active payment method. Please add a card first.",
225
+ QUOTE_CACHE_UNAVAILABLE: "Quote cache is temporarily unavailable. Please request a new quote and retry.",
226
+ ARREARS_OUTSTANDING: "You have outstanding arrears. Please settle your balance before booking a new ride.",
227
+ CONTACT_REQUIRED: "Passenger contact information is required. Please provide a passenger name and phone number.",
228
+ INVALID_PHONE: "The passenger phone number is not valid. Please provide a valid international number.",
229
+ SEAT_LIMIT_EXCEEDED: "The number of child/infant/toddler seats exceeds the vehicle capacity. Reduce seats or choose a larger vehicle.",
230
+ RIDE_NOT_FOUND: "The ride order was not found or does not belong to you.",
213
231
  CANCELLATION_NOT_ALLOWED: "This order cannot be cancelled in its current state.",
214
232
  NO_AVAILABILITY: "No rooms available for the selected hotel and dates.",
215
233
  PRICE_CHANGED: "The price changed since the quote. Re-quote and confirm.",
@@ -1262,6 +1280,11 @@ var hotelCreateOrderSchema = {
1262
1280
  "contact-email": { type: "string", required: false, description: "Booking contact email" },
1263
1281
  "arrive-time": { type: "string", required: false, description: "Expected arrival time", constraints: "HH:mm, hotel local time" },
1264
1282
  "special-requests": { type: "string", required: false, description: "Free-text special requests (non-binding)" },
1283
+ "payment-token-id": {
1284
+ type: "string",
1285
+ required: false,
1286
+ description: "UPI Agent Pay only: payment token id from an already-completed UnionPay network-token capture (funds already charged). When set, the platform skips EVO preauth/capture and only locks the order."
1287
+ },
1265
1288
  "idempotency-key": {
1266
1289
  type: "string",
1267
1290
  required: true,
@@ -2335,10 +2358,10 @@ function registerListOrdersCommand(parent, deps) {
2335
2358
  // src/services/registry.ts
2336
2359
  var SERVICE_REGISTRY = [
2337
2360
  {
2338
- // service_id 是平台级不透明内部引用(svc_ 前缀 + ULID),不进 Agent 日常拼的命令
2339
- // ——Agent 拼命令用的是 cli_noun="ride-elife"。与后端
2340
- // services/merchant_service/discovery/catalog.py 的 RIDE_ELIFE_SERVICE_ID 保持一致。
2341
- service_id: "svc_01KWTPBWDH5YZ52H717BFVWZA8",
2361
+ // Agent-facing service_id = cli_noun(Agent 拼命令用这个标识)。
2362
+ // 平台级不透明内部 ULID: svc_01KWTPBWDH5YZ52H717BFVWZA8(与后端
2363
+ // services/merchant_service/discovery/catalog.py 的 RIDE_ELIFE_SERVICE_ID 对应)。
2364
+ service_id: "ride-elife",
2342
2365
  name: "Ride hailing (eLife)",
2343
2366
  description: "On-demand ride ordering: quote a fare, book it, poll status, and cancel.",
2344
2367
  category: "ride",
@@ -2360,7 +2383,7 @@ var SERVICE_REGISTRY = [
2360
2383
  }
2361
2384
  },
2362
2385
  {
2363
- service_id: "svc_01J0HT5REDAUG0001",
2386
+ service_id: "hotel-redaug",
2364
2387
  name: "Hotel booking (Redaug)",
2365
2388
  description: "International hotel booking via Redaug: search by location, real-time room/rate availability, two-step create-then-pay flow supporting monthly_settlement and pay_per_call (EVO) billing modes, cancel and partial check-out.",
2366
2389
  category: "hotel",
@@ -2415,7 +2438,7 @@ var SERVICE_REGISTRY = [
2415
2438
  }
2416
2439
  ];
2417
2440
  function findService(serviceId) {
2418
- return SERVICE_REGISTRY.find((s) => s.service_id === serviceId);
2441
+ return SERVICE_REGISTRY.find((s) => s.service_id === serviceId || s.cli_noun === serviceId);
2419
2442
  }
2420
2443
 
2421
2444
  // src/services/local-caps.ts
@@ -2997,6 +3020,9 @@ function formatCreateOrder(data) {
2997
3020
  }
2998
3021
  function registerHotelCreateOrderCommand(parent, deps) {
2999
3022
  const cmd = parent.command("create-order").description("Create a hotel order without charging (lock inventory, await payment)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--product-token <token>", "Chosen rate token from quote (rates[].product_token)").option("--total-amount <amount>", "Total stay price in decimal currency units (not cents)").option("--currency <currency>", "ISO 4217 currency code from the chosen rate").option("--price-items <json>", "Per-night price breakdown JSON array (copied verbatim from quote)").option("--check-in <date>", "Check-in date (YYYY-MM-DD, match quote)").option("--check-out <date>", "Check-out date (YYYY-MM-DD, strictly after check-in)").option("--room-num <n>", "Number of rooms (match quote)", "1").option("--adults <n>", "Adults per room (match quote)", "2").option("--children <n>", "Children per room (match quote)", "0").option("--nationality <code>", "Guest nationality (ISO country code)", "CN").option("--guest-name <name>", "Primary guest name").option("--contact-name <name>", "Booking contact name (may equal guest-name)").option("--contact-phone <phone>", "Booking contact phone number (digits)").option("--contact-country-code <code>", "Phone country calling code without '+'", "86").option("--contact-email <email>", "Booking contact email").option("--arrive-time <time>", "Expected arrival time (HH:mm, hotel local time)").option("--special-requests <text>", "Free-text special requests (non-binding)").option("--hotel-name <name>", "Hotel name (display-only, stored for order summary)").option(
3023
+ "--payment-token-id <id>",
3024
+ "UPI Agent Pay: payment token id from an already-completed UnionPay network-token capture. When set, the platform skips EVO preauth/capture and only locks the order + records this credential (funds already charged)."
3025
+ ).option(
3000
3026
  "--idempotency-key <key>",
3001
3027
  "Idempotency key forwarded verbatim as the Idempotency-Key header"
3002
3028
  );
@@ -3041,9 +3067,11 @@ function registerHotelCreateOrderCommand(parent, deps) {
3041
3067
  if (opts.arriveTime !== void 0) body.arrive_time = opts.arriveTime;
3042
3068
  if (opts.specialRequests !== void 0) body.special_requests = opts.specialRequests;
3043
3069
  if (opts.hotelName !== void 0) body.hotel_name = opts.hotelName;
3070
+ if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
3044
3071
  if (!isYes) {
3072
+ const chargeNote = opts.paymentTokenId !== void 0 ? "Payment has already been captured via UPI Agent Pay; this only locks the room." : "This locks the rate but does NOT charge anything yet.";
3045
3073
  const confirmed = await confirm3({
3046
- message: `Create this hotel order for ${totalAmount} ${currency} (check-in ${checkIn}, check-out ${checkOut})? This locks the rate but does NOT charge anything yet.`,
3074
+ message: `Create this hotel order for ${totalAmount} ${currency} (check-in ${checkIn}, check-out ${checkOut})? ${chargeNote}`,
3047
3075
  default: false
3048
3076
  });
3049
3077
  if (!confirmed) {