Skip to content

Commit be29b00

Browse files
authored
fix: do not sync draft invoices (#96)
There could be multiple draft invoices per subscription and we generally want to avoid syncing non-final invoices as the state could already be invalid a second after the sync.
1 parent 29d510c commit be29b00

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/orb-sync-lib/src/orb-sync.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ export class OrbSync {
233233
const webhook = parsedData as InvoiceWebhook;
234234

235235
this.config.logger?.info(`Received webhook ${webhook.id}: ${webhook.type} for invoice ${webhook.invoice.id}`);
236+
if (webhook.invoice.status === 'draft') {
237+
this.config.logger?.info(`Skipping sync for invoice ${webhook.invoice.id} in draft status`);
238+
break;
239+
}
236240

237241
await syncInvoices(this.postgresClient, [webhook.invoice], webhook.created_at);
238242
break;

0 commit comments

Comments
 (0)