feat(billing): stamp OUR fee footer on draft transfer invoices - #3216
feat(billing): stamp OUR fee footer on draft transfer invoices#3216riderx wants to merge 1 commit into
Conversation
On invoice.created and invoice.updated webhooks, update draft transfer invoices via Stripe API so US bank wire senders are told to use OUR (sender pays all correspondent fees) instead of SHA/shared fees. Transfer invoices are identified by send_invoice collection or bank-transfer payment method types. Card-only charge_automatically invoices are skipped. Co-authored-by: Martin DONADIEU <martindonadieu@gmail.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
|
dimin4241-svg
left a comment
There was a problem hiding this comment.
Please preserve existing invoice footer content when adding the wire instruction.
|
|
||
| try { | ||
| await getStripe(c).invoices.update(invoice.id, { | ||
| footer: TRANSFER_INVOICE_FOOTER, |
There was a problem hiding this comment.
This replaces any existing draft-invoice footer that does not already contain the marker. A customer-specific footer (tax/legal wording, PO instructions, support contact, etc.) therefore gets silently deleted as soon as Stripe emits invoice.created or invoice.updated. Please append the transfer sentence to invoice.footer (while respecting Stripe’s footer length limit), or skip non-empty footers; add a test with unrelated pre-existing footer text so this content cannot be lost.



Summary (AI generated)
invoice.createdandinvoice.updatedin the existing Stripe webhook (stripe_event.ts).invoices.updateto set a footer instructing US bank wire senders to use OUR (sender pays all correspondent/intermediary fees), not SHA/shared fees.collection_methodissend_invoice, or whenpayment_settings.payment_method_typesincludes any bank-transfer type (customer_balance,us_bank_account,ach_credit_transfer,ach_debit,sepa_debit,acss_debit,bacs_debit,au_becs_debit).charge_automatically/ card-only invoices, non-draft invoices, and invoices that already contain the OUR footer marker.Motivation (AI generated)
US bank wire payments often arrive short when senders use SHA/shared fees. Adding the OUR instruction directly on the invoice PDF gives customers clear guidance before they send payment, without changing account defaults or bulk-updating customers.
Business Impact (AI generated)
Reduces underpaid wire transfers and manual reconciliation for bank-transfer billing. Card and auto-charge customers are unaffected. No change to subscription or revenue accounting logic.
Test Plan (AI generated)
bun run test:unit -- tests/stripe-invoice-footer.unit.test.ts— transfer filter, skip rules, andextractDataEventfor invoice eventsinvoice.created(and optionallyinvoice.updated) to/triggers/stripe_eventsend_invoiceinvoice for a test customer and verify the footer is stamped before finalizecharge_automaticallycard invoice does not get the footerGenerated with AI
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.