Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(billing): preserve callback erasure across repeated deliveries

Timothy Yinf92c977f6d58
diff --git a/packages/platform/src/payments.ts b/packages/platform/src/payments.ts
index dd43beb7..d8fa2e66 100644
--- a/packages/platform/src/payments.ts
+++ b/packages/platform/src/payments.ts
@@ -685,7 +685,7 @@ export async function receivePaymentEvent(
),
db
.prepare(
- 'INSERT OR IGNORE INTO platform_payment_event_payloads(event_id,ciphertext,received_at) VALUES(?,?,?)',
+ 'INSERT OR IGNORE INTO platform_payment_event_payloads(event_id,ciphertext,received_at) SELECT ?,?,? WHERE changes()=1',
)
.bind(event.id, payload, now),
])
diff --git a/tests/platform-payments.test.ts b/tests/platform-payments.test.ts
index 2622b49e..a3dc9bf2 100644
--- a/tests/platform-payments.test.ts
+++ b/tests/platform-payments.test.ts
@@ -909,6 +909,30 @@ test('Paid checkout snapshots survive price edits; actual purchasers qualify wit
).user_id,
null,
)
+ assert.equal(
+ (await paymentEventPayload(f.db, root, 'evt_saved_quote', f.now))
+ .available,
+ false,
+ )
+ assert.ok(
+ await f.db
+ .prepare(
+ "SELECT id FROM platform_payment_events WHERE id='evt_saved_quote'",
+ )
+ .first(),
+ )
+ await (
+ await f.event(
+ 'evt_saved_quote',
+ 'checkout.completed',
+ f.checkouts.get('chk_1'),
+ )
+ ).receive()
+ assert.equal(
+ (await paymentEventPayload(f.db, root, 'evt_saved_quote', f.now))
+ .available,
+ false,
+ )
assert.equal((await resolveSubscription(f.db, 1, f.now)).id, 'free')
} finally {
await f.mf.dispose()
@@ -1512,6 +1536,16 @@ test('Signed webhook payloads are encrypted, bound to their event, paginated and
).n,
0,
)
+ await (
+ await f.event('evt_page_000', 'refund.created', {
+ id: 'refund_0',
+ mode: 'test',
+ })
+ ).receive()
+ assert.equal(
+ (await paymentEventPayload(f.db, root, 'evt_page_000', f.now)).available,
+ false,
+ )
assert.equal(
(
await f.db