@agenzo/merchant-cli 0.8.2 → 0.8.4

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
@@ -2097,6 +2097,25 @@ var flightChangeCancelSchema = flightSchema(
2097
2097
  { status: { type: "int", description: "Terminal 5 (cancelled)." } },
2098
2098
  { command: "agenzo-merchant-cli flight-flink change-cancel --change-order-no C1 --idempotency-key k5", output_summary: "Change request cancelled." }
2099
2099
  );
2100
+ var flightChangePaySchema = flightSchema(
2101
+ "change-pay",
2102
+ "Pay a change request fee (charges like a normal order) and trigger change ticketing. flink pay type=1.",
2103
+ {
2104
+ "change-order-no": { type: "string", required: true, description: "Change order number." },
2105
+ "order-no": { type: "string", required: true, description: "Original order reference (ownership check)." },
2106
+ amount: { type: "float", required: true, description: "Change fee total (change-detail price_total, decimal units)." },
2107
+ currency: { type: "string", required: false, default: "USD", description: "ISO 4217 currency code." },
2108
+ "payment-method-id": { type: "string", required: false, description: "Optional bound-card id (EVO path)." },
2109
+ "payment-token-id": { type: "string", required: false, description: "Optional UPI network-token id (unionpay charge path)." },
2110
+ "idempotency-key": { type: "string", required: true, description: "Idempotency-Key header." }
2111
+ },
2112
+ {
2113
+ change_order_no: { type: "string", description: "Change order number." },
2114
+ status: { type: "string", description: "PROCESSING after payment." },
2115
+ payment_status: { type: "string", description: "SETTLED on success." }
2116
+ },
2117
+ { command: "agenzo-merchant-cli flight-flink change-pay --change-order-no C1 --order-no ffo_... --amount 120 --currency USD --idempotency-key k6", output_summary: "Change fee charged; change ticketing triggered." }
2118
+ );
2100
2119
  var flightRefundApplySchema = flightSchema(
2101
2120
  "refund-apply",
2102
2121
  "Submit a refund request. Returns refund_order_no, status 0 (pending review).",
@@ -3361,6 +3380,19 @@ function parseTips(raw) {
3361
3380
  }
3362
3381
  return parsed;
3363
3382
  }
