diff --git a/public/app.js b/public/app.js
index 187ff2f..5d10534 100644
--- a/public/app.js
+++ b/public/app.js
@@ -624,6 +624,7 @@ function renderAboOffer(card, data, { ended } = {}) {
Ihre Bestellung
+ ${data.testAccount ? '
Testkonto: Bei Stripe wird ein Test-Rabatt verrechnet, abgebucht werden nur 0,50 € pro Monat.
' : ''}
diff --git a/server/config.js b/server/config.js
index 18a0136..cbd7dd2 100644
--- a/server/config.js
+++ b/server/config.js
@@ -84,6 +84,12 @@ export const config = {
.split(',')
.map((s) => s.trim().toLowerCase())
.filter(Boolean),
+ // Testkonten zahlen nur den Stripe-Mindestbetrag (0,50 €) ueber einen Rabatt auf den echten Preis
+ testEmails: (process.env.ABO_TEST_EMAILS || '')
+ .split(',')
+ .map((s) => s.trim().toLowerCase())
+ .filter(Boolean),
+ testCouponId: 'WEBKLAR-TEST-050',
},
smtp: {
diff --git a/server/routes/abo.js b/server/routes/abo.js
index 6ea189e..6732ab4 100644
--- a/server/routes/abo.js
+++ b/server/routes/abo.js
@@ -79,6 +79,7 @@ router.get('/', requireSession, async (req, res) => {
const ledger = sub ? await getLedger(customerId, { active }) : null
return res.json({
available: isStripeConfigured() && isPilotAllowed(customer),
+ testAccount: config.abo.testEmails.includes(String(customer?.email || '').toLowerCase()),
termsVersion: config.abo.termsVersion,
subscription: publicSubscription(sub),
ledger,
diff --git a/server/services/stripeBilling.js b/server/services/stripeBilling.js
index 65510c2..1248499 100644
--- a/server/services/stripeBilling.js
+++ b/server/services/stripeBilling.js
@@ -265,6 +265,22 @@ async function getOrCreateStripeCustomer(customer) {
return created.id
}
+/** Rabatt fuer Testkonten: 49,50 € auf jede Abrechnung -> es werden nur 0,50 € abgebucht. */
+async function ensureTestCoupon() {
+ const stripe = getStripe()
+ const existing = await stripe.coupons.retrieve(config.abo.testCouponId).catch(() => null)
+ if (existing) return existing.id
+ const created = await stripe.coupons.create({
+ id: config.abo.testCouponId,
+ name: 'Testzugang WEBklar (0,50 €)',
+ amount_off: config.stripe.priceAmountCents - 50,
+ currency: 'eur',
+ duration: 'forever',
+ metadata: { webklar: 'wartungs-abo-test' },
+ })
+ return created.id
+}
+
/**
* Stripe Checkout fuer das Abo. Der Kunde hat seine Bestellung vorher im Portal
* abgegeben ("Zahlungspflichtig bestellen"); hier hinterlegt er die Zahlungsart.
@@ -284,6 +300,8 @@ export async function createAboCheckout(customer, consent) {
getOrCreateStripeCustomer(customer),
])
const lateStart = consent.startChoice === 'nach_frist'
+ const isTestAccount = config.abo.testEmails.includes(String(customer.email || '').toLowerCase())
+ const testCoupon = isTestAccount ? await ensureTestCoupon() : null
// Stripe-Metadaten: max. 500 Zeichen je Wert
const meta = {
webklarCustomerId: customer.$id,
@@ -311,6 +329,7 @@ export async function createAboCheckout(customer, consent) {
...(lateStart ? { trial_period_days: config.abo.lateStartTrialDays } : {}),
},
metadata: meta,
+ ...(testCoupon ? { discounts: [{ coupon: testCoupon }] } : {}),
custom_text: {
submit: {
message: lateStart