Skip to content

feat(billing): stamp OUR fee footer on draft transfer invoices - #3216

Draft
riderx wants to merge 1 commit into
mainfrom
cursor/stripe-invoice-footer-d30a
Draft

feat(billing): stamp OUR fee footer on draft transfer invoices#3216
riderx wants to merge 1 commit into
mainfrom
cursor/stripe-invoice-footer-d30a

Conversation

@riderx

@riderx riderx commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary (AI generated)

  • Handle invoice.created and invoice.updated in the existing Stripe webhook (stripe_event.ts).
  • On draft transfer invoices, call invoices.update to set a footer instructing US bank wire senders to use OUR (sender pays all correspondent/intermediary fees), not SHA/shared fees.
  • Treat invoices as transfer invoices when collection_method is send_invoice, or when payment_settings.payment_method_types includes any bank-transfer type (customer_balance, us_bank_account, ach_credit_transfer, ach_debit, sepa_debit, acss_debit, bacs_debit, au_becs_debit).
  • Skip charge_automatically / card-only invoices, non-draft invoices, and invoices that already contain the OUR footer marker.
  • Add unit tests for the transfer-invoice filter and webhook customer extraction.

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, and extractDataEvent for invoice events
  • Confirm Stripe webhook endpoint delivers invoice.created (and optionally invoice.updated) to /triggers/stripe_event
  • Create a draft send_invoice invoice for a test customer and verify the footer is stamped before finalize
  • Verify a charge_automatically card invoice does not get the footer

Generated with AI

Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

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>
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@dimin4241-svg dimin4241-svg left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please preserve existing invoice footer content when adding the wire instruction.


try {
await getStripe(c).invoices.update(invoice.id, {
footer: TRANSFER_INVOICE_FOOTER,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants