# `PaperTiger.BalanceTransactionHelper`
[🔗](https://github.com/EnaiaInc/paper_tiger/blob/v1.2.2/lib/paper_tiger/balance_transaction_helper.ex#L1)

Helper functions for creating balance transactions.

Balance transactions are created automatically when:
- A charge is created (type: "charge")
- A refund is created (type: "refund")
- A payout is created (type: "payout")

## Fee Calculation

Stripe's standard fee is 2.9% + $0.30 per successful card charge.
For simplicity, PaperTiger uses this formula for all charges.

# `calculate_fee`

```elixir
@spec calculate_fee(integer()) :: integer()
```

Calculates Stripe's processing fee for a given amount.

Formula: 2.9% + $0.30 (in cents)

# `create_for_application_fee`

```elixir
@spec create_for_application_fee(map()) :: {:ok, String.t()} | {:error, term()}
```

Creates a platform-side balance transaction for an application fee.

# `create_for_application_fee_refund`

```elixir
@spec create_for_application_fee_refund(map()) :: {:ok, String.t()} | {:error, term()}
```

Creates a platform-side balance transaction for an application fee refund.

# `create_for_charge`

```elixir
@spec create_for_charge(map()) :: {:ok, String.t()} | {:error, term()}
```

Creates a balance transaction for a charge.

Returns the balance transaction ID.

# `create_for_destination_transfer`

```elixir
@spec create_for_destination_transfer(map()) :: {:ok, String.t()} | {:error, term()}
```

Creates a connected-account balance transaction for funds received by transfer.

# `create_for_destination_transfer_reversal`

```elixir
@spec create_for_destination_transfer_reversal(map()) ::
  {:ok, String.t()} | {:error, term()}
```

Creates the connected-account balance transaction for a transfer reversal.

# `create_for_refund`

```elixir
@spec create_for_refund(map(), map()) :: {:ok, String.t()} | {:error, term()}
```

Creates a balance transaction for a refund.

Refunds have negative amounts and return fees proportionally.

# `create_for_transfer`

```elixir
@spec create_for_transfer(map()) :: {:ok, String.t()} | {:error, term()}
```

Creates the platform-side balance transaction for a transfer.

# `create_for_transfer_reversal`

```elixir
@spec create_for_transfer_reversal(map()) :: {:ok, String.t()} | {:error, term()}
```

Creates the platform-side balance transaction for a transfer reversal.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
