@reeboot/strapi-payment-plugin 0.0.6 → 0.0.7
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/README.md +21 -0
- package/dist/_chunks/{Analytics-CQmAVKsq.mjs → Analytics-CncK5kn-.mjs} +6 -7
- package/dist/_chunks/{Analytics-CLjtRWYA.js → Analytics-c8KBuG3k.js} +6 -7
- package/dist/_chunks/{App-DXN62SV6.mjs → App-B5AB8Omu.mjs} +7 -7
- package/dist/_chunks/{App-Dk7XtjNA.js → App-Cih9sWu1.js} +7 -7
- package/dist/_chunks/{Customers-BQzVBQDT.mjs → Customers-BVk2gx7w.mjs} +51 -118
- package/dist/_chunks/{Customers-BNDi4QBH.js → Customers-CZWOnN26.js} +50 -117
- package/dist/_chunks/{Dashboard-UUwohHZa.js → Dashboard-CEif4jQn.js} +60 -84
- package/dist/_chunks/{Dashboard-CuHC-dit.mjs → Dashboard-DAjD8Q_6.mjs} +60 -84
- package/dist/_chunks/{Orders-CitNCdWE.js → Orders-DZXb54VO.js} +73 -146
- package/dist/_chunks/{Orders-65mNfu2i.mjs → Orders-DdJqI1HB.mjs} +74 -147
- package/dist/_chunks/{PaymentList-B0CAzInT.mjs → PaymentList-3HWK7PMz.mjs} +14 -39
- package/dist/_chunks/{PaymentList-Dy1BAFoD.js → PaymentList-APfyYD1h.js} +14 -39
- package/dist/_chunks/{Payments-FnhoV_2B.mjs → Payments-DFL-Cwgy.mjs} +97 -103
- package/dist/_chunks/{Payments-TOnygGIW.js → Payments-VzDGbK4W.js} +96 -102
- package/dist/_chunks/{Settings-BJtDagUs.js → Settings-B1tR3WOm.js} +157 -161
- package/dist/_chunks/{Settings-EoLSuZLe.mjs → Settings-SALxClBu.mjs} +157 -161
- package/dist/_chunks/{index-2Zd_T7bD.mjs → index-CB6TMitx.mjs} +1 -1
- package/dist/_chunks/{index-CHEgJ7e5.js → index-D-fFikb8.js} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +7 -34
- package/dist/server/index.mjs +7 -34
- package/package.json +1 -1
- /package/dist/server/src/{types → services/types}/api.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/customer.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/index.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/order.d.ts +0 -0
- /package/dist/server/src/{types → services/types}/payment.d.ts +0 -0
package/dist/server/index.mjs
CHANGED
|
@@ -408,36 +408,20 @@ const stripeController = {
|
|
|
408
408
|
const body = ctx.request.body;
|
|
409
409
|
const unparsedBody = body?.[Symbol.for("unparsedBody")] || body?.[Symbol.for("koa-body-unparsed-body")] || ctx.request.rawBody || ctx.rawBody;
|
|
410
410
|
const rawBody = unparsedBody || ctx.request.body;
|
|
411
|
-
const debugInfo = {
|
|
412
|
-
hasUnparsedBody: !!unparsedBody,
|
|
413
|
-
unparsedBodyType: typeof unparsedBody,
|
|
414
|
-
isBodyBuffer: Buffer.isBuffer(ctx.request.body),
|
|
415
|
-
keys: body ? Object.keys(body) : [],
|
|
416
|
-
symbols: body ? Object.getOwnPropertySymbols(body).map((s) => s.toString()) : []
|
|
417
|
-
};
|
|
418
|
-
strapi.log.info("Webhook Debug:", debugInfo);
|
|
419
411
|
if (!signature) {
|
|
420
412
|
return ctx.badRequest("Missing Stripe signature");
|
|
421
413
|
}
|
|
422
|
-
if (signature === "t=123,v1=abc") {
|
|
423
|
-
ctx.body = { debug: debugInfo };
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
414
|
const stripeService2 = strapi.plugin("payment-plugin").service("stripe");
|
|
427
415
|
const event = await stripeService2.constructEvent(rawBody, signature);
|
|
428
416
|
await stripeService2.handleWebhook(event);
|
|
429
417
|
ctx.body = { received: true };
|
|
430
418
|
} catch (error) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
bodyKeys: keys,
|
|
438
|
-
bodySymbols: symbols
|
|
439
|
-
});
|
|
440
|
-
ctx.badRequest(`Webhook Error: ${error.message} | Keys: ${keys.join(",")} | Symbols: ${symbols.join(",")}`);
|
|
419
|
+
if (error.message.includes("No signatures found matching") || error.message.includes("Webhook payload must be provided as a string or a Buffer")) {
|
|
420
|
+
strapi.log.error('Stripe Webhook Error: Payload is not raw. Ensure "includeUnparsed: true" is set in config/middlewares.ts for "strapi::body".');
|
|
421
|
+
return ctx.badRequest("Webhook verification failed: Payload must be raw. Check your Strapi configuration for strapi::body middleware.");
|
|
422
|
+
}
|
|
423
|
+
strapi.log.error("Failed to handle webhook", { error: error.message, stack: error.stack });
|
|
424
|
+
ctx.badRequest(`Webhook Error: ${error.message}`);
|
|
441
425
|
}
|
|
442
426
|
},
|
|
443
427
|
/**
|
|
@@ -1784,30 +1768,19 @@ const stripeService = ({ strapi: strapi2 }) => {
|
|
|
1784
1768
|
const stripeConfig = config2.stripe || {};
|
|
1785
1769
|
const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET || stripeConfig.webhookSecret || (process.env.STRIPE_SECRET_KEY?.startsWith("whsec_") ? process.env.STRIPE_SECRET_KEY : null);
|
|
1786
1770
|
const logger = getLogger();
|
|
1787
|
-
logger.info("Attempting to construct webhook event", {
|
|
1788
|
-
hasPayload: !!payload,
|
|
1789
|
-
payloadType: typeof payload,
|
|
1790
|
-
isBuffer: Buffer.isBuffer(payload),
|
|
1791
|
-
hasSignature: !!signature,
|
|
1792
|
-
hasSecret: !!webhookSecret,
|
|
1793
|
-
secretPrefix: webhookSecret ? webhookSecret.substring(0, 6) : "none"
|
|
1794
|
-
});
|
|
1795
1771
|
if (!webhookSecret) {
|
|
1796
1772
|
throw new Error("Stripe webhook secret not configured. Please set STRIPE_WEBHOOK_SECRET environment variable.");
|
|
1797
1773
|
}
|
|
1798
1774
|
try {
|
|
1799
1775
|
let verifiedPayload = payload;
|
|
1800
1776
|
if (typeof payload === "object" && !Buffer.isBuffer(payload)) {
|
|
1801
|
-
logger.warn("Webhook payload is an object, verification will likely fail. Expected raw body.");
|
|
1802
1777
|
verifiedPayload = JSON.stringify(payload);
|
|
1803
1778
|
}
|
|
1804
1779
|
return stripe2.webhooks.constructEvent(verifiedPayload, signature, webhookSecret);
|
|
1805
1780
|
} catch (error) {
|
|
1806
1781
|
logger.error("Failed to construct webhook event", {
|
|
1807
1782
|
message: error.message,
|
|
1808
|
-
type: error.type
|
|
1809
|
-
// Don't log full stack to keep logs cleaner but enough info for debugging
|
|
1810
|
-
shortStack: error.stack?.split("\n").slice(0, 3).join("\n")
|
|
1783
|
+
type: error.type
|
|
1811
1784
|
});
|
|
1812
1785
|
throw error;
|
|
1813
1786
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|