GoCardlessClient.Resources.Blocks (GoCardlessClient v2.0.0)

Copy Markdown View Source

GoCardless Blocks API.

Fraud prevention mechanism to block specific customers, email addresses, bank accounts, or device fingerprints from creating new mandates.

Block types

  • "email" — block a specific email address
  • "email_domain" — block an entire email domain
  • "device_fingerprint" — block by device fingerprint
  • "bank_account" — block a specific bank account

Example

{:ok, block} = GoCardlessClient.Resources.Blocks.create(client, %{
  block_type: "email",
  reason_type: "fraud",
  resource_reference: "fraudster@example.com"
})

Summary

Functions

Creates blocks by reference — blocks all accounts linked to an existing resource.

Eagerly collects all blocks into a list.

Disables a block, stopping it from preventing mandate creation.

Re-enables a previously disabled block.

Retrieves a single block by ID.

Returns a page of blocks. Filter by :block_type, :reason_type, :created_at[gte].

Returns a lazy Stream over all pages of blocks.

Functions

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

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

Creates blocks by reference — blocks all accounts linked to an existing resource.

For example, you can block all bank accounts and email addresses linked to a mandate or payment that was used fraudulently.

Params

  • :reference_type"mandate", "payment", "customer" (required)
  • :reference_id — ID of the reference resource (required)
  • :reason_type"fraud" or "other" (required)
  • :reason_description — optional human-readable reason

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

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

Creates a block.

Params

  • :block_type"email", "email_domain", "device_fingerprint", or "bank_account" (required)
  • :reason_type"fraud" or "other" (required)
  • :resource_reference — the value to block (required)
  • :reason_description — human-readable reason (optional)

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

Disables a block, stopping it from preventing mandate creation.

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

Re-enables a previously disabled block.

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

Retrieves a single block 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 blocks. Filter by :block_type, :reason_type, :created_at[gte].

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

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

Returns a lazy Stream over all pages of blocks.