paidInvoicePayments (providers/stripe-invoice-payments.ts)

rekey · apps/api/src/modules/billing/providers/stripe-invoice-payments.ts · typescript · MIT
payments

Fetches Stripe invoice payments for refunds and tracks out-of-band payments.

// Source: https://github.com/rekey-dev/rekey | License: MIT | Copyright 2026 Rekey
// Provided via justclaw.it.com; keep this notice with the code.
import type Stripe from 'stripe';

/** What Stripe's Refunds API accepts as the thing to refund. */
export type StripeRefundTarget = { payment_intent: string } | { charge: string };

function idOf(ref: string | { id: string } | null | undefined): string | null {
  if (typeof ref === 'string') return ref;
  return ref?.id ?? null;
}

/** What settled an invoice, split by whether Stripe can pay it back. */
export interface PaidInvoicePayments {
  /** Payments that moved through Stripe, as refund targets. */
  targets: StripeRefundTarget[];
  /** Paid payments recorded outside Stripe (out of band), which Stripe cannot refund. */
  outsideStripe: 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key