@visa/cli 4.1.0-rc.154 → 4.1.0-rc.155
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/checkout-engine/adapters/generic.d.ts +10 -0
- package/dist/checkout-engine/adapters/generic.js +15 -3
- package/dist/checkout-engine/adapters/shopify.d.ts +25 -1
- package/dist/checkout-engine/adapters/shopify.js +103 -12
- package/dist/checkout-engine/cli-engine.d.ts +4 -0
- package/dist/checkout-engine/cli-engine.js +6 -3
- package/dist/checkout-engine/confirmed-merchants.js +51 -22
- package/dist/checkout-engine/executor.js +40 -2
- package/dist/checkout-engine/mandate/mandate-ledger.d.ts +13 -0
- package/dist/checkout-engine/mandate/mandate-ledger.js +22 -0
- package/dist/checkout-engine/receipt.d.ts +42 -2
- package/dist/checkout-engine/receipt.js +30 -14
- package/dist/cli.js +346 -345
- package/dist/mcp-server/index.js +263 -263
- package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { KNOWN_MERCHANT_IDENTITIES } from './known-merchants.js';
|
|
3
4
|
import { submitClickedWithoutConfirmation } from './live-fill-approval.js';
|
|
4
5
|
/**
|
|
5
6
|
* What the operator still owes after this run. Empty for a clean dry-run fill
|
|
@@ -29,23 +30,37 @@ function reconciliationFor(result, vicConfirmation) {
|
|
|
29
30
|
}
|
|
30
31
|
export function buildReceipt(input) {
|
|
31
32
|
const { result } = input;
|
|
33
|
+
const reconciliation = reconciliationFor(result, input.vicConfirmation);
|
|
34
|
+
const fallbackAction = input.mode === 'dry-run'
|
|
35
|
+
? 'Dry run only — nothing was submitted; safe to run again.'
|
|
36
|
+
: result.outcome === 'confirmed'
|
|
37
|
+
? 'No action needed.'
|
|
38
|
+
: result.outcome === 'declined'
|
|
39
|
+
? 'Review the decline before trying again.'
|
|
40
|
+
: 'Review this outcome before retrying.';
|
|
41
|
+
const recoveryActions = reconciliation.reasons.length > 0 ? reconciliation.reasons : [fallbackAction];
|
|
42
|
+
const cardLast4 = input.cardLast4 && /^\d{4}$/.test(input.cardLast4) ? input.cardLast4 : null;
|
|
43
|
+
const checkoutUrl = input.merchant.url && KNOWN_MERCHANT_IDENTITIES[input.merchant.url] ? input.merchant.url : null;
|
|
44
|
+
const networkConfirmation = input.vicConfirmation?.posted === true ? input.vicConfirmation.transactionStatus : null;
|
|
32
45
|
return {
|
|
33
|
-
schema: 'checkout-agent-receipt/
|
|
46
|
+
schema: 'checkout-agent-receipt/v2',
|
|
34
47
|
recordedAt: (input.recordedAt ?? new Date()).toISOString(),
|
|
35
|
-
|
|
36
|
-
reviewId: input.reviewId,
|
|
37
|
-
merchant: { name: input.merchant.name, host: input.merchant.host },
|
|
48
|
+
merchant: { name: input.merchant.name, host: input.merchant.host, checkoutUrl },
|
|
38
49
|
transaction: input.transaction,
|
|
39
50
|
outcome: result.outcome,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
agent: input.agentName ? { name: input.agentName } : null,
|
|
52
|
+
rail: { type: 'card', cardLast4 },
|
|
53
|
+
network: { confirmation: networkConfirmation },
|
|
54
|
+
receiptId: input.reviewId,
|
|
55
|
+
reference: result.confirmationRef ?? null,
|
|
56
|
+
recovery: {
|
|
57
|
+
required: reconciliation.required,
|
|
58
|
+
// A clean dry-run did not submit anything, so repeating inspection is
|
|
59
|
+
// safe. Every submit outcome requires either no retry or owner review.
|
|
60
|
+
retrySafe: input.mode === 'dry-run' && !reconciliation.required,
|
|
61
|
+
action: recoveryActions[0],
|
|
62
|
+
actions: recoveryActions,
|
|
63
|
+
},
|
|
49
64
|
};
|
|
50
65
|
}
|
|
51
66
|
function luhnValid(digits) {
|
|
@@ -88,7 +103,8 @@ export function serializeReceipt(receipt) {
|
|
|
88
103
|
}
|
|
89
104
|
export function receiptFileName(receipt) {
|
|
90
105
|
const ts = receipt.recordedAt.replace(/[:.]/g, '-');
|
|
91
|
-
const
|
|
106
|
+
const receiptId = receipt.schema === 'checkout-agent-receipt/v1' ? receipt.reviewId : receipt.receiptId;
|
|
107
|
+
const review = (receiptId ?? 'no-review').replace(/[^A-Za-z0-9-]/g, '');
|
|
92
108
|
return `receipt-${ts}-${review || 'no-review'}.json`;
|
|
93
109
|
}
|
|
94
110
|
/**
|