Creates Charge objects from PaymentIntents.
Handles the PI -> Charge -> BalanceTransaction chain that Stripe performs when a PaymentIntent succeeds. This is used by checkout session completion and the billing engine to produce the same object graph that real Stripe does.
Summary
Functions
Captures an authorized PaymentIntent charge and links the resulting balance transaction.
Creates a Charge (and its BalanceTransaction) for a succeeded PaymentIntent.
Functions
@spec capture_payment_intent_charge(map(), integer(), boolean()) :: {:ok, map()} | {:error, :not_found}
Captures an authorized PaymentIntent charge and links the resulting balance transaction.
Creates a Charge (and its BalanceTransaction) for a succeeded PaymentIntent.
- Builds a charge map from the PI fields
- Inserts into the Charges store
- Creates a BalanceTransaction via BalanceTransactionHelper
- Updates the charge with the balance_transaction ID
- Updates the PI with
latest_charge - Fires telemetry
- Returns
{:ok, charge}