Duffel.Payments (Duffel v0.1.0)

Copy Markdown View Source

Pay for hold orders that were booked without immediate payment.

See the Duffel documentation.

Summary

Functions

Creates a payment for a hold order.

Retrieves a single payment by ID.

Lists one page of payments.

Lazily streams all payments across pages.

Functions

create(client, params, opts \\ [])

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

Creates a payment for a hold order.

Options

  • :idempotency_key - value for the Idempotency-Key header. A key is generated when you do not pass one (see Duffel.Client.post/4).

Examples

Duffel.Payments.create(client, %{
  order_id: "ord_123",
  payment: %{type: "balance", currency: "GBP", amount: "30.20"}
})

get(client, id)

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

Retrieves a single payment by ID.

list(client, params \\ [])

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

Lists one page of payments.

Parameters

  • :order_id - filter payments by order
  • :limit / :after / :before - pagination (see Duffel.Page)

stream(client, params \\ [])

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

Lazily streams all payments across pages.

Takes the same parameters as list/2. Raises Duffel.Error if a page request fails.