Documentation
¶
Overview ¶
Package bankingcircle is a production-grade Go client for the Banking Circle Connect API (https://docs.bankingcircleconnect.com): cross-border payments (single & bulk), accounts, virtual accounts (VIBANs), FX (market order / RFQ / held-rate trading, plus WebSocket quote streaming), reporting, case management (RFI / recall), direct debit collections, ISO20022 message transport, and webhooks (subscription management + AES-256-GCM payload verification).
Design goals ¶
- Zero third-party runtime dependencies (standard library only).
- Domain-driven package layout: each bounded context (payments, accounts, fx, ...) owns its entities, validation, and service in a single package, built on top of the shared kernel in internal/.
- OAuth2/JWT auth with cached, single-flight-refreshed tokens.
- Client-side request validation before any network call.
- Safe retries with full-jitter exponential backoff, restricted to idempotent/idempotency-keyed requests to avoid duplicate payment submission.
- Structured, classifiable errors (*bankingcircle.Error) normalizing both of Banking Circle's documented error body shapes.
- context.Context on every network-calling method for cancellation, deadlines, and tracing propagation.
Quick start ¶
client, err := bankingcircle.New(
bankingcircle.WithEnvironment(bankingcircle.Sandbox),
bankingcircle.WithCredentials(username, password, certThumbprint),
)
if err != nil {
log.Fatal(err)
}
payment, err := client.Payments.CreateSingle(ctx, payments.CreateSingleInput{
DebtorAccountID: "acc_123",
Amount: "100.50",
Currency: "EUR",
CreditorName: "Jane Doe",
CreditorIBAN: "DE89370400440532013000",
TransactionReference: "INV-2026-001",
})
Scope ¶
This package implements the full documented Banking Circle Connect API surface: Authentication, Payments (single & bulk, recalls, traces, Correspondent/Agency Banking), Accounts (balances, bookings, AHV), Virtual Accounts, Webhooks (subscriptions + verification), FX (trading, RFQ, held rates, streaming), Reporting (async + synchronous reconciliation), Case Management (RFI/Recall), Direct Debit Collections, and ISO20022 message transport.
Deliberately out of scope: Correspondent/Agency Banking over the raw SWIFT FIN network (MT101/MT103 message exchange is not an HTTP endpoint), and Aliases (PayID, etc.) — Banking Circle's docs describe this feature but do not publish REST endpoint paths/payload shapes for it anywhere we could find; inventing plausible-looking endpoints for a payment-routing feature is actively dangerous, not just inconvenient.
See the README for full usage examples and the package-level docs of each bounded-context package (payments, accounts, virtualaccounts, fx, reporting, cases, directdebit, iso20022, webhooks, webhook) for details.
Index ¶
- Constants
- type Client
- type Config
- type Environment
- type Error
- type ErrorDetail
- type ErrorKind
- type MissingFieldError
- type NoopTelemetry
- type Option
- func WithBaseURLOverrides(apiBaseURL, authBaseURL string) Option
- func WithClientCertificate(certPath, keyPath string) Option
- func WithCredentials(username, password, certificateThumbprint string) Option
- func WithEnvironment(env Environment) Option
- func WithHTTPClient(client *http.Client) Option
- func WithMaxRetries(n int) Option
- func WithName(name string) Option
- func WithRequestTimeout(d time.Duration) Option
- func WithRetryBaseDelay(d time.Duration) Option
- func WithTelemetry(t Telemetry) Option
- func WithWebhookEncryptionKey(key string) Option
- type Telemetry
- type ValidationError
Constants ¶
const ( KindTransport = apierrors.KindTransport KindTimeout = apierrors.KindTimeout KindAuth = apierrors.KindAuth KindValidation = apierrors.KindValidation KindRateLimited = apierrors.KindRateLimited KindConcurrencyConflict = apierrors.KindConcurrencyConflict KindNotFound = apierrors.KindNotFound KindClientError = apierrors.KindClientError KindServerError = apierrors.KindServerError KindUnexpectedResponse = apierrors.KindUnexpectedResponse )
Error kind constants — see ErrorKind.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Payments *payments.Service
Accounts *accounts.Service
VirtualAccounts *virtualaccounts.Service
FX *fx.Service
Reporting *reporting.Service
Cases *cases.Service
DirectDebit *directdebit.Service
ISO20022 *iso20022.Service
Webhooks *webhooks.Service
// contains filtered or unexported fields
}
Client is a fully-configured Banking Circle Connect client. Build one with New. Every bounded-context service is exposed as a field — Payments, Accounts, VirtualAccounts, FX, Reporting, Cases, DirectDebit, ISO20022, Webhooks — each independently documented in its own package.
A Client is safe for concurrent use by multiple goroutines; create one Client per Banking Circle account/legal-entity credential pair and share it, rather than constructing one per request.
func New ¶
New builds a Client from the given Options. WithEnvironment and WithCredentials are required; every other option has a sensible default. Returns an error if the resolved configuration is invalid (e.g. missing credentials, mismatched mTLS cert/key) — no network call is made during construction, since Banking Circle tokens are fetched lazily on first use and cached thereafter.
func (*Client) InvalidateToken ¶
func (c *Client) InvalidateToken()
InvalidateToken discards the cached bearer token, forcing a fresh authorization request on the next API call. Rarely needed — the client refreshes proactively before expiry — but useful if you suspect a token was revoked out-of-band.
type Config ¶
type Config struct {
Name string
Environment Environment
Username string
Password string
CertificateThumbprint string
// ClientCertPath / ClientKeyPath configure mTLS, which Banking Circle
// requires at the transport layer in addition to Basic-auth
// credentials at the token endpoint. Both must be set together, or
// both left empty.
ClientCertPath string
ClientKeyPath string
// WebhookEncryptionKey is the 32-character pre-shared AES-256-GCM key
// used by the webhook package to decrypt inbound payloads. Optional
// here — it can also be passed per-call to webhook.VerifyAndDecrypt.
WebhookEncryptionKey string
RequestTimeout time.Duration
MaxRetries int
RetryBaseDelay time.Duration
// HTTPClient, if set, is used as the base HTTP client (its Transport
// is reused for the no-redirect variant used by Reporting). Leave nil
// to have one built automatically, applying mTLS if ClientCertPath /
// ClientKeyPath are set.
HTTPClient *http.Client
Telemetry Telemetry
// APIBaseURLOverride / AuthBaseURLOverride are test/proxy escape
// hatches — not part of normal usage.
APIBaseURLOverride string
AuthBaseURLOverride string
}
Config is the fully-resolved, validated configuration for one Client instance. Build it via New with functional Options rather than constructing it directly.
type Environment ¶
type Environment string
Environment identifies which Banking Circle Connect environment a Client talks to. Sandbox and production use entirely separate hosts, credentials, and client certificates — mixing them up is the most common integration mistake, so Environment is the single source of truth for host resolution.
const ( // Sandbox is Banking Circle's testing environment. Sandbox Environment = "sandbox" // Production is Banking Circle's live environment. Production Environment = "production" )
func (Environment) APIBaseURL ¶
func (e Environment) APIBaseURL() string
APIBaseURL returns the REST API base URL for e.
func (Environment) AuthBaseURL ¶
func (e Environment) AuthBaseURL() string
AuthBaseURL returns the OAuth2 token endpoint base URL for e.
func (Environment) Validate ¶
func (e Environment) Validate() error
Validate reports whether e is a recognized environment.
func (Environment) WebSocketURL ¶
func (e Environment) WebSocketURL() string
WebSocketURL returns the FX streaming WebSocket URL for e.
type Error ¶
Error is the canonical error representation for every failure mode this client can surface: transport failures, HTTP 4xx/5xx responses (in either of Banking Circle's two documented error body shapes), auth failures, and client-side validation errors raised before a request is ever sent.
type ErrorDetail ¶
type ErrorDetail = apierrors.ErrorDetail
ErrorDetail is one normalized entry from either of Banking Circle's two documented error body shapes.
type MissingFieldError ¶
type MissingFieldError = apierrors.MissingFieldError
MissingFieldError is returned when a dynamically-required field (e.g. either Tenor or QuoteID on FX.Trade) is absent.
type NoopTelemetry ¶
type NoopTelemetry struct{}
NoopTelemetry implements Telemetry with no-op methods; it is the default when WithTelemetry is not supplied.
func (NoopTelemetry) OnRequestStart ¶
func (NoopTelemetry) OnRequestStart(context.Context, string, string)
OnRequestStart implements Telemetry.
type Option ¶
type Option func(*Config)
Option configures a Client at construction time. See New.
func WithBaseURLOverrides ¶
WithBaseURLOverrides overrides the API and/or auth base URLs — a test/proxy escape hatch, not for normal usage. Pass "" to leave either at its environment default.
func WithClientCertificate ¶
WithClientCertificate configures mTLS using a PEM certificate/key pair on disk. Banking Circle requires client-certificate authentication at the transport layer in addition to the Basic-auth credentials from WithCredentials.
func WithCredentials ¶
WithCredentials sets the OAuth2 Basic-auth username/password and the X-Certificate-Thumbprint header value Banking Circle requires at the token endpoint. Required.
func WithEnvironment ¶
func WithEnvironment(env Environment) Option
WithEnvironment selects Sandbox or Production. Required.
func WithHTTPClient ¶
WithHTTPClient supplies a pre-configured *http.Client (e.g. with a custom Transport for proxying/mocking in tests). When set, mTLS configured via WithClientCertificate is ignored — configure it on the supplied client's Transport instead.
func WithMaxRetries ¶
WithMaxRetries sets how many additional attempts are made after the first, for eligible requests (GET/HEAD, or any method carrying an Idempotency-Key). Defaults to 3.
func WithName ¶
WithName sets a label for this client instance, used only in telemetry metadata — useful when a process holds multiple Clients (e.g. one per legal entity) and needs to tell their metrics apart.
func WithRequestTimeout ¶
WithRequestTimeout sets the per-request timeout (applied per attempt, not across retries). Defaults to 15s.
func WithRetryBaseDelay ¶
WithRetryBaseDelay sets the base delay for full-jitter exponential backoff between retries (capped at 8s). Defaults to 250ms.
func WithTelemetry ¶
WithTelemetry attaches a Telemetry implementation to receive per-request lifecycle events.
func WithWebhookEncryptionKey ¶
WithWebhookEncryptionKey sets the default 32-character pre-shared AES-256-GCM key used to decrypt inbound webhook payloads. Optional — it can also be passed per-call.
type Telemetry ¶
type Telemetry interface {
// OnRequestStart is called immediately before a request is sent.
OnRequestStart(ctx context.Context, method, path string)
// OnRequestStop is called after a request completes (successfully or
// not), including retries — duration covers the full retry sequence.
// err is non-nil only for transport-level failures (a non-2xx HTTP
// response is not, itself, an error at this layer).
OnRequestStop(ctx context.Context, method, path string, duration time.Duration, status int, err error)
}
Telemetry receives lifecycle notifications for every outgoing request, mirroring the :telemetry events emitted by the reference Elixir client ([:banking_circle, :request, :start|:stop|:exception]). Implement this interface and pass it via WithTelemetry to feed metrics/tracing systems (Prometheus, OpenTelemetry, structured logging, ...).
Implementations must be safe for concurrent use, since requests from every service (Payments, Accounts, FX, ...) share one Client.
type ValidationError ¶
type ValidationError = apierrors.ValidationError
ValidationError represents a client-side validation failure raised before any network call is made.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package accounts implements account and balance operations: listing accounts, fetching balances, listing bookings (the transaction-level ledger), and Account Holder Verification (AHV / Confirmation-of-Payee style checks across supported schemes).
|
Package accounts implements account and balance operations: listing accounts, fetching balances, listing bookings (the transaction-level ledger), and Account Holder Verification (AHV / Confirmation-of-Payee style checks across supported schemes). |
|
Package cases implements Case Management: Banking Circle raises a Case when it needs something from you — most commonly an RFI (Request for Information, usually a sanctions-screening hold on a payment) or a Recall Case (the counterparty bank asking you to return a payment they sent you).
|
Package cases implements Case Management: Banking Circle raises a Case when it needs something from you — most commonly an RFI (Request for Information, usually a sanctions-screening hold on a payment) or a Recall Case (the counterparty bank asking you to return a payment they sent you). |
|
Package directdebit implements Direct Debit Collections: initiating a collection against a pre-authorized mandate you (the creditor) hold on the debtor's account.
|
Package directdebit implements Direct Debit Collections: initiating a collection against a pre-authorized mandate you (the creditor) hold on the debtor's account. |
|
examples
|
|
|
basic
command
Command basic demonstrates the major bankingcircle-go workflows: client construction, a single payment, an account balance lookup, an FX quote, and webhook payload verification.
|
Command basic demonstrates the major bankingcircle-go workflows: client construction, a single payment, an account balance lookup, an FX quote, and webhook payload verification. |
|
webhookreceiver
command
Command webhookreceiver demonstrates handling an inbound Banking Circle webhook: reading the encrypted body, verifying and decrypting it via the webhook package, and dispatching on event type.
|
Command webhookreceiver demonstrates handling an inbound Banking Circle webhook: reading the encrypted body, verifying and decrypting it via the webhook package, and dispatching on event type. |
|
Package fx implements foreign exchange: market-order trading, Request-for-Quote (RFQ), indicative rates, held rates, and trade/exposure lookups.
|
Package fx implements foreign exchange: market-order trading, Request-for-Quote (RFQ), indicative rates, held rates, and trade/exposure lookups. |
|
internal
|
|
|
apierrors
Package apierrors defines the canonical Error type shared by every bounded-context service package (payments, accounts, fx, ...) and the shared HTTP pipeline: transport failures, HTTP 4xx/5xx responses (normalizing both of Banking Circle's documented error body shapes), auth failures, and client-side validation errors.
|
Package apierrors defines the canonical Error type shared by every bounded-context service package (payments, accounts, fx, ...) and the shared HTTP pipeline: transport failures, HTTP 4xx/5xx responses (normalizing both of Banking Circle's documented error body shapes), auth failures, and client-side validation errors. |
|
auth
Package auth caches and refreshes the Banking Circle OAuth2 JWT access token used to authorize every REST and WebSocket call.
|
Package auth caches and refreshes the Banking Circle OAuth2 JWT access token used to authorize every REST and WebSocket call. |
|
httpclient
Package httpclient builds the shared HTTP request pipeline used by every bounded-context service package (payments, accounts, fx, ...): base-URL resolution, bearer-token injection via a TokenFetcher, jittered-backoff retries restricted to safe requests, idempotency-key support, telemetry hooks, and raw response passthrough so callers can decide how to interpret non-2xx / non-JSON responses (e.g.
|
Package httpclient builds the shared HTTP request pipeline used by every bounded-context service package (payments, accounts, fx, ...): base-URL resolution, bearer-token injection via a TokenFetcher, jittered-backoff retries restricted to safe requests, idempotency-key support, telemetry hooks, and raw response passthrough so callers can decide how to interpret non-2xx / non-JSON responses (e.g. |
|
wsclient
Package wsclient is a minimal, dependency-free client-side implementation of RFC 6455 WebSockets, sufficient for the FX streaming use case in the fx package: text-frame JSON messages, fragmented message reassembly, automatic ping/pong, and a clean close handshake.
|
Package wsclient is a minimal, dependency-free client-side implementation of RFC 6455 WebSockets, sufficient for the FX streaming use case in the fx package: text-frame JSON messages, fragmented message reassembly, automatic ping/pong, and a clean close handshake. |
|
Package iso20022 implements payment initiation via raw ISO20022 XML messages, for shops already standardized on pain.001 (customer credit transfer initiation) or pacs.008 (FI-to-FI credit transfer) rather than Banking Circle's JSON payment shape.
|
Package iso20022 implements payment initiation via raw ISO20022 XML messages, for shops already standardized on pain.001 (customer credit transfer initiation) or pacs.008 (FI-to-FI credit transfer) rather than Banking Circle's JSON payment shape. |
|
Package payments implements single and bulk payment initiation, status tracking, cancellation, lookup, recalls, traces, and Correspondent / Agency Banking (FI-to-FI) payments, per Banking Circle's Payment Lifecycle documentation.
|
Package payments implements single and bulk payment initiation, status tracking, cancellation, lookup, recalls, traces, and Correspondent / Agency Banking (FI-to-FI) payments, per Banking Circle's Payment Lifecycle documentation. |
|
Package reporting implements asynchronous report generation: request a report, poll its status, then download it once ready — the three-step flow Banking Circle uses for reports too large to return synchronously (reconciliation, account activity, rejections, bank statements, camt.053, etc), plus the one report type (Reconciliation) that also has a synchronous endpoint.
|
Package reporting implements asynchronous report generation: request a report, poll its status, then download it once ready — the three-step flow Banking Circle uses for reports too large to return synchronously (reconciliation, account activity, rejections, bank statements, camt.053, etc), plus the one report type (Reconciliation) that also has a synchronous endpoint. |
|
Package virtualaccounts implements Virtual Accounts (VIBANs): externally addressable IBANs that route to one or more physical Master Accounts rather than holding funds themselves.
|
Package virtualaccounts implements Virtual Accounts (VIBANs): externally addressable IBANs that route to one or more physical Master Accounts rather than holding funds themselves. |
|
Package webhook decrypts and verifies incoming Banking Circle webhook payloads.
|
Package webhook decrypts and verifies incoming Banking Circle webhook payloads. |
|
Package webhooks manages webhook subscriptions (create/list/activate/deactivate/remove) via the notification self-service API.
|
Package webhooks manages webhook subscriptions (create/list/activate/deactivate/remove) via the notification self-service API. |