GoCardlessClient.Resources.Payments (GoCardlessClient v2.0.0)

Copy Markdown View Source

GoCardlessClient Payments API.

Payments are the core of GoCardlessClient — they represent money being pulled from a customer's bank account on a mandate.

Example

{:ok, payment} = GoCardlessClient.Resources.Payments.create(client, %{
  amount: 1500,
  currency: "GBP",
  description: "Monthly service fee",
  links: %{mandate: "MD123"}
}, idempotency_key: GoCardlessClient.new_idempotency_key())

Summary

Functions

Cancels a payment. Only possible before it is submitted to the banks.

Eagerly collects all payments into a list. Use stream/3 for large datasets.

Creates a payment against an existing mandate. Always pass an idempotency key to make retries safe.

Retrieves a single payment by ID.

Returns a single page of payments with optional filters (:status, :mandate, :customer, :created_at[gte], etc.).

Retries a failed payment on a new charge date.

Returns a lazy Stream over all pages of payments. Efficient for large datasets.

Updates a payment's description or metadata. Only possible before submission.

Functions

cancel(client, id, params \\ %{}, opts \\ [])

Cancels a payment. Only possible before it is submitted to the banks.

collect_all(client, params \\ %{}, opts \\ [])

@spec collect_all(GoCardlessClient.Client.t(), map(), keyword()) ::
  {:ok, [map()]}
  | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}

Eagerly collects all payments into a list. Use stream/3 for large datasets.

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

Creates a payment against an existing mandate. Always pass an idempotency key to make retries safe.

get(client, id, opts \\ [])

Retrieves a single payment by ID.

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

@spec list(GoCardlessClient.Client.t(), map(), keyword()) ::
  {:ok, %{items: [map()], meta: map()}}
  | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}

Returns a single page of payments with optional filters (:status, :mandate, :customer, :created_at[gte], etc.).

retry(client, id, params \\ %{}, opts \\ [])

Retries a failed payment on a new charge date.

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

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

Returns a lazy Stream over all pages of payments. Efficient for large datasets.

update(client, id, params, opts \\ [])

Updates a payment's description or metadata. Only possible before submission.