@visa/cli 4.1.0-rc.160 → 4.1.0-rc.162

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.
@@ -12,11 +12,29 @@ export type PostVicConfirmation = (input: {
12
12
  transactionCurrencyCode: string;
13
13
  };
14
14
  }) => Promise<unknown>;
15
+ /**
16
+ * Why a confirmation was not posted, as a BOUNDED value rather than prose.
17
+ *
18
+ * `reason` below is a human sentence built for the local receipt; it embeds
19
+ * upstream error text and is useless as an aggregate. These three codes are the
20
+ * whole space, and they mean very different things:
21
+ *
22
+ * - `outcome_not_definitive` — the merchant never gave a definitive answer, so
23
+ * there is nothing truthful to report. Expected, not a fault.
24
+ * - `no_credential_minted` — no VIC credential existed for this run, so there
25
+ * is no intent to confirm against. Expected, not a fault.
26
+ * - `post_failed` — we HAD a definitive outcome and an intent to report it
27
+ * against, and the POST did not land. This one is a fault: the processor
28
+ * lifecycle row is never written, so the purchase can never rank above the
29
+ * platform's own record no matter how well it actually went.
30
+ */
31
+ export type VicConfirmationSkipCode = 'outcome_not_definitive' | 'no_credential_minted' | 'post_failed';
15
32
  export type VicConfirmationReport = {
16
33
  posted: true;
17
34
  transactionStatus: VicTransactionStatus;
18
35
  } | {
19
36
  posted: false;
37
+ code: VicConfirmationSkipCode;
20
38
  reason: string;
21
39
  };
22
40
  /** Definitive merchant answers map to a status; everything else maps to none. */
@@ -11,12 +11,17 @@ export async function reportVicOutcome(input) {
11
11
  if (!transactionStatus) {
12
12
  return {
13
13
  posted: false,
14
+ code: 'outcome_not_definitive',
14
15
  reason: `outcome '${input.outcome}' is not a definitive merchant answer — ` +
15
16
  'resolve it with the merchant, then post the confirmation manually',
16
17
  };
17
18
  }
18
19
  if (!input.target) {
19
- return { posted: false, reason: 'no VIC credential was minted in this run' };
20
+ return {
21
+ posted: false,
22
+ code: 'no_credential_minted',
23
+ reason: 'no VIC credential was minted in this run',
24
+ };
20
25
  }
21
26
  try {
22
27
  await input.post({
@@ -32,6 +37,7 @@ export async function reportVicOutcome(input) {
32
37
  catch (err) {
33
38
  return {
34
39
  posted: false,
40
+ code: 'post_failed',
35
41
  reason: `confirmation POST failed: ${err.message} — the merchant-reported outcome ` +
36
42
  'remains unverified; retry the confirmation for this intent out-of-band',
37
43
  };