Abo-API: Bestellung je Produkt, Katalog, Speicherstand, Wechsel-Möglichkeit
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
05363d06ad
commit
c4607e9c43
6 files changed
+784
-40
No files matched your search
@@ -12,6 +12,8 @@ export async function startFakeStripe() {
|
||||
const products = new Map()
|
||||
const coupons = new Map()
|
||||
const billingPortalConfigurations = new Map()
|
||||
const customers = new Map()
|
||||
const checkoutSessions = new Map()
|
||||
const calls = []
|
||||
let seq = 0
|
||||
const nextId = (prefix) => `${prefix}_test_${(seq += 1)}`
|
||||
@@ -115,6 +117,44 @@ export async function startFakeStripe() {
|
||||
coupons.set(id, obj)
|
||||
return [200, obj]
|
||||
}
|
||||
// Checkout (Neuabschluss): Kunde suchen/anlegen, Checkout-Sitzung anlegen (F10)
|
||||
if (method === 'GET' && path === '/v1/customers/search') {
|
||||
// Suchsyntax wie in getOrCreateStripeCustomer: metadata['webklarCustomerId']:'c1'
|
||||
const m2 = (query.get('query') || '').match(/metadata\['(\w+)'\]:'([^']*)'/)
|
||||
const found = [...customers.values()].filter((c) => !m2 || c.metadata?.[m2[1]] === m2[2])
|
||||
return [200, { object: 'search_result', data: found, has_more: false, url: '/v1/customers/search' }]
|
||||
}
|
||||
if (method === 'POST' && path === '/v1/customers') {
|
||||
const data = unflatten(body)
|
||||
const obj = {
|
||||
id: nextId('cus'),
|
||||
object: 'customer',
|
||||
email: data.email ?? null,
|
||||
name: data.name ?? null,
|
||||
address: data.address ?? null,
|
||||
invoice_settings: data.invoice_settings || {},
|
||||
metadata: data.metadata || {},
|
||||
}
|
||||
customers.set(obj.id, obj)
|
||||
return [200, obj]
|
||||
}
|
||||
if (method === 'POST' && path === '/v1/checkout/sessions') {
|
||||
const data = unflatten(body)
|
||||
const id = nextId('cs')
|
||||
const obj = {
|
||||
id,
|
||||
object: 'checkout.session',
|
||||
url: `https://checkout.stripe.test/c/pay/${id}`,
|
||||
mode: data.mode || 'payment',
|
||||
customer: data.customer ?? null,
|
||||
client_reference_id: data.client_reference_id ?? null,
|
||||
subscription: null,
|
||||
metadata: data.metadata || {},
|
||||
subscription_data: data.subscription_data || {},
|
||||
}
|
||||
checkoutSessions.set(id, obj)
|
||||
return [200, obj]
|
||||
}
|
||||
if (method === 'GET' && path === '/v1/billing_portal/configurations') {
|
||||
const active = query.get('active')
|
||||
const found = [...billingPortalConfigurations.values()].filter(
|
||||
@@ -172,6 +212,8 @@ export async function startFakeStripe() {
|
||||
products,
|
||||
coupons,
|
||||
billingPortalConfigurations,
|
||||
customers,
|
||||
checkoutSessions,
|
||||
close: () => new Promise((resolve) => server.close(resolve)),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user