(dispute: Stripe.Dispute)
| 9 | const logger = createLogger('DisputeWebhooks') |
| 10 | |
| 11 | async function getCustomerIdFromDispute(dispute: Stripe.Dispute): Promise<string | null> { |
| 12 | const chargeId = typeof dispute.charge === 'string' ? dispute.charge : dispute.charge?.id |
| 13 | if (!chargeId) return null |
| 14 | |
| 15 | const stripe = requireStripeClient() |
| 16 | const charge = await stripe.charges.retrieve(chargeId) |
| 17 | return typeof charge.customer === 'string' ? charge.customer : (charge.customer?.id ?? null) |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Handles charge.dispute.created - blocks the responsible user |
no test coverage detected