Shop E2: Abschluss (schliesseAb), verwirf, Abgleich offener Bestellungen, Minutenjob
schliesseAb ist die einzige Stelle fuer den Status bezahlt: Sperre je Bestellung, Konto muss zum Shop passen, idempotent, spaete Zahlung nach Ablauf wird angenommen, SEPA erst bei bezahlt, Bestandsabzug mit Ueberverkauft-Hinweis, G09 an den Kaeufer und K25 an den Haendler (Mailfehler machen nichts rueckgaengig). pruefeOffene und jobs.js minutenJob gleichen offene Bestellungen mit Stripe ab. fakeStripe: completeSession. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9de23c7fe2
commit
bf99f659eb
4 files changed
+741
-4
No files matched your search
@@ -805,6 +805,29 @@ export async function startFakeStripe() {
|
||||
accounts.set(id, next)
|
||||
return next
|
||||
},
|
||||
/**
|
||||
* Sitzung eines Haendlerkontos als abgeschlossen markieren (status complete) und die Felder setzen, die Stripe nach der Kasse
|
||||
* liefert: completeSession('acct_x', 'cs_x', { payment_status: 'paid', amount_total, customer_details, shipping, payment_intent,
|
||||
* payment_method_types }). shipping steht wie bei Stripe unter collected_information.shipping_details und shipping_details.
|
||||
* Gibt die neue Sitzung zurueck (so schickt der Webhook sie).
|
||||
*/
|
||||
completeSession(accountId, id, { payment_status = 'paid', amount_total = null, customer_details = null, shipping = null, payment_intent = null, payment_method_types } = {}) {
|
||||
const sessions = bucket(accountSessionMaps, accountId)
|
||||
const found = sessions.get(id)
|
||||
if (!found) throw new Error(`Stripe-Nachbau: keine Sitzung ${id} bei ${accountId}`)
|
||||
const next = {
|
||||
...found,
|
||||
status: 'complete',
|
||||
payment_status,
|
||||
amount_total,
|
||||
customer_details,
|
||||
payment_intent,
|
||||
...(payment_method_types ? { payment_method_types } : {}),
|
||||
...(shipping ? { collected_information: { shipping_details: shipping }, shipping_details: shipping } : {}),
|
||||
}
|
||||
sessions.set(id, next)
|
||||
return next
|
||||
},
|
||||
/** Zahlung eines Haendlerkontos (Betrag in Cent) fuer Erstattungen: setPaymentIntent('acct_x', 'pi_x', { amount: 2500 }). */
|
||||
setPaymentIntent(accountId, id, { amount, currency = 'eur' }) {
|
||||
const obj = { id, object: 'payment_intent', amount, currency }
|
||||
|
||||
Reference in new issue
Block a user