Shop D3: Connect-Webhook (account.updated, Checkout-Abschluss/Verwerfen, charge.refunded nachtragen)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
987b184aa1
commit
7464a4ef55
6 files changed
+593
No files matched your search
@@ -157,3 +157,22 @@ export function connectEreignis(rawBody, signatur) {
|
||||
if (String(config.stripe.secretKey).startsWith('sk_live') && event.livemode !== true) return null
|
||||
return event
|
||||
}
|
||||
|
||||
/**
|
||||
* Neuer Statuswert fuer das Speichern: ein gemerkter Hinweis (Klarna/SEPA beim Haendler nicht freigeschaltet) bleibt, solange das
|
||||
* Konto Zahlungen annimmt und der Shop Klarna/SEPA anbietet; sonst gilt der frisch gelesene Status. Gleiche Regel wie
|
||||
* POST /api/shop/stripe/aktualisieren.
|
||||
*/
|
||||
export function statusMitHinweis(alt, status, zahlungsarten) {
|
||||
const arten = Array.isArray(zahlungsarten) ? zahlungsarten : ['card']
|
||||
const behalte = typeof alt?.hinweis === 'string' && alt.hinweis !== '' && status.charges_enabled === true && arten.some((z) => z === 'klarna' || z === 'sepa')
|
||||
return behalte ? { ...status, hinweis: alt.hinweis } : status
|
||||
}
|
||||
|
||||
/** Alle Erstattungen einer Zahlung des Haendlerkontos (bis 100; Stripe liefert sie im charge.refunded-Ereignis nicht immer mit). */
|
||||
export async function erstattungenZurZahlung(accountId, paymentIntent) {
|
||||
pruefeKonto(accountId)
|
||||
if (typeof paymentIntent !== 'string' || !PAYMENT_INTENT_RE.test(paymentIntent)) throw fehler(400, 'Ungültige Zahlung.')
|
||||
const liste = await getStripe().refunds.list({ payment_intent: paymentIntent, limit: 100 }, { stripeAccount: accountId })
|
||||
return Array.isArray(liste?.data) ? liste.data : []
|
||||
}
|
||||
Reference in new issue
Block a user