3383
+ function parseCancellation(raw) {
3384
+ const INVALID = "--cancellation must be a JSON object.";
3385
+ let parsed;
3386
+ try {
3387
+ parsed = JSON.parse(raw);
3388
+ } catch {
3389
+ throw new CliError("PARAM_INVALID", INVALID);
3390
+ }
3391
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
3392
+ throw new CliError("PARAM_INVALID", INVALID);
3393
+ }
3394
+ return parsed;
3395
+ }
3364
3396
  function need7(value, flag) {
3365
3397
  if (value === void 0) {
3366
3398
  throw new CliError("PARAM_INVALID", `Missing required --${flag}.`);
@@ -3415,6 +3447,12 @@ function registerHotelCreateOrderCommand(parent, deps) {
3415
3447
  "--tips <json>",
3416
3448
  "\u5BA2\u6237\u81EA\u6D4B\u70B95 \u63D0\u793A\u4FE1\u606F: the chosen quote rate's tips as a JSON array [{title,text}]. Stored on the order for the order-detail page ONLY \u2014 platform-local, not sent upstream."
3417
3449
  ).option("--hotel-name <name>", "Hotel name (display-only, stored for order summary)").option(
3450
+ "--cancellation <json>",
3451
+ "Cancellation policy JSON from the chosen rate ({restriction_type,restriction_day,restriction_time,penalties[]}); stored on the order for cancellation gating and free-cancel deadline display. Not sent upstream."
3452
+ ).option(
3453
+ "--hotel-timezone <tz>",
3454
+ "Hotel timezone from quote (e.g. 'UTC-5'); stored to compute the free-cancellation deadline in hotel-local time."
3455
+ ).option(
3418
3456
  "--bed-type <code>",
3419
3457
  "Product bed-type code from the chosen quote rate's beds[].code (e.g. 'L000000' King / '1000000' Queen); forwarded verbatim to upstream createOrder bedType."
3420
3458
  ).option(
@@ -3465,6 +3503,8 @@ function registerHotelCreateOrderCommand(parent, deps) {
3465
3503
  if (opts.arriveTime !== void 0) body.arrive_time = opts.arriveTime;
3466
3504
  if (opts.specialRequests !== void 0) body.special_requests = opts.specialRequests;
3467
3505
  if (opts.tips !== void 0) body.tips = parseTips(opts.tips);
3506
+ if (opts.cancellation !== void 0) body.cancellation = parseCancellation(opts.cancellation);
3507
+ if (opts.hotelTimezone !== void 0) body.hotel_timezone = opts.hotelTimezone;
3468
3508
  if (opts.hotelName !== void 0) body.hotel_name = opts.hotelName;
3469
3509
  if (opts.bedType !== void 0) body.bed_type = opts.bedType;
3470
3510
  if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
@@ -4991,7 +5031,7 @@ function registerVerifyCommand(parent, deps) {
4991
5031
  // src/flight-flink/create-order.ts
4992
5032
  import { confirm as confirm6 } from "@inquirer/prompts";
4993
5033
  function registerCreateOrderCommand(parent, deps) {
4994
- const cmd = parent.command("create-order").description("Create a flight order without charging (locks the fare, await payment)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--product-token <token>", "Authoritative rate token from verify").option("--total-amount <amount>", "Verified total price in decimal units").option("--currency <currency>", "ISO 4217 currency code").option("--trip-type <n>", "1/2/3", "1").option("--contact-name <name>", "Booking contact name").option("--contact-region <code>", "Contact phone country code (no '+')").option("--contact-phone <phone>", "Booking contact phone").option("--contact-email <email>", "Booking contact email").option("--passengers <json>", "JSON array of passengers (gender/id_type are strings)").option("--payment-method-id <id>", "Optional bound-card id (pay_per_call only)").option("--idempotency-key <key>", "Forwarded verbatim as the Idempotency-Key header");
5034
+ const cmd = parent.command("create-order").description("Create a flight order without charging (locks the fare, await payment)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--product-token <token>", "Authoritative rate token from verify").option("--total-amount <amount>", "Verified total price in decimal units").option("--currency <currency>", "ISO 4217 currency code").option("--trip-type <n>", "1/2/3", "1").option("--contact-name <name>", "Booking contact name").option("--contact-region <code>", "Contact phone country code (no '+')").option("--contact-phone <phone>", "Booking contact phone").option("--contact-email <email>", "Booking contact email").option("--passengers <json>", "JSON array of passengers (gender/id_type are strings)").option("--payment-method-id <id>", "Optional bound-card id (pay_per_call only)").option("--payment-token-id <id>", "Optional UPI network-token id (unionpay charge path)").option("--idempotency-key <key>", "Forwarded verbatim as the Idempotency-Key header");
4995
5035
  attachSchemaHelp(cmd, flightCreateOrderSchema);
4996
5036
  cmd.action(async () => {
4997
5037
  const opts = cmd.optsWithGlobals();
@@ -5013,6 +5053,7 @@ function registerCreateOrderCommand(parent, deps) {
5013
5053
  passengers: jsonArray(need16(opts.passengers, "passengers"), "passengers")
5014
5054
  };
5015
5055
  if (opts.paymentMethodId !== void 0) body.payment_method_id = opts.paymentMethodId;
5056
+ if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
5016
5057
  if (!isYes) {
5017
5058
  const ok = await confirm6({
5018
5059
  message: `Create this flight order for ${totalAmount} ${currency}? This locks the fare but does NOT charge yet.`,
@@ -5344,8 +5385,65 @@ function registerChangeCancelCommand(parent, deps) {
5344
5385
  });
5345
5386
  }
5346
5387
 
5347
- // src/flight-flink/refund-apply.ts
5388
+ // src/flight-flink/change-pay.ts
5348
5389
  import { confirm as confirm11 } from "@inquirer/prompts";
5390
+ function registerChangePayCommand(parent, deps) {
5391
+ const cmd = parent.command("change-pay").description("Pay a change request fee (like a normal order) and trigger change ticketing").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--change-order-no <id>", "Change order number").option("--order-no <id>", "Original order reference (ownership check)").option("--amount <amount>", "Change fee total in decimal units (change-detail price_total)").option("--currency <currency>", "ISO 4217 currency code", "USD").option("--payment-method-id <id>", "Optional bound-card id (EVO path)").option("--payment-token-id <id>", "Optional UPI network-token id (unionpay charge path)").option("--idempotency-key <key>", "Forwarded verbatim as the Idempotency-Key header");
5392
+ attachSchemaHelp(cmd, flightChangePaySchema);
5393
+ cmd.action(async () => {
5394
+ const opts = cmd.optsWithGlobals();
5395
+ const format = resolveFormat(opts.format);
5396
+ const isYes = Boolean(opts.yes);
5397
+ const apiKey = await resolveApiKey(opts.apiKey);
5398
+ const changeOrderNo = need16(opts.changeOrderNo, "change-order-no");
5399
+ const orderNo = need16(opts.orderNo, "order-no");
5400
+ const amount = num8(opts.amount, "amount");
5401
+ const currency = need16(opts.currency, "currency");
5402
+ const body = {
5403
+ order_no: orderNo,
5404
+ amount,
5405
+ currency
5406
+ };
5407
+ if (opts.paymentMethodId !== void 0) body.payment_method_id = opts.paymentMethodId;
5408
+ if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
5409
+ if (!isYes) {
5410
+ const ok = await confirm11({
5411
+ message: `Pay change fee ${amount} ${currency} for change order ${changeOrderNo}? This charges the customer and triggers change ticketing.`,
5412
+ default: false
5413
+ });
5414
+ if (!ok) throw new CliError("CLIENT_ABORTED", "Change payment aborted by user.");
5415
+ }
5416
+ const idempotencyKey = await resolveIdempotencyKey(opts.idempotencyKey, {
5417
+ yes: isYes,
5418
+ commandPath: "flight-flink change-pay"
5419
+ });
5420
+ const spinner = format === "json" ? null : createSpinner("Paying change request...");
5421
+ const result = await deps.apiClient.post(
5422
+ `/flight/change/${encodeURIComponent(changeOrderNo)}/pay`,
5423
+ { type: "api-key", key: apiKey },
5424
+ body,
5425
+ { "Idempotency-Key": idempotencyKey }
5426
+ );
5427
+ spinner?.stop();
5428
+ if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
5429
+ await render2(
5430
+ result.data,
5431
+ opts.format,
5432
+ (d) => [
5433
+ Formatter.keyValue([
5434
+ ["Change order no", String(d.change_order_no ?? "-")],
5435
+ ["Status", String(d.status ?? "-")],
5436
+ ["Amount", `${d.amount ?? "-"} ${d.currency ?? ""}`.trim()],
5437
+ ["Payment status", String(d.payment_status ?? "-")]
5438
+ ]),
5439
+ Formatter.status("info", "Change fee charged; change ticketing triggered. Poll change-detail until SUCCESS.")
5440
+ ].join("\n\n")
5441
+ );
5442
+ });
5443
+ }
5444
+
5445
+ // src/flight-flink/refund-apply.ts
5446
+ import { confirm as confirm12 } from "@inquirer/prompts";
5349
5447
  function registerRefundApplyCommand(parent, deps) {
5350
5448
  const cmd = parent.command("refund-apply").description("Submit a refund request (returns refund_order_no, pending review)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--order-no <id>", "Our order reference").option("--passenger <code>", "passengerCode").option("--segment-id <ids>", "Comma-separated segment ids").option("--reason-type <n>", "Refund reason type code").option("--reason <text>", "Free-text reason").option("--contact-name <name>", "Contact name").option("--contact-region <code>", "Contact region").option("--contact-phone <phone>", "Contact phone").option("--contact-email <email>", "Contact email").option("--idempotency-key <key>", "Forwarded verbatim as the Idempotency-Key header");
5351
5449
  attachSchemaHelp(cmd, flightRefundApplySchema);
@@ -5366,7 +5464,7 @@ function registerRefundApplyCommand(parent, deps) {
5366
5464
  };
5367
5465
  if (opts.reason !== void 0) body.reason = opts.reason;
5368
5466
  if (!isYes) {
5369
- const ok = await confirm11({
5467
+ const ok = await confirm12({
5370
5468
  message: `Submit a refund request for order ${body.order_no}?`,
5371
5469
  default: false
5372
5470
  });
@@ -5410,7 +5508,7 @@ function registerRefundDetailCommand(parent, deps) {
5410
5508
  }
5411
5509
 
5412
5510
  // src/flight-flink/refund-confirm.ts
5413
- import { confirm as confirm12 } from "@inquirer/prompts";
5511
+ import { confirm as confirm13 } from "@inquirer/prompts";
5414
5512
  function registerRefundConfirmCommand(parent, deps) {
5415
5513
  const cmd = parent.command("refund-confirm").description('Confirm ("1") or cancel ("2") a refund').option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--refund-order-no <id>", "Refund order number").option("--confirm <flag>", '"1" confirm / "2" cancel').option("--idempotency-key <key>", "Forwarded verbatim as the Idempotency-Key header");
5416
5514
  attachSchemaHelp(cmd, flightRefundConfirmSchema);
@@ -5426,7 +5524,7 @@ function registerRefundConfirmCommand(parent, deps) {
5426
5524
  }
5427
5525
  if (!isYes) {
5428
5526
  const action = confirmFlag === "1" ? "confirm" : "cancel";
5429
- const ok = await confirm12({ message: `${action} refund ${refundOrderNo}?`, default: false });
5527
+ const ok = await confirm13({ message: `${action} refund ${refundOrderNo}?`, default: false });
5430
5528
  if (!ok) throw new CliError("CLIENT_ABORTED", "Refund confirmation aborted by user.");
5431
5529
  }
5432
5530
  const idempotencyKey = await resolveIdempotencyKey(opts.idempotencyKey, {
@@ -5679,6 +5777,7 @@ Key notes:
5679
5777
  registerChangeApplyCommand(flightCmd, deps);
5680
5778
  registerChangeDetailCommand(flightCmd, deps);
5681
5779
  registerChangeCancelCommand(flightCmd, deps);
5780
+ registerChangePayCommand(flightCmd, deps);
5682
5781
  registerRefundApplyCommand(flightCmd, deps);
5683
5782
  registerRefundDetailCommand(flightCmd, deps);
5684
5783
  registerRefundConfirmCommand(flightCmd, deps);