Lithic (Lithic v1.0.0)

Copy Markdown View Source

Elixir client for the Lithic API.

Installation

Add to your mix.exs:

{:lithic, "~> 1.0"}

Configuration

# config/config.exs
config :lithic,
  api_key: System.get_env("LITHIC_API_KEY"),
  environment: :production   # or :sandbox

Quick Start

# Cards
{:ok, card} = Lithic.Cards.create(%{type: "VIRTUAL"})
{:ok, page} = Lithic.Cards.list(page_size: 25)
Lithic.Cards.stream() |> Enum.take(50)

# Payments
{:ok, payment} = Lithic.Payments.create(%{
  financial_account_token: "fa_token",
  external_bank_account_token: "eba_token",
  amount: 5000,
  direction: "DEBIT",
  method: "ACH_NEXT_DAY",
  method_attributes: %{sec_code: "PPD"},
  type: "PAYMENT"
})

# Per-request client override
client = Lithic.Client.new(api_key: "other_key", environment: :sandbox)
{:ok, card} = Lithic.Cards.create(%{type: "VIRTUAL"}, client: client)

Pagination

# Cursor-based page
{:ok, page} = Lithic.Cards.list()
page.has_more   #=> true
{:ok, next}  = Lithic.Page.next(page)

# Lazy stream
Lithic.Transactions.stream(card_token: "tok_...")
|> Stream.filter(&(&1["result"] == "APPROVED"))
|> Enum.take(100)

# Collect all (use carefully on large datasets)
{:ok, all} = Lithic.Cards.list() |> then(fn {:ok, p} -> Lithic.Page.collect_all(p) end)

Webhooks

# In your Plug/Phoenix controller:
Lithic.Webhook.verify(raw_body, signature_header, timestamp_header, secret: "whsec_...")

Telemetry

All requests emit:

  • [:lithic, :request_start] — before the request
  • [:lithic, :request_stop] — after success, includes :duration
  • [:lithic, :request_exception] — on error, includes :error

Resources

ModuleDescription
Lithic.CardsCard lifecycle, balances, provisioning
Lithic.AccountsAccount management and spend limits
Lithic.AccountHoldersKYC/KYB verification
Lithic.AuthRulesV2 authorization rules engine
Lithic.AuthStreamAccessReal-time ASA webhook
Lithic.TransactionsCard transactions and sandbox simulation
Lithic.PaymentsACH payments
Lithic.BookTransfersInternal fund transfers
Lithic.ExternalBankAccountsACH counterparty accounts
Lithic.ExternalPaymentsExternal payment lifecycle
Lithic.FinancialAccountsLedger, balances, credit config
Lithic.BalancesBalance queries
Lithic.HoldsFinancial holds
Lithic.ManagementOperationsManual ledger adjustments
Lithic.CardBulkOrdersBulk physical card orders
Lithic.ThreeDS3DS authentication and decisioning
Lithic.TokenizationDigital wallet tokenization
Lithic.EventsWebhooks and event subscriptions
Lithic.ChargebacksChargeback/dispute (legacy)
Lithic.DisputesDisputes V2
Lithic.FraudReportsFraud report management
Lithic.CreditCredit products, statements, loan tapes
Lithic.SettlementSettlement summaries
Lithic.NetworkNetwork programs and totals
Lithic.FundingEventsProgram-level funding
Lithic.TransactionMonitoringCases and queues

Summary

Functions

Check API connectivity. Returns {:ok, %{"status" => "OK"}} on success.

Functions

status(opts \\ [])

@spec status(keyword()) :: {:ok, map()} | {:error, Lithic.Error.t()}

Check API connectivity. Returns {:ok, %{"status" => "OK"}} on success.