PaperTiger.ChargeHelper (PaperTiger v1.0.2)

Copy Markdown View Source

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

Creates a Charge (and its BalanceTransaction) for a succeeded PaymentIntent.

Functions

create_for_payment_intent(payment_intent)

@spec create_for_payment_intent(map()) :: {:ok, map()}

Creates a Charge (and its BalanceTransaction) for a succeeded PaymentIntent.

  1. Builds a charge map from the PI fields
  2. Inserts into the Charges store
  3. Creates a BalanceTransaction via BalanceTransactionHelper
  4. Updates the charge with the balance_transaction ID
  5. Updates the PI with latest_charge
  6. Fires telemetry
  7. Returns {:ok, charge}