Marqeta.Credit.Accounts (marqeta v1.0.0)

Copy Markdown View Source

Create and manage credit accounts (the core object of the credit platform).

A credit account centres around a single credit line, accessed by one or more cards. APR, fees, and rewards are inherited from the bundle's policies.

Credit Limit

Range: 0–1,000,000. Required at creation.

Config Fields

  • billing_cycle_day — Day of month billing closes (1–28)
  • payment_due_interval — Days after billing close that payment is due
  • e_disclosure_active — Electronic disclosure consent
  • card_levelPREMIUM, TRADITIONAL, or NA

Examples

{:ok, account} = Marqeta.Credit.Accounts.create(%{
  user_token:   "user_01",
  bundle_token: "bundle_01",
  credit_limit: 5_000.00,
  config: %{
    billing_cycle_day:    1,
    payment_due_interval: 25,
    e_disclosure_active:  true,
    card_level:           "TRADITIONAL"
  }
})

Summary

Functions

Returns the current balance for a credit account.

Creates a new credit account.

Creates a new credit account. Raises Marqeta.Error on failure.

Retrieves a credit account by token.

Retrieves a credit account by token. Raises Marqeta.Error on failure.

Lists credit account resources.

Lists credit account resources. Raises Marqeta.Error on failure.

Lists credit accounts for a business.

Lists credit accounts for a user.

Returns a lazy Stream that auto-paginates credit account resources.

Streams credit accounts for a user.

Updates an existing credit account.

Updates an existing credit account. Raises Marqeta.Error on failure.

Functions

balance(token, opts \\ [])

@spec balance(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Marqeta.Error.t()}

Returns the current balance for a credit account.

create(params \\ %{}, opts \\ [])

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

Creates a new credit account.

Returns {:ok, map()} on success, {:error, %Marqeta.Error{}} on failure.

create!(params \\ %{}, opts \\ [])

@spec create!(
  map(),
  keyword()
) :: map()

Creates a new credit account. Raises Marqeta.Error on failure.

get(token, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Marqeta.Error.t()}

Retrieves a credit account by token.

Returns {:ok, map()} on success, {:error, %Marqeta.Error{}} on failure.

get!(token, opts \\ [])

@spec get!(
  String.t(),
  keyword()
) :: map()

Retrieves a credit account by token. Raises Marqeta.Error on failure.

list(params \\ %{}, opts \\ [])

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

Lists credit account resources.

Accepts standard Marqeta pagination params: count, start_index, sort_by, sort_order, fields.

Use stream/2 to lazily iterate all pages automatically.

list!(params \\ %{}, opts \\ [])

@spec list!(
  map(),
  keyword()
) :: map()

Lists credit account resources. Raises Marqeta.Error on failure.

list_by_business(token, params \\ %{}, opts \\ [])

@spec list_by_business(String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, Marqeta.Error.t()}

Lists credit accounts for a business.

list_by_user(user_token, params \\ %{}, opts \\ [])

@spec list_by_user(String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, Marqeta.Error.t()}

Lists credit accounts for a user.

stream(params \\ %{}, opts \\ [])

@spec stream(
  map(),
  keyword()
) :: Enumerable.t()

Returns a lazy Stream that auto-paginates credit account resources.

stream_by_user(user_token, params \\ %{})

@spec stream_by_user(String.t(), map()) :: Enumerable.t()

Streams credit accounts for a user.

update(token, params, opts \\ [])

@spec update(String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, Marqeta.Error.t()}

Updates an existing credit account.

Returns {:ok, map()} on success, {:error, %Marqeta.Error{}} on failure.

update!(token, params, opts \\ [])

@spec update!(String.t(), map(), keyword()) :: map()

Updates an existing credit account. Raises Marqeta.Error on failure.