@agenzo/merchant-cli 0.8.2 → 0.8.3
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 +83 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -59,7 +59,6 @@ var CODE_NUM = {
|
|
|
59
59
|
CHECKOUT_TASK_NOT_FOUND: 4307,
|
|
60
60
|
PAY_PER_CALL_NOT_AVAILABLE: 4308,
|
|
61
61
|
HOTEL_NOT_FOUND: 4309,
|
|
62
|
-
BOOKING_RESTRICTED: 4310,
|
|
63
62
|
RATE_LIMITED: 5001,
|
|
64
63
|
UPSTREAM_ERROR: 5101,
|
|
65
64
|
INTERNAL_ERROR: 5201,
|
|
@@ -240,7 +239,6 @@ var STABLE_MESSAGE = {
|
|
|
240
239
|
CHECKOUT_TASK_NOT_FOUND: "Check-out application not found.",
|
|
241
240
|
PAY_PER_CALL_NOT_AVAILABLE: "Pay-per-call billing is not available; use monthly_settlement.",
|
|
242
241
|
HOTEL_NOT_FOUND: "This hotel is no longer available from the supplier.",
|
|
243
|
-
BOOKING_RESTRICTED: "This room has a booking condition that your request doesn't meet. Please check the room's booking rules and adjust your request.",
|
|
244
242
|
NOT_IMPLEMENTED: "This operation is not implemented yet."
|
|
245
243
|
};
|
|
246
244
|
function toErrorEnvelope(error) {
|
|
@@ -2097,6 +2095,25 @@ var flightChangeCancelSchema = flightSchema(
|
|
|
2097
2095
|
{ status: { type: "int", description: "Terminal 5 (cancelled)." } },
|
|
2098
2096
|
{ command: "agenzo-merchant-cli flight-flink change-cancel --change-order-no C1 --idempotency-key k5", output_summary: "Change request cancelled." }
|
|
2099
2097
|
);
|
|
2098
|
+
var flightChangePaySchema = flightSchema(
|
|
2099
|
+
"change-pay",
|
|
2100
|
+
"Pay a change request fee (charges like a normal order) and trigger change ticketing. flink pay type=1.",
|
|
2101
|
+
{
|
|
2102
|
+
"change-order-no": { type: "string", required: true, description: "Change order number." },
|
|
2103
|
+
"order-no": { type: "string", required: true, description: "Original order reference (ownership check)." },
|
|
2104
|
+
amount: { type: "float", required: true, description: "Change fee total (change-detail price_total, decimal units)." },
|
|
2105
|
+
currency: { type: "string", required: false, default: "USD", description: "ISO 4217 currency code." },
|
|
2106
|
+
"payment-method-id": { type: "string", required: false, description: "Optional bound-card id (EVO path)." },
|
|
2107
|
+
"payment-token-id": { type: "string", required: false, description: "Optional UPI network-token id (unionpay charge path)." },
|
|
2108
|
+
"idempotency-key": { type: "string", required: true, description: "Idempotency-Key header." }
|
|
2109
|
+
},
|
|
2110
|
+
{
|
|
2111
|
+
change_order_no: { type: "string", description: "Change order number." },
|
|
2112
|
+
status: { type: "string", description: "PROCESSING after payment." },
|
|
2113
|
+
payment_status: { type: "string", description: "SETTLED on success." }
|
|
2114
|
+
},
|
|
2115
|
+
{ 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." }
|
|
2116
|
+
);
|
|
2100
2117
|
var flightRefundApplySchema = flightSchema(
|
|
2101
2118
|
"refund-apply",
|
|
2102
2119
|
"Submit a refund request. Returns refund_order_no, status 0 (pending review).",
|
|
@@ -4991,7 +5008,7 @@ function registerVerifyCommand(parent, deps) {
|
|
|
4991
5008
|
// src/flight-flink/create-order.ts
|
|
4992
5009
|
import { confirm as confirm6 } from "@inquirer/prompts";
|
|
4993
5010
|
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");
|
|
5011
|
+
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
5012
|
attachSchemaHelp(cmd, flightCreateOrderSchema);
|
|
4996
5013
|
cmd.action(async () => {
|
|
4997
5014
|
const opts = cmd.optsWithGlobals();
|
|
@@ -5013,6 +5030,7 @@ function registerCreateOrderCommand(parent, deps) {
|
|
|
5013
5030
|
passengers: jsonArray(need16(opts.passengers, "passengers"), "passengers")
|
|
5014
5031
|
};
|
|
5015
5032
|
if (opts.paymentMethodId !== void 0) body.payment_method_id = opts.paymentMethodId;
|
|
5033
|
+
if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
|
|
5016
5034
|
if (!isYes) {
|
|
5017
5035
|
const ok = await confirm6({
|
|
5018
5036
|
message: `Create this flight order for ${totalAmount} ${currency}? This locks the fare but does NOT charge yet.`,
|
|
@@ -5344,8 +5362,65 @@ function registerChangeCancelCommand(parent, deps) {
|
|
|
5344
5362
|
});
|
|
5345
5363
|
}
|
|
5346
5364
|
|
|
5347
|
-
// src/flight-flink/
|
|
5365
|
+
// src/flight-flink/change-pay.ts
|
|
5348
5366
|
import { confirm as confirm11 } from "@inquirer/prompts";
|
|
5367
|
+
function registerChangePayCommand(parent, deps) {
|
|
5368
|
+
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");
|
|
5369
|
+
attachSchemaHelp(cmd, flightChangePaySchema);
|
|
5370
|
+
cmd.action(async () => {
|
|
5371
|
+
const opts = cmd.optsWithGlobals();
|
|
5372
|
+
const format = resolveFormat(opts.format);
|
|
5373
|
+
const isYes = Boolean(opts.yes);
|
|
5374
|
+
const apiKey = await resolveApiKey(opts.apiKey);
|
|
5375
|
+
const changeOrderNo = need16(opts.changeOrderNo, "change-order-no");
|
|
5376
|
+
const orderNo = need16(opts.orderNo, "order-no");
|
|
5377
|
+
const amount = num8(opts.amount, "amount");
|
|
5378
|
+
const currency = need16(opts.currency, "currency");
|
|
5379
|
+
const body = {
|
|
5380
|
+
order_no: orderNo,
|
|
5381
|
+
amount,
|
|
5382
|
+
currency
|
|
5383
|
+
};
|
|
5384
|
+
if (opts.paymentMethodId !== void 0) body.payment_method_id = opts.paymentMethodId;
|
|
5385
|
+
if (opts.paymentTokenId !== void 0) body.payment_token_id = opts.paymentTokenId;
|
|
5386
|
+
if (!isYes) {
|
|
5387
|
+
const ok = await confirm11({
|
|
5388
|
+
message: `Pay change fee ${amount} ${currency} for change order ${changeOrderNo}? This charges the customer and triggers change ticketing.`,
|
|
5389
|
+
default: false
|
|
5390
|
+
});
|
|
5391
|
+
if (!ok) throw new CliError("CLIENT_ABORTED", "Change payment aborted by user.");
|
|
5392
|
+
}
|
|
5393
|
+
const idempotencyKey = await resolveIdempotencyKey(opts.idempotencyKey, {
|
|
5394
|
+
yes: isYes,
|
|
5395
|
+
commandPath: "flight-flink change-pay"
|
|
5396
|
+
});
|
|
5397
|
+
const spinner = format === "json" ? null : createSpinner("Paying change request...");
|
|
5398
|
+
const result = await deps.apiClient.post(
|
|
5399
|
+
`/flight/change/${encodeURIComponent(changeOrderNo)}/pay`,
|
|
5400
|
+
{ type: "api-key", key: apiKey },
|
|
5401
|
+
body,
|
|
5402
|
+
{ "Idempotency-Key": idempotencyKey }
|
|
5403
|
+
);
|
|
5404
|
+
spinner?.stop();
|
|
5405
|
+
if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
|
|
5406
|
+
await render2(
|
|
5407
|
+
result.data,
|
|
5408
|
+
opts.format,
|
|
5409
|
+
(d) => [
|
|
5410
|
+
Formatter.keyValue([
|
|
5411
|
+
["Change order no", String(d.change_order_no ?? "-")],
|
|
5412
|
+
["Status", String(d.status ?? "-")],
|
|
5413
|
+
["Amount", `${d.amount ?? "-"} ${d.currency ?? ""}`.trim()],
|
|
5414
|
+
["Payment status", String(d.payment_status ?? "-")]
|
|
5415
|
+
]),
|
|
5416
|
+
Formatter.status("info", "Change fee charged; change ticketing triggered. Poll change-detail until SUCCESS.")
|
|
5417
|
+
].join("\n\n")
|
|
5418
|
+
);
|
|
5419
|
+
});
|
|
5420
|
+
}
|
|
5421
|
+
|
|
5422
|
+
// src/flight-flink/refund-apply.ts
|
|
5423
|
+
import { confirm as confirm12 } from "@inquirer/prompts";
|
|
5349
5424
|
function registerRefundApplyCommand(parent, deps) {
|
|
5350
5425
|
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
5426
|
attachSchemaHelp(cmd, flightRefundApplySchema);
|
|
@@ -5366,7 +5441,7 @@ function registerRefundApplyCommand(parent, deps) {
|
|
|
5366
5441
|
};
|
|
5367
5442
|
if (opts.reason !== void 0) body.reason = opts.reason;
|
|
5368
5443
|
if (!isYes) {
|
|
5369
|
-
const ok = await
|
|
5444
|
+
const ok = await confirm12({
|
|
5370
5445
|
message: `Submit a refund request for order ${body.order_no}?`,
|
|
5371
5446
|
default: false
|
|
5372
5447
|
});
|
|
@@ -5410,7 +5485,7 @@ function registerRefundDetailCommand(parent, deps) {
|
|
|
5410
5485
|
}
|
|
5411
5486
|
|
|
5412
5487
|
// src/flight-flink/refund-confirm.ts
|
|
5413
|
-
import { confirm as
|
|
5488
|
+
import { confirm as confirm13 } from "@inquirer/prompts";
|
|
5414
5489
|
function registerRefundConfirmCommand(parent, deps) {
|
|
5415
5490
|
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
5491
|
attachSchemaHelp(cmd, flightRefundConfirmSchema);
|
|
@@ -5426,7 +5501,7 @@ function registerRefundConfirmCommand(parent, deps) {
|
|
|
5426
5501
|
}
|
|
5427
5502
|
if (!isYes) {
|
|
5428
5503
|
const action = confirmFlag === "1" ? "confirm" : "cancel";
|
|
5429
|
-
const ok = await
|
|
5504
|
+
const ok = await confirm13({ message: `${action} refund ${refundOrderNo}?`, default: false });
|
|
5430
5505
|
if (!ok) throw new CliError("CLIENT_ABORTED", "Refund confirmation aborted by user.");
|
|
5431
5506
|
}
|
|
5432
5507
|
const idempotencyKey = await resolveIdempotencyKey(opts.idempotencyKey, {
|
|
@@ -5679,6 +5754,7 @@ Key notes:
|
|
|
5679
5754
|
registerChangeApplyCommand(flightCmd, deps);
|
|
5680
5755
|
registerChangeDetailCommand(flightCmd, deps);
|
|
5681
5756
|
registerChangeCancelCommand(flightCmd, deps);
|
|
5757
|
+
registerChangePayCommand(flightCmd, deps);
|
|
5682
5758
|
registerRefundApplyCommand(flightCmd, deps);
|
|
5683
5759
|
registerRefundDetailCommand(flightCmd, deps);
|
|
5684
5760
|
registerRefundConfirmCommand(flightCmd, deps);
|