Tests: Stripe- und Appwrite-Nachbau im Testprozess

getStripe() nutzt in Tests über STRIPE_API_BASE den Nachbau auf 127.0.0.1;
in Produktion ist der Wert leer und nichts ändert sich.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-09-27 15:30:56 +00:00
1 parent 877fde7a6f
commit 54defb75c4
6 files changed
+271 -1

No files matched your search

+2
View File
@@ -106,6 +106,8 @@ export const config = {
stripe: {
secretKey: process.env.STRIPE_SECRET_KEY || '',
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET || '',
// Nur für Tests: Stripe-Nachbau statt api.stripe.com (z. B. http://127.0.0.1:12111)
apiBase: process.env.STRIPE_API_BASE || '',
priceLookupKey: products.wartung.lookupKey,
priceAmountCents: products.wartung.amountCents,
productName: products.wartung.name,
+7 -1
View File
@@ -30,7 +30,13 @@ export function getStripe() {
throw err
}
if (!stripeClient) {
stripeClient = new Stripe(config.stripe.secretKey, { maxNetworkRetries: 2 })
const options = { maxNetworkRetries: 2 }
// Tests: Stripe-Nachbau auf 127.0.0.1 (config.stripe.apiBase ist in Produktion leer)
if (config.stripe.apiBase) {
const base = new URL(config.stripe.apiBase)
Object.assign(options, { host: base.hostname, port: Number(base.port), protocol: base.protocol.replace(':', '') })
}
stripeClient = new Stripe(config.stripe.secretKey, options)
}
return stripeClient
}