arispay 0.1.2 → 0.1.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/cli.js +28 -15
- package/package.json +1 -1
- package/src/cli.ts +29 -16
package/dist/cli.js
CHANGED
|
@@ -122,12 +122,13 @@ ${bold("Connect your agent to ArisPay")}`);
|
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
124
|
console.log(`
|
|
125
|
-
${dim("How does your agent make payments?")}
|
|
126
|
-
console.log(` ${dim(" platform \u2014 Your app triggers payments on behalf of the agent (default)")}`);
|
|
127
|
-
console.log(` ${dim(" autonomous \u2014 The agent decides when to pay, within spend limits you set")}
|
|
125
|
+
${dim("How does your agent make payments?")}
|
|
128
126
|
`);
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
console.log(` ${cyan("[1]")} Platform ${dim("\u2014 Your app triggers payments on behalf of the agent")}`);
|
|
128
|
+
console.log(` ${cyan("[2]")} Autonomous ${dim("\u2014 The agent decides when to pay, within spend limits you set")}
|
|
129
|
+
`);
|
|
130
|
+
const modeChoice = await prompt(` Enter choice ${dim("[1]")}: `);
|
|
131
|
+
const mode = modeChoice === "2" ? "autonomous" : "platform";
|
|
131
132
|
console.log(`
|
|
132
133
|
${dim("Connecting agent...")}`);
|
|
133
134
|
try {
|
|
@@ -138,13 +139,14 @@ ${bold("Connect your agent to ArisPay")}`);
|
|
|
138
139
|
});
|
|
139
140
|
const a = agent;
|
|
140
141
|
const config = loadConfig(BRAND);
|
|
141
|
-
saveConfig(BRAND, { ...config, agentId: a.id });
|
|
142
|
+
saveConfig(BRAND, { ...config, agentId: a.id, agentName: a.name || name });
|
|
142
143
|
console.log();
|
|
143
144
|
success(`Agent connected!
|
|
144
145
|
`);
|
|
145
|
-
console.log(` ${dim("ArisPay
|
|
146
|
-
console.log(` ${dim("
|
|
147
|
-
console.log(` ${dim("
|
|
146
|
+
console.log(` ${dim("ArisPay has created a Visa TAP cryptographic identity for your agent.")}`);
|
|
147
|
+
console.log(` ${dim("Every payment your agent makes is signed with this identity so merchants")}`);
|
|
148
|
+
console.log(` ${dim("can verify it is authorised. A circuit breaker is also in place to")}`);
|
|
149
|
+
console.log(` ${dim("auto-pause your agent if unusual spending is detected.")}
|
|
148
150
|
`);
|
|
149
151
|
console.log(` ${bold("Agent ID:")} ${a.id}`);
|
|
150
152
|
console.log(` ${bold("Name:")} ${a.name}`);
|
|
@@ -282,9 +284,11 @@ ${bold("Make a test payment")}`);
|
|
|
282
284
|
`);
|
|
283
285
|
const config = loadConfig(BRAND);
|
|
284
286
|
const storedAgentId = config.agentId;
|
|
287
|
+
const storedAgentName = config.agentName;
|
|
285
288
|
let agentId;
|
|
286
289
|
if (storedAgentId) {
|
|
287
|
-
const
|
|
290
|
+
const agentLabel = storedAgentName ? bold(storedAgentName) : dim(storedAgentId.slice(0, 12) + "...");
|
|
291
|
+
const useStored = await prompt(` Use agent ${agentLabel}? ${dim("(Y/n)")}: `);
|
|
288
292
|
if (useStored.toLowerCase() === "n") {
|
|
289
293
|
agentId = await prompt(` Agent ID: `);
|
|
290
294
|
if (!agentId) {
|
|
@@ -301,25 +305,34 @@ ${bold("Make a test payment")}`);
|
|
|
301
305
|
return;
|
|
302
306
|
}
|
|
303
307
|
}
|
|
304
|
-
const amountStr = await prompt(` Amount
|
|
305
|
-
const
|
|
306
|
-
if (!
|
|
308
|
+
const amountStr = await prompt(` Amount ${dim("(e.g. 5.00)")}: $`);
|
|
309
|
+
const dollars = parseFloat(amountStr);
|
|
310
|
+
if (!dollars || isNaN(dollars)) {
|
|
307
311
|
console.log(dim(" Invalid amount. Cancelled."));
|
|
308
312
|
return;
|
|
309
313
|
}
|
|
310
|
-
const
|
|
314
|
+
const amount = Math.round(dollars * 100);
|
|
315
|
+
const memo = await prompt(` Description ${dim("(appears on the transaction record)")}: `);
|
|
311
316
|
if (!memo) {
|
|
312
317
|
console.log(dim(" Cancelled."));
|
|
313
318
|
return;
|
|
314
319
|
}
|
|
320
|
+
const userId = config.endUserId;
|
|
321
|
+
if (!userId) {
|
|
322
|
+
console.log(`
|
|
323
|
+
${dim("No payment method set up yet. Run option [2] first.")}`);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
315
326
|
console.log(`
|
|
316
|
-
${dim(`Sending $${
|
|
327
|
+
${dim(`Sending $${dollars.toFixed(2)} test payment...`)}`);
|
|
317
328
|
try {
|
|
318
329
|
const payment = await client.payments.create({
|
|
319
330
|
agentId,
|
|
331
|
+
userId,
|
|
320
332
|
amount,
|
|
321
333
|
currency: "USD",
|
|
322
334
|
memo,
|
|
335
|
+
merchantUrl: "https://test.arispay.app",
|
|
323
336
|
idempotencyKey: `cli_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`
|
|
324
337
|
});
|
|
325
338
|
const p = payment;
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -140,12 +140,12 @@ async function wizardConnectAgent(client: ArisPayClient): Promise<void> {
|
|
|
140
140
|
const name = await prompt(` What is your agent called? `);
|
|
141
141
|
if (!name) { console.log(dim(' Cancelled.')); return; }
|
|
142
142
|
|
|
143
|
-
console.log(`\n ${dim('How does your agent make payments?')}`);
|
|
144
|
-
console.log(` ${dim('
|
|
145
|
-
console.log(` ${dim('
|
|
143
|
+
console.log(`\n ${dim('How does your agent make payments?')}\n`);
|
|
144
|
+
console.log(` ${cyan('[1]')} Platform ${dim('— Your app triggers payments on behalf of the agent')}`);
|
|
145
|
+
console.log(` ${cyan('[2]')} Autonomous ${dim('— The agent decides when to pay, within spend limits you set')}\n`);
|
|
146
146
|
|
|
147
|
-
const
|
|
148
|
-
const mode =
|
|
147
|
+
const modeChoice = await prompt(` Enter choice ${dim('[1]')}: `);
|
|
148
|
+
const mode = modeChoice === '2' ? 'autonomous' : 'platform';
|
|
149
149
|
|
|
150
150
|
console.log(`\n ${dim('Connecting agent...')}`);
|
|
151
151
|
|
|
@@ -159,13 +159,14 @@ async function wizardConnectAgent(client: ArisPayClient): Promise<void> {
|
|
|
159
159
|
|
|
160
160
|
// Store agent ID so other steps can auto-fill it
|
|
161
161
|
const config = loadConfig(BRAND);
|
|
162
|
-
saveConfig(BRAND, { ...config, agentId: a.id } as any);
|
|
162
|
+
saveConfig(BRAND, { ...config, agentId: a.id, agentName: a.name || name } as any);
|
|
163
163
|
|
|
164
164
|
console.log();
|
|
165
165
|
success(`Agent connected!\n`);
|
|
166
|
-
console.log(` ${dim('ArisPay
|
|
167
|
-
console.log(` ${dim('
|
|
168
|
-
console.log(` ${dim('
|
|
166
|
+
console.log(` ${dim('ArisPay has created a Visa TAP cryptographic identity for your agent.')}`);
|
|
167
|
+
console.log(` ${dim('Every payment your agent makes is signed with this identity so merchants')}`);
|
|
168
|
+
console.log(` ${dim('can verify it is authorised. A circuit breaker is also in place to')}`);
|
|
169
|
+
console.log(` ${dim('auto-pause your agent if unusual spending is detected.')}\n`);
|
|
169
170
|
console.log(` ${bold('Agent ID:')} ${a.id}`);
|
|
170
171
|
console.log(` ${bold('Name:')} ${a.name}`);
|
|
171
172
|
console.log(` ${bold('Mode:')} ${a.mode || mode}`);
|
|
@@ -283,14 +284,17 @@ async function wizardAddPaymentMethod(client: ArisPayClient): Promise<void> {
|
|
|
283
284
|
|
|
284
285
|
async function wizardTestPayment(client: ArisPayClient): Promise<void> {
|
|
285
286
|
console.log(`\n${bold('Make a test payment')}`);
|
|
286
|
-
console.log(` ${dim('Verify your integration works by sending a test payment.')}
|
|
287
|
+
console.log(` ${dim('Verify your integration works by sending a test payment.')}`);
|
|
288
|
+
console.log(` ${dim('This is a sandbox test — no real funds are moved.')}\n`);
|
|
287
289
|
|
|
288
290
|
const config = loadConfig(BRAND);
|
|
289
291
|
const storedAgentId = (config as any).agentId;
|
|
292
|
+
const storedAgentName = (config as any).agentName;
|
|
290
293
|
|
|
291
294
|
let agentId: string;
|
|
292
295
|
if (storedAgentId) {
|
|
293
|
-
const
|
|
296
|
+
const agentLabel = storedAgentName ? bold(storedAgentName) : dim(storedAgentId.slice(0, 12) + '...');
|
|
297
|
+
const useStored = await prompt(` Use agent ${agentLabel}? ${dim('(Y/n)')}: `);
|
|
294
298
|
if (useStored.toLowerCase() === 'n') {
|
|
295
299
|
agentId = await prompt(` Agent ID: `);
|
|
296
300
|
if (!agentId) { console.log(dim(' Cancelled.')); return; }
|
|
@@ -302,21 +306,30 @@ async function wizardTestPayment(client: ArisPayClient): Promise<void> {
|
|
|
302
306
|
if (!agentId) { console.log(dim(' Cancelled.')); return; }
|
|
303
307
|
}
|
|
304
308
|
|
|
305
|
-
const amountStr = await prompt(` Amount
|
|
306
|
-
const
|
|
307
|
-
if (!
|
|
309
|
+
const amountStr = await prompt(` Amount ${dim('(e.g. 5.00)')}: $`);
|
|
310
|
+
const dollars = parseFloat(amountStr);
|
|
311
|
+
if (!dollars || isNaN(dollars)) { console.log(dim(' Invalid amount. Cancelled.')); return; }
|
|
312
|
+
const amount = Math.round(dollars * 100);
|
|
308
313
|
|
|
309
|
-
const memo = await prompt(`
|
|
314
|
+
const memo = await prompt(` Description ${dim('(appears on the transaction record)')}: `);
|
|
310
315
|
if (!memo) { console.log(dim(' Cancelled.')); return; }
|
|
311
316
|
|
|
312
|
-
|
|
317
|
+
const userId = (config as any).endUserId;
|
|
318
|
+
if (!userId) {
|
|
319
|
+
console.log(`\n ${dim('No payment method set up yet. Run option [2] first.')}`);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
console.log(`\n ${dim(`Sending $${dollars.toFixed(2)} test payment...`)}`);
|
|
313
324
|
|
|
314
325
|
try {
|
|
315
326
|
const payment = await client.payments.create({
|
|
316
327
|
agentId,
|
|
328
|
+
userId,
|
|
317
329
|
amount,
|
|
318
330
|
currency: 'USD',
|
|
319
331
|
memo,
|
|
332
|
+
merchantUrl: 'https://test.arispay.app',
|
|
320
333
|
idempotencyKey: `cli_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
321
334
|
} as any);
|
|
322
335
|
const p = payment as any;
|