@agenzo/merchant-cli 0.8.13 → 0.8.15

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
@@ -1519,9 +1519,24 @@ var hotelPayOrderSchema = {
1519
1519
  cli: CLI_NAME,
1520
1520
  noun: HOTEL_NOUN,
1521
1521
  verb: "pay-order",
1522
- description: 'Settle an existing AWAITING_PAYMENT order created by create-order. Takes only --order-id; the billing path is decided server-side by the order billing_mode. monthly_settlement deducts from the developer credit account then confirms with the supplier; pay_per_call verifies the user EVO payment \u2014 the EVO merchantTransID IS the order_id (the user pays via EVO under the order_id), so the platform queries EVO for that order_id and requires an exact amount/currency match before confirming (the response settlement_path is then "pay_per_call"). On success the order becomes PAID. Supports --watch to poll on PAYMENT_NOT_COMPLETED until PAID',
1522
+ description: "Settle an existing AWAITING_PAYMENT order created by create-order. Charging happens in this step \u2014 platform create-order only locks inventory/price and moves no money (lock-then-pay). Optional payment credentials (--payment-method-id / --payment-token-id / --authorized-merchant-trans-id) are forwarded to the pay body; omit them to let the platform settle by billing_mode (monthly_settlement deducts credit; pay_per_call selects the developer default card / EVO preauth). Token wins over method id server-side. On EVO cardholder authentication the response is AUTHENTICATION_REQUIRED with a three_ds_url + merchant_trans_id; resume by re-calling pay-order with --authorized-merchant-trans-id. On success the order becomes PAID. Supports --watch to poll on PAYMENT_NOT_COMPLETED until PAID",
1523
1523
  flags: {
1524
- "order-id": { type: "string", required: true, description: "Order to settle (create-order.response.order_id). For pay_per_call this is also the EVO merchantTransID the user paid under." },
1524
+ "order-id": { type: "string", required: true, description: "Order to settle (create-order.response.order_id)." },
1525
+ "payment-method-id": {
1526
+ type: "string",
1527
+ required: false,
1528
+ description: "Optional bound-card id to charge (pay_per_call / EVO preauth). Ignored for monthly_settlement and when payment-token-id is set."
1529
+ },
1530
+ "payment-token-id": {
1531
+ type: "string",
1532
+ required: false,
1533
+ description: "Optional network-token id (UnionPay/Visa). When set the platform settles via network-token direct charge instead of EVO preauth+capture. Wins over payment-method-id."
1534
+ },
1535
+ "authorized-merchant-trans-id": {
1536
+ type: "string",
1537
+ required: false,
1538
+ description: "Resume a 3DS challenge: merchant trans id of an already-authorised preauth returned by a prior AUTHENTICATION_REQUIRED response. Reuses that authorization instead of creating a new one (pay_per_call only)."
1539
+ },
1525
1540
  "idempotency-key": {
1526
1541
  type: "string",
1527
1542
  required: true,
@@ -2309,12 +2324,13 @@ var flightChangePaySchema = flightSchema(
2309
2324
  currency: { type: "string", required: false, default: "USD", description: "ISO 4217 currency code." },
2310
2325
  "payment-method-id": { type: "string", required: false, description: "Optional bound-card id (EVO path)." },
2311
2326
  "payment-token-id": { type: "string", required: false, description: "Optional UPI network-token id (unionpay charge path)." },
2327
+ "authorized-merchant-trans-id": { type: "string", required: false, description: "Resume a 3DS challenge with the merchant trans id of the already-authorised preauth; the platform reuses and captures it instead of authorizing again." },
2312
2328
  "idempotency-key": { type: "string", required: true, description: "Idempotency-Key header." }
2313
2329
  },
2314
2330
  {
2315
2331
  change_order_no: { type: "string", description: "Change order number." },
2316
2332
  status: { type: "string", description: "PROCESSING after payment." },
2317
- payment_status: { type: "string", description: "SETTLED on success." }
2333
+ payment_status: { type: "string", description: "SETTLED on success. Absent when the card needs 3DS \u2014 the response then carries a challenge object instead (status AUTHENTICATION_REQUIRED, three_ds_url, merchant_trans_id) and nothing has been charged yet." }
2318
2334
  },
2319
2335
  { 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." }
2320
2336
  );
@@ -4150,7 +4166,10 @@ function isPaymentTerminal(record) {
4150
4166
  return status === "PAID";
4151
4167
  }
4152
4168
  function registerHotelPayOrderCommand(parent, deps) {
4153
- const cmd = parent.command("pay-order").description("Settle an existing hotel order (path decided by billing_mode: monthly_settlement or pay_per_call)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--order-id <id>", "Order ID to pay (from create-order response)").option(
4169
+ const cmd = parent.command("pay-order").description("Settle an existing hotel order (path decided by billing_mode: monthly_settlement or pay_per_call)").option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--order-id <id>", "Order ID to pay (from create-order response)").option("--payment-method-id <id>", "Optional bound-card id to charge (pay_per_call / EVO preauth)").option("--payment-token-id <id>", "Optional network-token id (unionpay/visa charge path)").option(
4170
+ "--authorized-merchant-trans-id <id>",
4171
+ "Resume a 3DS challenge: merchant trans id of an already-authorised preauth"
4172
+ ).option(
4154
4173
  "--idempotency-key <key>",
4155
4174
  "Idempotency key forwarded verbatim as the Idempotency-Key header"
4156
4175
  ).option("--watch", "Poll until PAID or timeout (NDJSON output)", false).option(
@@ -4183,6 +4202,11 @@ function registerHotelPayOrderCommand(parent, deps) {
4183
4202
  const watchInterval = resolveSeconds(opts.watchInterval, DEFAULT_PAY_WATCH_INTERVAL_SECONDS);
4184
4203
  const watchTimeout = resolveSeconds(opts.watchTimeout, DEFAULT_PAY_WATCH_TIMEOUT_SECONDS);
4185
4204
  const body = {};
4205
+ if (opts.paymentMethodId !== void 0) body.payment_method_id = opts.paymentMethodId;
4206
+ if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
4207
+ if (opts.authorizedMerchantTransId !== void 0) {
4208
+ body.authorized_merchant_trans_id = opts.authorizedMerchantTransId;
4209
+ }
4186
4210
  if (!isYes) {
4187
4211
  const confirmed = await confirm5({
4188
4212
  message: `Settle hotel order ${orderId}? This moves money via the order's configured billing mode (monthly_settlement or pay_per_call).`,
@@ -5873,7 +5897,10 @@ function registerChangeCancelCommand(parent, deps) {
5873
5897
  // src/flight-flink/change-pay.ts
5874
5898
  import { confirm as confirm12 } from "@inquirer/prompts";
5875
5899
  function registerChangePayCommand(parent, deps) {
5876
- 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");
5900
+ 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(
5901
+ "--authorized-merchant-trans-id <id>",
5902
+ "Resume a 3DS challenge: merchant trans id of the already-authorised preauth"
5903
+ ).option("--idempotency-key <key>", "Forwarded verbatim as the Idempotency-Key header");
5877
5904
  attachSchemaHelp(cmd, flightChangePaySchema);
5878
5905
  cmd.action(async () => {
5879
5906
  const opts = cmd.optsWithGlobals();
@@ -5891,11 +5918,13 @@ function registerChangePayCommand(parent, deps) {
5891
5918
  };
5892
5919
  if (opts.paymentMethodId !== void 0) body.payment_method_id = opts.paymentMethodId;
5893
5920
  if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
5921
+ if (opts.authorizedMerchantTransId !== void 0) {
5922
+ body.authorized_merchant_trans_id = opts.authorizedMerchantTransId;
5923
+ }
5894
5924
  if (!isYes) {
5895
- const ok = await confirm12({
5896
- message: `Pay change fee ${amount} ${currency} for change order ${changeOrderNo}? This charges the customer and triggers change ticketing.`,
5897
- default: false
5898
- });
5925
+ const isResume = opts.authorizedMerchantTransId !== void 0;
5926
+ const message = isResume ? `Resume change fee ${amount} ${currency} for change order ${changeOrderNo}? The card is already authorised; this captures it and triggers change ticketing.` : `Pay change fee ${amount} ${currency} for change order ${changeOrderNo}? This charges the customer and triggers change ticketing.`;
5927
+ const ok = await confirm12({ message, default: false });
5899
5928
  if (!ok) throw new CliError("CLIENT_ABORTED", "Change payment aborted by user.");
5900
5929
  }
5901
5930
  const idempotencyKey = await resolveIdempotencyKey(opts.idempotencyKey, {
@@ -5911,10 +5940,24 @@ function registerChangePayCommand(parent, deps) {
5911
5940
  );
5912
5941
  spinner?.stop();
5913
5942
  if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
5914
- await render2(
5915
- result.data,
5916
- opts.format,
5917
- (d) => [
5943
+ await render2(result.data, opts.format, (d) => {
5944
+ const challenge = d.challenge ?? null;
5945
+ if (challenge) {
5946
+ return [
5947
+ Formatter.keyValue([
5948
+ ["Change order no", String(challenge.change_order_no ?? "-")],
5949
+ ["Status", String(challenge.status ?? "-")],
5950
+ ["Amount", `${challenge.amount ?? "-"} ${challenge.currency ?? ""}`.trim()],
5951
+ ["Authentication URL", String(challenge.three_ds_url ?? "-")],
5952
+ ["Merchant trans id", String(challenge.merchant_trans_id ?? "-")]
5953
+ ]),
5954
+ Formatter.status(
5955
+ "warning",
5956
+ "Not charged yet \u2014 the card requires 3-D Secure and the funds are not held. Open the authentication URL, then re-run change-pay with --authorized-merchant-trans-id <merchant trans id>."
5957
+ )
5958
+ ].join("\n\n");
5959
+ }
5960
+ return [
5918
5961
  Formatter.keyValue([
5919
5962
  ["Change order no", String(d.change_order_no ?? "-")],
5920
5963
  ["Status", String(d.status ?? "-")],
@@ -5922,8 +5965,8 @@ function registerChangePayCommand(parent, deps) {
5922
5965
  ["Payment status", String(d.payment_status ?? "-")]
5923
5966
  ]),
5924
5967
  Formatter.status("info", "Change fee charged; change ticketing triggered. Poll change-detail until SUCCESS.")
5925
- ].join("\n\n")
5926
- );
5968
+ ].join("\n\n");
5969
+ });
5927
5970
  });
5928
5971
  }
5929
5972