MCPcopy Index your code
hub / github.com/simstudioai/sim / getCustomerIdFromDispute

Function getCustomerIdFromDispute

apps/sim/lib/billing/webhooks/disputes.ts:11–18  ·  view source on GitHub ↗
(dispute: Stripe.Dispute)

Source from the content-addressed store, hash-verified

9const logger = createLogger('DisputeWebhooks')
10
11async 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

Callers 2

handleChargeDisputeFunction · 0.85
handleDisputeClosedFunction · 0.85

Calls 1

requireStripeClientFunction · 0.90

Tested by

no test coverage detected