PaperTiger.BalanceTransactionHelper (PaperTiger v1.1.0)

Copy Markdown View Source

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.

Summary

Functions

Calculates Stripe's processing fee for a given amount.

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

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

Creates a balance transaction for a charge.

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

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

Creates a balance transaction for a refund.

Creates the platform-side balance transaction for a transfer.

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

Functions

calculate_fee(amount)

@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(application_fee)

@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(refund)

@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(charge)

@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(transfer)

@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(reversal)

@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(refund, original_charge)

@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(transfer)

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

Creates the platform-side balance transaction for a transfer.

create_for_transfer_reversal(reversal)

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

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