Skip to content

Repository files navigation

Clearbank-go

A production-grade Go package for the ClearBank UK API.

Supports

GBP Accounts GBP Payments (FPS, CHAPS, Bacs, CoP, Cheques) Multi-currency & FX Embedded Banking Webhooks


Installation

go get github.com/iamkanishka/clearbank-go

Quick Start

client, err := clearbank.New(clearbank.Config{
    APIToken:       os.Getenv("CLEARBANK_API_TOKEN"),
    PrivateKeyPath: os.Getenv("CLEARBANK_PRIVATE_KEY_PATH"),
    Environment:    clearbank.Simulation,
})

Configuration

Create a client once and reuse it throughout your application.

Authentication

ClearBank requires:

  1. API Token
  2. RSA private key

The SDK automatically signs mutating requests when a private key is configured.

Accounts

  • List Accounts
  • Get Account
  • Create Virtual Account

Payments

  • Faster Payments (FPS)
  • CHAPS Payments
  • Confirmation of Payee

Multi-Currency & FX

  • Currency Accounts
  • International Payments
  • FX Quotes

Embedded Banking

  • Customers
  • Accounts

Webhooks

  • Signature Verification
  • Typed Event Handling

Error Handling

All API errors are returned as *clearbank.APIError.

Idempotency

Use clearbank.WithRequestID(...) when retrying mutating requests.

Telemetry

Register a telemetry hook to observe all API calls.

Security

  • Never commit your private_key.pem — add it to .gitignore
  • In production, load private keys from an HSM, not the filesystem
  • Rotate API tokens before their 1-year expiry
  • Verify all inbound webhook signatures before processing
  • Store X-Correlation-Id from error responses — required for ClearBank support

License

MIT — see LICENSE.


Releases

Packages

Contributors

Languages