vibecash 0.2.4 → 0.2.6
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 +33 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -181,14 +181,15 @@ function registerWalletCommands(program2) {
|
|
|
181
181
|
// src/commands/product.ts
|
|
182
182
|
function registerProductCommands(program2) {
|
|
183
183
|
const product = program2.command("product").description("Manage products");
|
|
184
|
-
product.command("create <name>").description("Create a new product").option("-d, --description <description>", "Product description").action(async (name, opts) => {
|
|
184
|
+
product.command("create <name>").description("Create a new product").option("-d, --description <description>", "Product description").option("-w, --webhook-url <url>", "Webhook URL for this product").action(async (name, opts) => {
|
|
185
185
|
try {
|
|
186
186
|
const body = { name };
|
|
187
187
|
if (opts.description) body.description = opts.description;
|
|
188
|
+
if (opts.webhookUrl) body.webhookUrl = opts.webhookUrl;
|
|
188
189
|
const data = await apiRequest("POST", "/products", body);
|
|
189
190
|
success("Product created");
|
|
190
191
|
output(data, (d) => `Product ID: ${d.id}
|
|
191
|
-
Name: ${d.name}`);
|
|
192
|
+
Name: ${d.name}${d.webhookUrl ? "\nWebhook: " + d.webhookUrl : ""}`);
|
|
192
193
|
} catch (err) {
|
|
193
194
|
console.error(`Error: ${err.message}`);
|
|
194
195
|
process.exit(1);
|
|
@@ -218,6 +219,7 @@ Name: ${d.name}`);
|
|
|
218
219
|
`Product ID: ${d.id}`,
|
|
219
220
|
`Name: ${d.name}`,
|
|
220
221
|
`Description: ${d.description || "N/A"}`,
|
|
222
|
+
`Webhook: ${d.webhookUrl || "N/A (using wallet default)"}`,
|
|
221
223
|
`Created: ${fmtDate(d.createdAt)}`
|
|
222
224
|
].join("\n"));
|
|
223
225
|
} catch (err) {
|
|
@@ -225,11 +227,12 @@ Name: ${d.name}`);
|
|
|
225
227
|
process.exit(1);
|
|
226
228
|
}
|
|
227
229
|
});
|
|
228
|
-
product.command("update <id>").description("Update a product").option("-n, --name <name>", "New product name").option("-d, --description <description>", "New product description").action(async (id, opts) => {
|
|
230
|
+
product.command("update <id>").description("Update a product").option("-n, --name <name>", "New product name").option("-d, --description <description>", "New product description").option("-w, --webhook-url <url>", "Webhook URL for this product").action(async (id, opts) => {
|
|
229
231
|
try {
|
|
230
232
|
const body = {};
|
|
231
233
|
if (opts.name) body.name = opts.name;
|
|
232
234
|
if (opts.description) body.description = opts.description;
|
|
235
|
+
if (opts.webhookUrl) body.webhookUrl = opts.webhookUrl;
|
|
233
236
|
await apiRequest("PATCH", `/products/${id}`, body);
|
|
234
237
|
success("Product updated");
|
|
235
238
|
} catch (err) {
|
|
@@ -262,12 +265,15 @@ function registerPriceCommands(program2) {
|
|
|
262
265
|
if (opts.interval) body.interval = opts.interval;
|
|
263
266
|
const data = await apiRequest("POST", "/prices", body);
|
|
264
267
|
success("Price created");
|
|
265
|
-
output(data, (d) =>
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
output(data, (d) => {
|
|
269
|
+
const payUrl = process.env.VIBECASH_PAY_URL || "https://vibecash.dev";
|
|
270
|
+
return [
|
|
271
|
+
`Price ID: ${d.id}`,
|
|
272
|
+
`Amount: ${fmtAmount(d.unitAmount ?? d.amount, d.currency)}${d.interval ? "/" + d.interval : ""}`,
|
|
273
|
+
`Type: ${d.type}`,
|
|
274
|
+
`Payment URL: ${payUrl}/buy/${d.id}`
|
|
275
|
+
].join("\n");
|
|
276
|
+
});
|
|
271
277
|
} catch (err) {
|
|
272
278
|
console.error(`Error: ${err.message}`);
|
|
273
279
|
process.exit(1);
|
|
@@ -521,7 +527,7 @@ function registerCustomerCommands(program2) {
|
|
|
521
527
|
// src/commands/link.ts
|
|
522
528
|
function registerLinkCommands(program2) {
|
|
523
529
|
const link = program2.command("link").description("Manage payment links");
|
|
524
|
-
link.command("create <amount>").description("Create a new payment link (amount in cents, e.g. 1000 = $10.00)").option("-c, --currency <currency>", "Currency code", "SGD").option("-n, --name <name>", "Link name").option("-d, --description <description>", "Link description").option("--success-url <url>", "URL to redirect after successful payment").option("--cancel-url <url>", "URL to redirect on cancel").option("--methods <methods>", "Payment methods (comma-separated: card,alipay,paynow,wechat)").action(async (amount, opts) => {
|
|
530
|
+
link.command("create <amount>").description("Create a new payment link (amount in cents, e.g. 1000 = $10.00)").option("-c, --currency <currency>", "Currency code", "SGD").option("-n, --name <name>", "Link name").option("-d, --description <description>", "Link description").option("--success-url <url>", "URL to redirect after successful payment").option("--cancel-url <url>", "URL to redirect on cancel").option("--methods <methods>", "Payment methods (comma-separated: card,alipay,paynow,wechat)").option("-w, --webhook-url <url>", "Webhook URL for this payment link").action(async (amount, opts) => {
|
|
525
531
|
try {
|
|
526
532
|
const body = {
|
|
527
533
|
amount: parseInt(amount, 10),
|
|
@@ -532,6 +538,7 @@ function registerLinkCommands(program2) {
|
|
|
532
538
|
if (opts.successUrl) body.successUrl = opts.successUrl;
|
|
533
539
|
if (opts.cancelUrl) body.cancelUrl = opts.cancelUrl;
|
|
534
540
|
if (opts.methods) body.paymentMethodTypes = opts.methods.split(",").map((m) => m.trim());
|
|
541
|
+
if (opts.webhookUrl) body.webhookUrl = opts.webhookUrl;
|
|
535
542
|
const data = await apiRequest("POST", "/payment_links", body);
|
|
536
543
|
success("Payment link created");
|
|
537
544
|
output(data, (d) => {
|
|
@@ -580,6 +587,7 @@ function registerLinkCommands(program2) {
|
|
|
580
587
|
`Amount: ${fmtAmount(d.amount, d.currency)}`,
|
|
581
588
|
`Active: ${d.active ? "yes" : "no"}`,
|
|
582
589
|
`Desc: ${d.description || "N/A"}`,
|
|
590
|
+
`Webhook: ${d.webhookUrl || "N/A (using wallet default)"}`,
|
|
583
591
|
`Created: ${fmtDate(d.createdAt)}`
|
|
584
592
|
].join("\n");
|
|
585
593
|
});
|
|
@@ -588,6 +596,21 @@ function registerLinkCommands(program2) {
|
|
|
588
596
|
process.exit(1);
|
|
589
597
|
}
|
|
590
598
|
});
|
|
599
|
+
link.command("update <id>").description("Update a payment link").option("-n, --name <name>", "New link name").option("-d, --description <description>", "New description").option("--success-url <url>", "Success redirect URL").option("--cancel-url <url>", "Cancel redirect URL").option("-w, --webhook-url <url>", "Webhook URL").action(async (id, opts) => {
|
|
600
|
+
try {
|
|
601
|
+
const body = {};
|
|
602
|
+
if (opts.name) body.name = opts.name;
|
|
603
|
+
if (opts.description) body.description = opts.description;
|
|
604
|
+
if (opts.successUrl) body.successUrl = opts.successUrl;
|
|
605
|
+
if (opts.cancelUrl) body.cancelUrl = opts.cancelUrl;
|
|
606
|
+
if (opts.webhookUrl) body.webhookUrl = opts.webhookUrl;
|
|
607
|
+
await apiRequest("PATCH", `/payment_links/${id}`, body);
|
|
608
|
+
success("Payment link updated");
|
|
609
|
+
} catch (err) {
|
|
610
|
+
console.error(`Error: ${err.message}`);
|
|
611
|
+
process.exit(1);
|
|
612
|
+
}
|
|
613
|
+
});
|
|
591
614
|
link.command("deactivate <id>").description("Deactivate a payment link").action(async (id) => {
|
|
592
615
|
try {
|
|
593
616
|
await apiRequest("PATCH", `/payment_links/${id}`, { active: false });
|