Wechsel: Lastschrift-Fehler nur für den echten Wechsel, Abgleich ohne Webhook, Gutschrift netto, Skript prüft Stripe
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc20ce0673
commit
662f8d8144
7 files changed
+528
-76
No files matched your search
+13
-2
@@ -149,13 +149,24 @@ test('Stripe-Nachbau: ausstehende Aktualisierung bleibt zurückgehalten, bis sie
|
||||
// Wie Stripe: Antwort und gespeichertes Abo zeigen den alten Stand
|
||||
assert.equal(pending.metadata.productKey, 'hosting')
|
||||
assert.equal(pending.items.data[0].price.id, 'price_0')
|
||||
// Wie Stripe (Fix 1): das Abo traegt pending_update, bis die Aenderung uebernommen oder verworfen wird
|
||||
const stored = await stripe.subscriptions.retrieve('sub_p')
|
||||
assert.equal(stored.metadata.productKey, 'hosting')
|
||||
assert.equal(stored.pending_update, undefined)
|
||||
assert.deepEqual(stored.pending_update, { expires_at: 1 })
|
||||
// Bezahlt: die zurueckgehaltene Aenderung wird uebernommen
|
||||
const applied = st.applyPendingUpdate('sub_p')
|
||||
assert.equal(applied.metadata.productKey, 'wartung')
|
||||
assert.equal((await stripe.subscriptions.retrieve('sub_p')).items.data[0].price.id, 'price_b')
|
||||
const after = await stripe.subscriptions.retrieve('sub_p')
|
||||
assert.equal(after.items.data[0].price.id, 'price_b')
|
||||
assert.equal(after.pending_update, null)
|
||||
assert.throws(() => st.applyPendingUpdate('sub_p'), /keine ausstehende/)
|
||||
// Verfallen: Stripe verwirft die Aenderung, das Abo bleibt beim alten Stand
|
||||
st.nextSubscriptionUpdate = { pending_update: { expires_at: 2 } }
|
||||
await stripe.subscriptions.update('sub_p', { metadata: { productKey: 'neu' }, payment_behavior: 'pending_if_incomplete' })
|
||||
st.expirePendingUpdate('sub_p')
|
||||
const expired = await stripe.subscriptions.retrieve('sub_p')
|
||||
assert.equal(expired.metadata.productKey, 'wartung')
|
||||
assert.equal(expired.pending_update, null)
|
||||
assert.throws(() => st.applyPendingUpdate('sub_p'), /keine ausstehende/)
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user