GoCardlessClient.Resources.OutboundPayments (GoCardlessClient v2.0.0)

Copy Markdown View Source

GoCardless Outbound Payments API.

Outbound Payments send money from your Payment Account to recipients. They require API request signing with an ECDSA P-256 private key registered in your GoCardless dashboard.

Rate limiting

Outbound Payments has stricter rate limits than other endpoints. Check the GoCardlessClient.Client.rate_limit_state/1 after each call.

Outbound payment states

createdpending_approval (optional) → executingexecuted / failed / cancelled

Example — send a payment

signer = GoCardlessClient.Signing.new!(key_id: "kid", pem: pem)

{:ok, payment} = GoCardlessClient.Resources.OutboundPayments.create(client,
  %{
    amount: 50_000,
    currency: "GBP",
    description: "Supplier invoice #1234",
    recipient_bank_account: %{
      account_holder_name: "Acme Ltd",
      account_number: "12345678",
      branch_code: "204514",
      country_code: "GB"
    },
    links: %{creditor: "CR123", payment_account: "PA123"}
  },
  signer: signer,
  idempotency_key: GoCardlessClient.new_idempotency_key()
)

Example — withdraw funds to your own bank account

{:ok, withdrawal} = GoCardlessClient.Resources.OutboundPayments.withdrawal(client,
  %{
    amount: 100_000,
    currency: "GBP",
    links: %{
      payment_account: "PA123",
      creditor_bank_account: "BA456"
    }
  },
  signer: signer,
  idempotency_key: GoCardlessClient.new_idempotency_key()
)

Summary

Functions

Approves an outbound payment that is pending approval.

Cancels an outbound payment before it is executed.

Eagerly collects all outbound payments into a list.

Creates an outbound payment to a recipient.

Retrieves a single outbound payment by ID.

Returns a page of outbound payments. Filter by :status, :currency, :payment_account.

Returns aggregate statistics for outbound payments.

Returns a lazy Stream over all pages of outbound payments.

Updates an outbound payment's metadata. Only possible before execution.

Creates a withdrawal — sends funds from the Payment Account to your own creditor bank account. Useful for sweeping collected funds.

Functions

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

Approves an outbound payment that is pending approval.

SCA (Strong Customer Authentication) must be completed before calling this. The :signer option is required.

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

Cancels an outbound payment before it is executed.

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 outbound payments into a list.

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

Creates an outbound payment to a recipient.

Always pass an idempotency key and a :signer for safe retries and security.

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

Retrieves a single outbound 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 page of outbound payments. Filter by :status, :currency, :payment_account.

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

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

Returns aggregate statistics for outbound payments.

Returns counts and total amounts grouped by status and currency.

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

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

Returns a lazy Stream over all pages of outbound payments.

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

Updates an outbound payment's metadata. Only possible before execution.

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

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

Creates a withdrawal — sends funds from the Payment Account to your own creditor bank account. Useful for sweeping collected funds.