Skip to content

Commit

Permalink
refactor(stripe): simplify invoice payment process
Browse files Browse the repository at this point in the history
- Remove unnecessary finalization step before payment
- Directly process invoice payment
- Remove error handling wrapper for cleaner flow
  • Loading branch information
gentamura committed Feb 6, 2025
1 parent 701c473 commit 9ba3e19
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions app/webhooks/stripe/handle-invoice-creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,5 @@ export async function handleInvoiceCreation(invoice: Stripe.Invoice) {
return;
}

await finalizeAndPayInvoice(invoice.id);
}

async function finalizeAndPayInvoice(invoiceId: string) {
try {
await stripe.invoices.finalizeInvoice(invoiceId);
await stripe.invoices.pay(invoiceId);
} catch (error) {
console.error(`Error processing invoice ${invoiceId}:`, error);
throw new Error("Failed to process invoice");
}
await stripe.invoices.pay(invoice.id);
}

0 comments on commit 9ba3e19

Please sign in to comment.