Documentation
¶
Overview ¶
Package clearbank provides a production-grade Go client for the ClearBank UK API.
The package covers all ClearBank API surface areas:
- GBP Accounts (real and virtual account management, transactions, Bacs data, camt.053 reporting)
- GBP Payments (FPS, CHAPS, Bacs, Bacs DDIs, Cheques, GBP Cross-Border, Confirmation of Payee)
- Multi-currency & FX (account management, international payments, SEPA SCT UK, FX spot & RFQ)
- Embedded Banking (retail/sole-trader/legal-entity customers, payment/savings/ISA accounts, KYC)
- Webhooks (signature verification, typed event dispatch)
Quick Start ¶
client, err := clearbank.New(clearbank.Config{
APIToken: os.Getenv("CLEARBANK_API_TOKEN"),
PrivateKeyPath: os.Getenv("CLEARBANK_PRIVATE_KEY_PATH"),
Environment: clearbank.Simulation,
})
if err != nil {
log.Fatal(err)
}
accounts, err := client.Accounts.List(ctx, clearbank.ListAccountsParams{})
Authentication ¶
Every mutating request (POST, PUT, PATCH) requires a DigitalSignature header computed by RSA-SHA256 signing the request body with your private key. The client handles this automatically when PrivateKeyPEM or PrivateKeyPath is configured.
Environments ¶
Use Simulation for integration testing and Production for live traffic.
Error Handling ¶
All API errors are returned as *APIError, which includes the HTTP status code, ClearBank error message, and the X-Correlation-Id for support escalation.
Idempotency ¶
Every request includes a unique X-Request-Id (UUID v4). For retrying failed mutating requests, use RequestOption WithRequestID to reuse the same ID.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRequestID ¶
func GenerateRequestID() string
GenerateRequestID returns a new UUID v4 for use as X-Request-Id.
func ParseRSAPublicKey ¶
ParseRSAPublicKey decodes a PEM-encoded RSA public key for webhook verification.
Types ¶
type APIError ¶
type APIError = httpclient.APIError
APIError represents a structured error returned by the ClearBank API.
type Client ¶
type Client struct {
// Accounts provides GBP real and virtual account management.
Accounts *accounts.Service
// Payments provides GBP payment operations (FPS, CHAPS, Bacs, CoP, etc.).
Payments *payments.Service
// MultiCurrency provides multi-currency account management and FX operations.
MultiCurrency *multicurrency.Service
// Embedded provides Banking-as-a-Service customer and account management.
Embedded *embedded.Service
// Webhooks provides signature verification and typed event parsing.
Webhooks *webhooks.Service
}
Client is the top-level ClearBank API client. Create one with New and reuse it across your application.
type Config ¶
type Config = httpclient.Config
Config holds all configuration for the ClearBank client.
type Environment ¶
type Environment = httpclient.Environment
Environment selects between Simulation and Production API endpoints.
const ( // Simulation targets https://institution-api-sim.clearbank.co.uk Simulation Environment = httpclient.Simulation // Production targets https://institution-api.clearbank.co.uk Production Environment = httpclient.Production )
type ListAccountsParams ¶
type ListAccountsParams = accounts.ListAccountsParams
Re-export type aliases used by callers.
type RequestOption ¶
type RequestOption = httpclient.RequestOption
RequestOption configures individual API requests.
func WithRequestID ¶
func WithRequestID(id string) RequestOption
WithRequestID sets a specific X-Request-Id on the request. Use this when retrying a failed mutating request with the same ID to satisfy ClearBank's idempotency requirement.
type TelemetryEvent ¶
TelemetryEvent carries observability data for a single API request.
type TelemetryHook ¶
TelemetryHook is called after every HTTP request with observability data.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
example
command
Command example demonstrates the clearbank-go client library.
|
Command example demonstrates the clearbank-go client library. |
|
domain
|
|
|
accounts
Package accounts provides GBP account management for the ClearBank API.
|
Package accounts provides GBP account management for the ClearBank API. |
|
embedded
Package embedded provides Banking-as-a-Service customer and account management.
|
Package embedded provides Banking-as-a-Service customer and account management. |
|
multicurrency
Package multicurrency provides multi-currency account management, international payments, SEPA SCT UK, and FX operations.
|
Package multicurrency provides multi-currency account management, international payments, SEPA SCT UK, and FX operations. |
|
payments
Package payments provides GBP payment operations for the ClearBank API.
|
Package payments provides GBP payment operations for the ClearBank API. |
|
webhooks
Package webhooks provides ClearBank webhook signature verification and typed event parsing.
|
Package webhooks provides ClearBank webhook signature verification and typed event parsing. |
|
internal
|
|
|
platform/crypto
Package crypto provides RSA signing and verification for the ClearBank API.
|
Package crypto provides RSA signing and verification for the ClearBank API. |
|
platform/httpclient
Package httpclient provides the shared HTTP infrastructure for the ClearBank API client.
|
Package httpclient provides the shared HTTP infrastructure for the ClearBank API client. |
|
platform/telemetry
Package telemetry defines the observability hook for HTTP requests.
|
Package telemetry defines the observability hook for HTTP requests. |
|
pkg
|
|
|
ptr
Package ptr provides convenience functions for creating pointers to primitive values.
|
Package ptr provides convenience functions for creating pointers to primitive values. |
|
Package testutil provides test helpers for the clearbank-go package.
|
Package testutil provides test helpers for the clearbank-go package. |