Stripe: Testrabatt-Namen, Produktbild, Hosting-Leistungen, Tests für Bestandskunden

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-09-28 10:02:03 +00:00
1 parent c4607e9c43
commit 7df0b72019
7 files changed
+297 -52

No files matched your search

+20
View File
@@ -66,6 +66,14 @@ export async function startFakeStripe() {
}
if (method === 'POST' && path === '/v1/prices') {
const data = unflatten(body)
// Wie echtes Stripe: ein lookup_key darf nur an einem aktiven Preis gleichzeitig haengen
// (Fix round 1, Important 1 - haertet den Nachbau, ensurePrice fragt vorher ohnehin per GET)
if (data.lookup_key) {
const clash = [...prices.values()].find((p) => p.lookup_key === data.lookup_key && p.active !== false)
if (clash) {
return [400, { error: { type: 'invalid_request_error', param: 'lookup_key', message: `An active price already exists for lookup_key: '${data.lookup_key}'.` } }]
}
}
const obj = {
id: nextId('price'),
object: 'price',
@@ -84,6 +92,10 @@ export async function startFakeStripe() {
if (method === 'GET' && (m = path.match(/^\/v1\/invoices\/([^/]+)$/))) {
return invoices.has(m[1]) ? [200, invoices.get(m[1])] : noSuch('invoice', m[1])
}
// scripts/stripe-products.mjs --pruefen liest das Produkt zurueck (Beschreibung, Bild)
if (method === 'GET' && (m = path.match(/^\/v1\/products\/([^/]+)$/))) {
return products.has(m[1]) ? [200, products.get(m[1])] : noSuch('product', m[1])
}
if (method === 'POST' && path === '/v1/products') {
const data = unflatten(body)
const obj = {
@@ -93,6 +105,7 @@ export async function startFakeStripe() {
name: data.name || '',
description: data.description ?? null,
statement_descriptor: data.statement_descriptor ?? null,
images: data.images || [],
metadata: data.metadata || {},
}
products.set(obj.id, obj)
@@ -104,6 +117,13 @@ export async function startFakeStripe() {
if (method === 'POST' && path === '/v1/coupons') {
const data = unflatten(body)
const id = data.id || nextId('coupon')
// Wie echtes Stripe: Name auf 40 Zeichen begrenzt, IDs eindeutig (Fix round 1, Important 1)
if (data.name && data.name.length > 40) {
return [400, { error: { type: 'invalid_request_error', param: 'name', message: 'Name must be no more than 40 characters.' } }]
}
if (coupons.has(id)) {
return [400, { error: { type: 'invalid_request_error', message: `Coupon with ID '${id}' already exists.` } }]
}
const obj = {
id,
object: 'coupon',