@vibecodemax/cli 0.1.9 → 0.1.10
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 +20 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1192,6 +1192,14 @@ function formEncode(value, prefix = "") {
|
|
|
1192
1192
|
return entries;
|
|
1193
1193
|
}
|
|
1194
1194
|
async function stripeRequest(params) {
|
|
1195
|
+
const { response, json } = await stripeRequestWithResponse(params);
|
|
1196
|
+
if (!response.ok) {
|
|
1197
|
+
const message = extractErrorMessage(json?.error) || extractErrorMessage(json) || `Stripe returned ${response.status}`;
|
|
1198
|
+
fail("STRIPE_API_ERROR", message, 1, { status: response.status });
|
|
1199
|
+
}
|
|
1200
|
+
return json;
|
|
1201
|
+
}
|
|
1202
|
+
async function stripeRequestWithResponse(params) {
|
|
1195
1203
|
const url = new URL(`https://api.stripe.com${params.path}`);
|
|
1196
1204
|
if (params.query) {
|
|
1197
1205
|
for (const [key, value] of formEncode(params.query)) {
|
|
@@ -1212,11 +1220,7 @@ async function stripeRequest(params) {
|
|
|
1212
1220
|
body,
|
|
1213
1221
|
});
|
|
1214
1222
|
const json = await response.json().catch(() => null);
|
|
1215
|
-
|
|
1216
|
-
const message = extractErrorMessage(json?.error) || extractErrorMessage(json) || `Stripe returned ${response.status}`;
|
|
1217
|
-
fail("STRIPE_API_ERROR", message, 1, { status: response.status });
|
|
1218
|
-
}
|
|
1219
|
-
return json;
|
|
1223
|
+
return { response, json };
|
|
1220
1224
|
}
|
|
1221
1225
|
async function lemonRequest(params) {
|
|
1222
1226
|
const url = new URL(`https://api.lemonsqueezy.com/v1${params.path}`);
|
|
@@ -1379,7 +1383,7 @@ async function createStripeWebhook(flags) {
|
|
|
1379
1383
|
});
|
|
1380
1384
|
return;
|
|
1381
1385
|
}
|
|
1382
|
-
const
|
|
1386
|
+
const createdResponse = await stripeRequestWithResponse({
|
|
1383
1387
|
secretKey,
|
|
1384
1388
|
method: "POST",
|
|
1385
1389
|
path: "/v1/webhook_endpoints",
|
|
@@ -1389,6 +1393,16 @@ async function createStripeWebhook(flags) {
|
|
|
1389
1393
|
description: "VibeCodeMax payments webhook",
|
|
1390
1394
|
},
|
|
1391
1395
|
});
|
|
1396
|
+
if (!createdResponse.response.ok) {
|
|
1397
|
+
const errorMessage = extractErrorMessage(createdResponse.json?.error)
|
|
1398
|
+
|| extractErrorMessage(createdResponse.json)
|
|
1399
|
+
|| `Stripe returned ${createdResponse.response.status}`;
|
|
1400
|
+
if (/activate|activation|business details|submit.*business/i.test(errorMessage)) {
|
|
1401
|
+
fail("STRIPE_ACCOUNT_NOT_ACTIVATED", "Your Stripe account is not activated. Submit your business details in the Stripe dashboard before setting up live webhooks.", 1, { status: createdResponse.response.status });
|
|
1402
|
+
}
|
|
1403
|
+
fail("STRIPE_WEBHOOK_CREATE_FAILED", errorMessage, 1, { status: createdResponse.response.status });
|
|
1404
|
+
}
|
|
1405
|
+
const created = createdResponse.json;
|
|
1392
1406
|
if (!isStripeWebhookSecret(created.secret)) {
|
|
1393
1407
|
fail("STRIPE_WEBHOOK_CREATE_FAILED", "Stripe did not return a webhook signing secret.");
|
|
1394
1408
|
}
|