clearbank

package module
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

README

clearbank-api-client-go

Go Reference Go Report Card Maintainability Test Coverage

ClearBank API Client for Go

Installation

go get github.com/brokeyourbike/clearbank-api-client-go

Usage

client := clearbank.NewClient("token", signer)

err := client.Test(clearbank.RequestIdContext(context.TODO(), "123"), "hello")
require.NoError(t, err)

Authors

License

BSD-3-Clause License

Documentation

Index

Constants

View Source
const (
	AccountStatusNotProvided     AccountStatus        = "NotProvided"
	AccountStatusEnabled         AccountStatus        = "Enabled"
	AccountStatusClosed          AccountStatus        = "Closed"
	AccountStatusSuspended       AccountStatus        = "Suspended"
	VirtualAccountStatusEnabled  VirtualAccountStatus = "Enabled"
	VirtualAccountStatusDisabled VirtualAccountStatus = "Disabled"
)
View Source
const (
	MCCYAccountStatusActive                      MCCYAccountStatus       = "Active"
	MCCYAccountStatusSuspended                   MCCYAccountStatus       = "Suspended"
	MCCYAccountStatusClosed                      MCCYAccountStatus       = "Closed"
	MCCYAccountStatusNotProvided                 MCCYAccountStatus       = "NotProvided"
	MCCYAccountStatusReasonAccountHolderBankrupt MCCYAccountStatusReason = "AccountHolderBankrupt"
	MCCYAccountStatusReasonDissatisfiedCustomer  MCCYAccountStatusReason = "DissatisfiedCustomer"
	MCCYAccountStatusReasonFinancialCrime        MCCYAccountStatusReason = "FinancialCrime"
	MCCYAccountStatusReasonFraudFirstParty       MCCYAccountStatusReason = "FraudFirstParty"
	MCCYAccountStatusReasonFraudThirdParty       MCCYAccountStatusReason = "FraudThirdParty"
	MCCYAccountStatusReasonOther                 MCCYAccountStatusReason = "Other"
)
View Source
const ProprietarySortCode = "SortcodeAccountNumber"
View Source
const SchemeNameOther = "Other"

Variables

This section is empty.

Functions

func MarketrateNotAvailableError added in v0.14.0

func MarketrateNotAvailableError(err error) bool

func NewClient

func NewClient(token string, signer Signer, options ...ClientOption) *client

func NewRequest

func NewRequest(r *http.Request) *request

func RequestIdContext

func RequestIdContext(ctx context.Context, id string) context.Context

RequestIdContext adds a request ID to the given context.

func RequestIdFromContext

func RequestIdFromContext(ctx context.Context) string

RequestIdFromContext returns the request ID from the given context.

Types

type AccountBalance added in v0.3.0

type AccountBalance struct {
	Name     string  `json:"name"`
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
	Status   string  `json:"status"`
}

type AccountResponse added in v0.3.0

type AccountResponse struct {
	Account struct {
		ID           uuid.UUID        `json:"id"`
		Name         string           `json:"name"`
		Owner        string           `json:"label"`
		Type         string           `json:"type"`
		Currency     []string         `json:"currency"`
		Balances     []AccountBalance `json:"balances"`
		Status       AccountStatus    `json:"status"`
		StatusReason string           `json:"statusReason"`
		IBAN         string           `json:"iban"`
	} `json:"account"`
}

type AccountStatus added in v0.3.0

type AccountStatus string

type AccountUsageType added in v0.5.0

type AccountUsageType string
const (
	AccountUsageTypeYourFunds            AccountUsageType = "YourFunds"
	AccountUsageTypeSegregatedDesignated AccountUsageType = "SegregatedDesignated"
	AccountUsageTypeSegregatedPooled     AccountUsageType = "SegregatedPooled"
)

type AccountsClient added in v0.3.0

type AccountsClient interface {
	// accounts
	FetchAccount(ctx context.Context, accountID uuid.UUID) (AccountResponse, error)
	FetchAccounts(ctx context.Context, pageNum int, pageSize int) (AccountsResponse, error)
	CreateAccount(ctx context.Context, payload CreateAccountPayload) (AccountResponse, error)
	UpdateAccount(ctx context.Context, accountID uuid.UUID, payload UpdateAccountPayload) error

	// virtual accounts
	FetchVirtualAccountsFor(ctx context.Context, accountID uuid.UUID, pageNum int, pageSize int) (VirtualAccountsResponse, error)
	CreateVirtualAccounts(ctx context.Context, accountID uuid.UUID, payload CreateVirtualAccountsPayload) error
	UpdateVirtualAccount(ctx context.Context, accountID uuid.UUID, virtualAccountID uuid.UUID, payload UpdateVirtualAccountPayload) error
	DisableVirtualAccount(ctx context.Context, accountID uuid.UUID, virtualAccountID uuid.UUID) error
}

type AccountsResponse added in v0.3.0

type AccountsResponse struct {
	Accounts []struct {
		ID           uuid.UUID        `json:"id"`
		Name         string           `json:"name"`
		Owner        string           `json:"label"`
		Type         string           `json:"type"`
		Currency     []string         `json:"currency"`
		Balances     []AccountBalance `json:"balances"`
		Status       AccountStatus    `json:"status"`
		StatusReason string           `json:"statusReason"`
		IBAN         string           `json:"iban"`
	} `json:"accounts"`
}

type Address added in v0.9.0

type Address struct {
	BuildingNumber string `json:"buildingNumber,omitempty"`
	BuildingName   string `json:"buildingName,omitempty"`
	StreetName     string `json:"streetName,omitempty"`
	TownName       string `json:"townName"`
	PostCode       string `json:"postCode"`
	Country        string `json:"country"`
}

type ClientOption

type ClientOption func(*client)

ClientOption is a function that configures a Client.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL sets the base URL for the ClearBank API client.

func WithHTTPClient

func WithHTTPClient(c HttpClient) ClientOption

WithHTTPClient sets the HTTP client for the ClearBank API client.

func WithLogger

func WithLogger(l *logrus.Logger) ClientOption

WithLogger sets the *logrus.Logger for the ClearBank API client.

func WithRequestIDGenerator added in v0.9.0

func WithRequestIDGenerator(f RequestIdGen) ClientOption

WithRequestIDGenerator generate requestId on demand.

type CreateAccountPayload added in v0.3.0

type CreateAccountPayload struct {
	Name  string `json:"accountName"`
	Owner struct {
		Name string `json:"name"`
	} `json:"owner"`
	SortCode  string           `json:"sortCode"`
	UsageType AccountUsageType `json:"usageType,omitempty"`
}

type CreateCHAPSPaymentPayload added in v0.9.0

type CreateCHAPSPaymentPayload struct {
	// Unique identification, as assigned by you, to unambiguously identify the payment instruction.
	InstructionIdentification string `json:"instructionIdentification"`

	// Unique identification, as assigned by the initiating party, to unambiguously identify the transaction.
	// This identification is passed on, unchanged, throughout the entire end-to-end chain.
	EndToEndIdentification string `json:"endToEndIdentification"`

	// Amount of money to be moved between the debtor and creditor,
	// before deduction of charges, expressed in the currency as ordered by the initiating party.
	InstructedAmount struct {
		Currency string  `json:"currency"`
		Amount   float64 `json:"amount"`
	} `json:"instructedAmount"`

	// The ClearBank account that will be credited or debited
	// based on the successful completion of the payment instruction.
	// You need to include EITHER the iban field OR the schemeName and identification fields in this object.
	SourceAccount struct {
		IBAN           string `json:"iban,omitempty"`
		SchemeName     string `json:"schemeName,omitempty"`
		Proprietary    string `json:"proprietary,omitempty"`
		Identification string `json:"identification,omitempty"`
	} `json:"sourceAccount"`

	// Unambiguous identification of the account of the debtor
	// to which a debit entry will be made as a result of the transaction.
	// You need to include EITHER the iban field OR the schemeName and identification fields in this object.
	DebtorAccount struct {
		IBAN           string `json:"iban,omitempty"`
		SchemeName     string `json:"schemeName,omitempty"`
		Proprietary    string `json:"proprietary,omitempty"`
		Identification string `json:"identification,omitempty"`
	} `json:"debtorAccount"`

	// Unambiguous identification of the account of the creditor
	// to which a credit entry will be posted as a result of the payment transaction.
	CreditorAccount struct {
		IBAN           string `json:"iban,omitempty"`
		SchemeName     string `json:"schemeName,omitempty"`
		Proprietary    string `json:"proprietary,omitempty"`
		Identification string `json:"identification,omitempty"`
	} `json:"creditorAccount"`

	// Party that is owed an amount of money by the (ultimate) debtor.
	Creditor struct {
		Name    string   `json:"name"`
		Address *Address `json:"postalAddress,omitempty"`
	} `json:"creditor"`

	// Party that owes an amount of money to the (ultimate) creditor.
	Debtor struct {
		Name    string  `json:"name"`
		Address Address `json:"postalAddress"`
	} `json:"debtor"`

	// Underlying reason for the payment transaction, as published in an external purpose code list.
	Purpose string `json:"purpose,omitempty"`

	// Category purpose, in a proprietary form.
	CategoryPurpose string `json:"categoryPurpose,omitempty"`

	// Information supplied to enable the matching of an entry with the items that the transfer is intended to settle,
	// such as commercial invoices in an accounts' receivable system.
	RemittanceInformation struct {
		CreditorReferenceInformation string `json:"creditorReferenceInformation"`
	} `json:"remittanceInformation"`
}

type CreateFPSPaymentOriginatedOverseasPayload added in v0.3.0

type CreateFPSPaymentOriginatedOverseasPayload struct {
	// Unique identification, as assigned by you, to unambiguously identify the payment instruction.
	InstructionIdentification string `json:"instructionIdentification"`

	// Unique identification, as assigned by the initiating party, to unambiguously identify the transaction. This identification is passed on, unchanged, throughout the entire end-to-end chain.
	EndToEndIdentification string `json:"endToEndIdentification"`

	// Underlying reason for the payment transaction, as published in an external purpose code list.
	Purpose string `json:"purpose,omitempty"`

	// Category purpose, in a proprietary form.
	CategoryPurpose string `json:"categoryPurpose,omitempty"`

	// Amount of money to be moved between the debtor and creditor,
	// before deduction of charges, expressed in the currency as ordered by the initiating party.
	InstructedAmount struct {
		Currency string  `json:"currency"`
		Amount   float64 `json:"amount"`
	} `json:"instructedAmount"`

	// The ClearBank account that will be credited or debited
	// based on the successful completion of the payment instruction.
	// You need to include EITHER the iban field OR the schemeName and identification fields in this object.
	SourceAccount struct {
		IBAN           string `json:"iban,omitempty"`
		SchemeName     string `json:"schemeName,omitempty"`
		Proprietary    string `json:"proprietary,omitempty"`
		Identification string `json:"identification,omitempty"`
	} `json:"sourceAccount"`

	// Unambiguous identification of the account of the debtor
	// to which a debit entry will be made as a result of the transaction.
	// You need to include EITHER the iban field OR the schemeName and identification fields in this object.
	DebtorAccount struct {
		IBAN           string `json:"iban,omitempty"`
		SchemeName     string `json:"schemeName,omitempty"`
		Proprietary    string `json:"proprietary,omitempty"`
		Identification string `json:"identification,omitempty"`
	} `json:"debtorAccount"`

	// Unambiguous identification of the account of the creditor
	// to which a credit entry will be posted as a result of the payment transaction.
	CreditorAccount struct {
		IBAN           string `json:"iban,omitempty"`
		SchemeName     string `json:"schemeName,omitempty"`
		Proprietary    string `json:"proprietary,omitempty"`
		Identification string `json:"identification,omitempty"`
	} `json:"creditorAccount"`

	// Party that owes an amount of money to the (ultimate) creditor.
	Debtor struct {
		Name    string  `json:"name"`
		Address Address `json:"postalAddress"`
	} `json:"debtor"`

	// Party that is owed an amount of money by the (ultimate) debtor.
	Creditor struct {
		Name    string  `json:"name"`
		BIC     string  `json:"bic"`
		Address Address `json:"postalAddress"`
	} `json:"creditor"`

	RemittanceInformation struct {
		CreditorReferenceInformation string `json:"creditorReferenceInformation"`
	} `json:"remittanceInformation"`

	// Agent between the debtor's agent and the creditor's agent.
	// You must include the Direct Participant's information in this object.
	IntermediaryAgent struct {
		Name    string  `json:"name"`
		BIC     string  `json:"bic"`
		Address Address `json:"postalAddress"`
	} `json:"intermediaryAgent1"`
}

type CreateInternalTransactionPayload added in v0.3.0

type CreateInternalTransactionPayload struct {
	DebitAccountIBAN   string  `json:"debitAccountIban"`
	CreditAccountIBAN  string  `json:"creditAccountIban"`
	InstructedAmount   float64 `json:"instructedAmount"`
	InstructedCurrency string  `json:"instructedCurrency"`
	EndToEndID         string  `json:"endToEndId"`
	Reference          string  `json:"reference"`
}

type CreateMCCYAccountPayload added in v0.3.0

type CreateMCCYAccountPayload struct {
	Label       string          `json:"label"`
	Owner       string          `json:"owner"`
	Kind        MCCYAccountKind `json:"kind"`
	Currencies  []string        `json:"currencies"`
	RoutingCode struct {
		Code string          `json:"code"`
		Kind RoutingCodeKind `json:"kind"`
	} `json:"routingCode"`
}

type CreateMCCYInboundPaymentPayload added in v0.5.0

type CreateMCCYInboundPaymentPayload struct {
	// Currency of the instructed payment. This is the three-letter ISO currency code.
	InstructedCurrency string `json:"instructedCurrency"`

	// Instructed payment amount.
	InstructedAmount float64 `json:"instructedAmount"`

	// Reference provided by the ultimate debtor for the payment.
	Reference string `json:"reference"`

	// Unique identifier supplied by you in your API request to simulate the sending bank’s reference.
	EndToEndId string `json:"endToEndId"`

	// Information about the ultimate creditor of the transaction.
	UltimateCreditor struct {
		// Ultimate creditor’s International Bank Account Number.
		IBAN string `json:"iban"`
		// Ultimate Creditor Name.
		Name string `json:"name"`
		// Ultimate creditor’s address.
		Address string `json:"address"`
	} `json:"ultimateCreditor"`

	// Information about the ultimate debtor of the transaction.
	UltimateDebtor struct {
		// Ultimate debtor’s unique identifier value. This can only be an IBAN or BIC.
		Identifier string `json:"identifier"`
		// Ultimate Creditor Name.
		Name string `json:"name"`
		// Ultimate creditor’s address.
		Address string `json:"address"`
	} `json:"ultimateDebtor"`
}

type CreateMCCYTransactionsPayload added in v0.3.0

type CreateMCCYTransactionsPayload struct {
	// Unique identifier for the batch in which the payment is being submitted.
	BatchID string `json:"batchId,omitempty"`

	// Three-letter ISO currency code for the outbound payment.
	Currency string `json:"currencyCode"`

	// Array of transactions.
	Transactions []MCCYTransactionPayload `json:"transactions"`
}

type CreateMCCYVirtualAccountPayload added in v0.3.0

type CreateMCCYVirtualAccountPayload struct {
	AccountID      string `json:"accountId"`
	VirtualAccount struct {
		Owner string `json:"owner"`
	} `json:"virtualAccount"`
}

type CreateTransactionsPayload added in v0.3.0

type CreateTransactionsPayload struct {
	// Details of the payments to be made.
	PaymentInstructions []PaymentInstruction `json:"paymentInstructions"`
}

type CreateVirtualAccountPayload added in v0.3.0

type CreateVirtualAccountPayload struct {
	OwnerName         string `json:"ownerName"`
	AccountIdentifier struct {
		IBAN                  string `json:"iban,omitempty"`
		BBAN                  string `json:"bban,omitempty"`
		ProprietaryIdentifier string `json:"proprietaryIdentifier,omitempty"`
		ExternalIdentifier    string `json:"externalIdentifier,omitempty"`
	} `json:"accountIdentifier"`
}

type CreateVirtualAccountsPayload added in v0.3.0

type CreateVirtualAccountsPayload struct {
	VirtualAccounts []CreateVirtualAccountPayload `json:"virtualAccounts"`
}

type CreditTransfer added in v0.3.0

type CreditTransfer struct {
	// Identification of the payment instruction.
	PaymentIdentification struct {
		// Unique identification, as assigned by an instructing party
		// for an instructed party, to unambiguously identify the instruction.
		InstructionIdentification string `json:"instructionIdentification"`

		// Unique identification, as assigned by the initiating party to unambiguously identify the transaction.
		// This identification is passed on unchanged throughout the entire end-to-end chain.
		EndToEndIdentification string `json:"endToEndIdentification"`
	} `json:"paymentIdentification"`

	// Indicates the amount and the currency used in a given transaction or account balance.
	Amount struct {
		Currency         string  `json:"currency"`
		InstructedAmount float64 `json:"instructedAmount"`
	} `json:"amount"`

	// The name and, optionally, the legal entity identifier of the account.
	Creditor struct {
		// The name of the account holder.
		Name string `json:"name"`

		// The legal entity identifier of the account holder (eg: charity number).
		// This should be supplied if known.
		LegalEntityIndentifier string `json:"legalEntityIdentifier,omitempty"`
	} `json:"creditor"`

	// Information about the counterpart in a given transaction.
	CreditorAccount struct {
		// The identifiable information of an account.
		Identification struct {
			// The International Bank Account Number (IBAN).
			IBAN string `json:"iban,omitempty"`
			// Unique identification of an account,
			// as assigned by the account servicer,
			// using an identification scheme.
			Other *CreditTransferOtherIdentification `json:"other,omitempty"`
		} `json:"identification"`
	} `json:"creditorAccount"`

	// Information supplied to enable the matching/reconciliation of an entry
	// with the items that the payment is intended to settle,
	// such as commercial invoices in an accounts’ receivable system.
	RemittanceInformation struct {
		// Information supplied by the remitter (in a structured form),
		// to reconcile an entry with item(s) that the payment intends to settle
		//  (e.g., a purchase reference number).
		Structured struct {
			// Reference information provided by the ultimate debtor
			// to allow the identification of underlying documents by the creditor.
			CreditorReferenceInformation struct {
				// A reference, as assigned by the ultimate debtor
				// to unambiguously refer to the payment transaction.
				// Conditionally required if supplied by the ultimate debtor.
				Reference string `json:"reference"`
			} `json:"creditorReferenceInformation"`
		} `json:"structured,omitempty"`
	} `json:"remittanceInformation,omitempty"`
}

type CreditTransferOtherIdentification added in v0.9.0

type CreditTransferOtherIdentification struct {
	// Identification assigned by an institution.
	Identification string `json:"identification"`
	// Name of the identification scheme.
	SchemeName struct {
		// Name of the identification scheme in coded form.
		Code string `json:"code"`
		// Name of the identification scheme in free-form text.
		Proprietary string `json:"proprietary"`
	} `json:"schemeName"`
}

type EnableMCCYAccountCurrencyPayload added in v0.3.0

type EnableMCCYAccountCurrencyPayload struct {
	Currency string `json:"currency"`
}

type ErrResponse

type ErrResponse struct {
	Type     string              `json:"type"`
	Title    string              `json:"title"`
	Status   int                 `json:"status" validate:"required"`
	Details  string              `json:"detail"`
	Instance string              `json:"instance"`
	Errors   map[string][]string `json:"errors"`
}

func (ErrResponse) Error

func (e ErrResponse) Error() string

type FXAccount added in v0.9.0

type FXAccount struct {
	Owner string `json:"owner"`
	IBAN  string `json:"iban"`
}

type FXAttestation added in v0.3.0

type FXAttestation string
const (
	FXAttestationSameOwner      FXAttestation = "Y"
	FXAttestationDifferentOwner FXAttestation = "N"
)

type FXPayload added in v0.3.0

type FXPayload struct {
	QuoteID             *uuid.UUID `json:"quoteId,omitempty"`
	CustomerInformation struct {
		SellAccount FXAccount     `json:"sellAccount"`
		BuyAccount  FXAccount     `json:"buyAccount"`
		Attestation FXAttestation `json:"attestation"`
	} `json:"customerInformation"`
	MarginAccount    *FXAccount          `json:"marginAccount,omitempty"`
	TradeInformation *FXTradeInformation `json:"tradeInformation,omitempty"`
}

type FXQuotePayload added in v0.9.0

type FXQuotePayload struct {
	SellCurrency     string         `json:"SellCurrency"`
	BuyCurrency      string         `json:"BuyCurrency"`
	InstructedAmount float64        `json:"InstructedAmount"`
	FixedSide        QuoteFixedSide `json:"FixedSide"`
	ValueDate        string         `json:"ValueDate"`
	Margin           *float64       `json:"Margin,omitempty"`
}

type FXQuoteResponse added in v0.9.0

type FXQuoteResponse struct {
	QuoteID      uuid.UUID `json:"QuoteId"`
	ValueDate    string    `json:"ValueDate"`
	CurrencyPair string    `json:"CurrencyPair"`
	ExchangeRate float64   `json:"ExchangeRate"`
	SellCurrency string    `json:"SellCurrency"`
	SellAmount   float64   `json:"SellAmount"`
	BuyCurrency  string    `json:"BuyCurrency"`
	BuyAmount    float64   `json:"BuyAmount"`
	CreatedAt    Time      `json:"CreatedAt"`
	ExpiresAt    Time      `json:"ExpiresAt"`
	QuoteRequest struct {
		ValueDate        string  `json:"ValueDate"`
		InstructedAmount float64 `json:"InstructedAmount"`
		FixedSide        string  `json:"FixedSide"`
		SellCurrency     string  `json:"SellCurrency"`
		BuyCurrency      string  `json:"BuyCurrency"`
	} `json:"QuoteRequest"`
}

func (FXQuoteResponse) GetRate added in v0.9.0

func (q FXQuoteResponse) GetRate() float64

type FXTradeInformation added in v0.9.0

type FXTradeInformation struct {
	ValueDate string `json:"valueDate,omitempty"`
	Details   struct {
		InstructedAmount float64   `json:"instructedAmount"`
		FixedSide        FixedSide `json:"fixedSide"`
		SellCurrency     string    `json:"sellCurrency"`
		BuyCurrency      string    `json:"buyCurrency"`
	} `json:"details"`
	Margin                  *FXTradeInformationMargin `json:"margin,omitempty"`
	EndToEndID              string                    `json:"endToEndId"`
	UnstructuredInformation string                    `json:"unstructuredInformation,omitempty"`
}

type FXTradeInformationMargin added in v0.13.0

type FXTradeInformationMargin struct {
	Amount  float64   `json:"amount"`
	Account FXAccount `json:"account"`
}

type FetchTransactionsParams added in v0.3.0

type FetchTransactionsParams struct {
	PageNumber    int
	PageSize      int
	StartDateTime time.Time
	EndDateTime   time.Time
}

func (FetchTransactionsParams) ApplyFor added in v0.3.0

func (p FetchTransactionsParams) ApplyFor(req *request)

ApplyFor applies values to the given request as query parameters.

type FixedSide

type FixedSide string
const (
	FixedSideBuy  FixedSide = "BUY"
	FixedSideSell FixedSide = "SELL"
)

type FxClient added in v0.3.0

type FxClient interface {
	InitiateFxOrder(context.Context, FXPayload) error
	RequestFxQuote(ctx context.Context, payload FXQuotePayload) (data FXQuoteResponse, err error)
	ExecuteFxQuote(ctx context.Context, payload FXPayload) error
}

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type MCCYAccountBalance added in v0.3.0

type MCCYAccountBalance struct {
	Currency  string  `json:"currency"`
	Available float64 `json:"available"`
	Actual    float64 `json:"actual"`
}

type MCCYAccountBalancesResponse added in v0.3.0

type MCCYAccountBalancesResponse struct {
	Balances []MCCYAccountBalance `json:"balances"`
}

func (*MCCYAccountBalancesResponse) UnmarshalJSON added in v0.3.0

func (m *MCCYAccountBalancesResponse) UnmarshalJSON(data []byte) error

type MCCYAccountCloseReason added in v0.3.0

type MCCYAccountCloseReason string
const (
	MCCYAccountCloseReasonOther                  MCCYAccountCloseReason = "Other"
	MCCYAccountCloseReasonAccountHolderDeceased  MCCYAccountCloseReason = "AccountHolderDeceased"
	MCCYAccountCloseReasonAccountSwitched        MCCYAccountCloseReason = "AccountSwitched"
	MCCYAccountCloseReasonCompanyNoLongerTrading MCCYAccountCloseReason = "CompanyNoLongerTrading"
	MCCYAccountCloseReasonDuplicateAccount       MCCYAccountCloseReason = "DuplicateAccount"
)

type MCCYAccountIdentifier added in v0.3.0

type MCCYAccountIdentifier struct {
	Identifier string `json:"identifier"`
	Kind       string `json:"kind"`
}

type MCCYAccountKind added in v0.3.0

type MCCYAccountKind string
const (
	MCCYAccountKindYourFunds            MCCYAccountKind = "YourFunds"
	MCCYAccountKindGeneralSegregated    MCCYAccountKind = "GeneralSegregated"
	MCCYAccountKindDesignatedSegregated MCCYAccountKind = "DesignatedSegregated"
	MCCYAccountKindGeneralClient        MCCYAccountKind = "GeneralClient"
	MCCYAccountKindDesignatedClient     MCCYAccountKind = "DesignatedClient"
)

type MCCYAccountResponse added in v0.3.0

type MCCYAccountResponse struct {
	ID                uuid.UUID               `json:"id"`
	Name              string                  `json:"name"`
	Label             string                  `json:"label"`
	Owner             string                  `json:"owner"`
	Kind              MCCYAccountKind         `json:"kind"`
	Currencies        []string                `json:"currencies"`
	Identifiers       []MCCYAccountIdentifier `json:"identifiers"`
	Status            MCCYAccountStatus       `json:"status"`
	StatusReason      string                  `json:"statusReason"`
	StatusInformation string                  `json:"statusInformation"`
}

func (MCCYAccountResponse) GetIdentifier added in v0.10.0

func (r MCCYAccountResponse) GetIdentifier() string

GetIdentifier returns first identifier.

type MCCYAccountStatus added in v0.3.0

type MCCYAccountStatus string

type MCCYAccountStatusReason added in v0.3.0

type MCCYAccountStatusReason string

type MCCYAccountsClient added in v0.3.0

type MCCYAccountsClient interface {
	// accounts
	FetchMCCYAccount(ctx context.Context, accountID uuid.UUID) (MCCYAccountResponse, error)
	FetchMCCYAccounts(ctx context.Context, pageNum int, pageSize int) (MCCYAccountsResponse, error)
	CreateMCCYAccount(ctx context.Context, payload CreateMCCYAccountPayload) (MCCYAccountResponse, error)
	UpdateMCCYAccount(ctx context.Context, accountID uuid.UUID, payload UpdateMCCYAccountPayload) (MCCYAccountResponse, error)
	UpdateMCCYAccountStatus(ctx context.Context, accountID uuid.UUID, payload UpdateMCCYAccountStatusPayload) (MCCYAccountResponse, error)
	EnableMCCYAccountCurrency(ctx context.Context, accountID uuid.UUID, payload EnableMCCYAccountCurrencyPayload) error
	CloseMCCYAccount(ctx context.Context, accountID uuid.UUID, reason MCCYAccountCloseReason) error
	FetchMCCYAccountBalances(ctx context.Context, accountID uuid.UUID) (MCCYAccountBalancesResponse, error)

	// virtual accounts
	FetchMCCYVirtualAccount(ctx context.Context, virtualAccountID uuid.UUID) (MCCYVirtualAccountResponse, error)
	FetchMCCYVirtualAccounts(ctx context.Context, pageNum int, pageSize int) (MCCYVirtualAccountsResponse, error)
	CreateMCCYVirtualAccount(ctx context.Context, payload CreateMCCYVirtualAccountPayload) (MCCYVirtualAccountResponse, error)
	UpdateMCCYVirtualAccount(ctx context.Context, virtualAccountID uuid.UUID, payload UpdateMCCYVirtualAccountPayload) (MCCYVirtualAccountResponse, error)
	UpdateMCCYVirtualAccountStatus(ctx context.Context, virtualAccountID uuid.UUID, payload UpdateMCCYVirtualAccountStatusPayload) (MCCYVirtualAccountResponse, error)
	CloseMCCYVirtualAccount(ctx context.Context, virtualAccountID uuid.UUID, reason MCCYAccountCloseReason) error
}

type MCCYAccountsResponse added in v0.3.0

type MCCYAccountsResponse struct {
	Accounts []MCCYAccountResponse `json:"accounts"`
}

type MCCYInboundPaymentResponse added in v0.5.0

type MCCYInboundPaymentResponse struct {
	TransactionID            uuid.UUID `json:"transactionId"`
	InstructedCurrency       string    `json:"instructedCurrency"`
	InstructedAmount         float64   `json:"instructedAmount"`
	Reference                string    `json:"reference"`
	EndToEndID               string    `json:"endToEndId"`
	UltimateCreditorIBAN     string    `json:"ultimateCreditorIBAN"`
	UltimateCreditorName     string    `json:"ultimateCreditorName"`
	UltimateDebtorIdentifier string    `json:"ultimateDebtorIdentifier"`
	UltimateDebtorName       string    `json:"ultimateDebtorName"`
	TimestampCreated         Time      `json:"timestampCreated"`
	BankRefSearchable        string    `json:"bankRefSearchable"`
}

type MCCYIntermediaryAgent added in v0.3.0

type MCCYIntermediaryAgent struct {
	// Information that identifies the intermediary agent as a financial institution.
	// Mandatory only when intermediary agent details are being provided.
	FinancialInstitutionIdentification struct {
		// Intermediary agent’s Business Identifier Code (BIC).
		// No need to specify if you are providing the intermediary agent’s American Bankers Association (ABA) routing number.
		BIC string `json:"bic,omitempty"`

		// Intermediary agent’s American Bankers Association (ABA) routing number.
		// No need to specify if you are providing the intermediary agent’s Business Identifier Code (BIC).
		ABA string `json:"aba,omitempty"`

		// Intermediary agent’s name.
		Name string `json:"name,omitempty"`

		// Information about the intermediary agent’s address.
		// Mandatory only when financial institution identification details are being provided.
		AddressDetails struct {
			AddressLine1 string `json:"addressLine1,omitempty"`
			AddressLine2 string `json:"addressLine2,omitempty"`
			AddressLine3 string `json:"addressLine3,omitempty"`
			PostCode     string `json:"postCode,omitempty"`
			Country      string `json:"country"`
		} `json:"addressDetails"`
	} `json:"FinancialInstitutionIdentification"`
}

MCCYIntermediaryAgent - information about the intermediary/correspondent bank.

type MCCYPurpose added in v0.8.0

type MCCYPurpose struct {
	// Purpose of the transaction in coded form, as specified in the Purpose11Code code set required by ISO 20022 Message Schemas.
	// No need to specify if you are providing this name in free-form text (i.e., proprietary).
	Code string `json:"code"`
	// Purpose of the transaction in free-form text.
	// No need to specify if you are providing this name in coded form (i.e., code).
	Proprietary string `json:"proprietary"`
}

MCCYPurpose - information about the purpose of the transaction.

type MCCYRemittanceInformation added in v0.8.0

type MCCYRemittanceInformation struct {
	// Additional remittance information in free-form text, to compliment the structured remittance information.
	AdditionalRemittanceInformation string `json:"additionalRemittanceInformation"`
}

MCCYRemittanceInformation - remittance information to accompany the payment.

type MCCYTransactionPayload added in v0.3.0

type MCCYTransactionPayload struct {
	// Unique identifier provided to ClearBank for each payment.
	EndToEndID string `json:"endToEndId"`

	// Reference provided by the debtor for the payment.
	Reference string `json:"reference"`

	// Instructed payment amount.
	Amount float64 `json:"amount"`

	// The name used to identify the legal owner of the account from which the funds will be debited.
	DebtorName string `json:"debtorName"`

	// Information about the debtor’s address.
	DebtorAddress struct {
		AddressLine1 string `json:"addressLine1"`
		AddressLine2 string `json:"addressLine2"`
		AddressLine3 string `json:"addressLine3,omitempty"`
		PostCode     string `json:"postCode"`
		Country      string `json:"country"`
	} `json:"debtorAddress"`

	// Debtor’s Business Identifier Code (BIC).
	DebtorBic string `json:"debtorBic,omitempty"`

	// The unique identifier for the account.
	DebtorAccountIdentifier MCCYAccountIdentifier `json:"accountIdentifier"`

	// Three-letter ISO currency code for the currency supported by the debtor account.
	DebtorAccountCurrency string `json:"debtorAccountCurrency"`

	// Information about the intermediary/correspondent bank.
	IntermediaryAgent *MCCYIntermediaryAgent `json:"intermediaryAgent,omitempty"`

	// Information about the purpose of the transaction.
	Purpose *MCCYPurpose `json:"purpose,omitempty"`

	// Remittance information to accompany the payment.
	RemittanceInformation *MCCYRemittanceInformation `json:"remittanceInformation,omitempty"`

	// Information about the creditor of the transaction.
	Creditor struct {
		// Creditor’s name.
		Name string `json:"name"`

		// Information about the creditor’s address.
		Address struct {
			AddressLine1 string `json:"addressLine1"`
			AddressLine2 string `json:"addressLine2"`
			AddressLine3 string `json:"addressLine3,omitempty"`
			PostCode     string `json:"postCode"`
			Country      string `json:"country"`
		} `json:"address"`

		// Creditor’s International Bank Account Number.
		// Mandatory only if account number is not specified.
		IBAN string `json:"iban,omitempty"`

		// Creditor’s Account Number.
		// Mandatory only if iban is not specified.
		AccountNumber string `json:"accountNumber,omitempty"`
	} `json:"creditor"`

	CreditorAgent struct {
		// Information that identifies the creditor agent as a financial institution.
		FinancialInstitutionIdentification struct {
			// Creditor agent’s Business Identifier Code (BIC).
			BIC string `json:"bic,omitempty"`

			// Creditor agent’s American Bankers Association (ABA) routing number.
			ABA string `json:"aba,omitempty"`

			// Creditor agent’s Clearing System Id Code.
			ClearingSystemIDCode string `json:"clearingSystemIdCode,omitempty"`

			// Creditor agent’s Member Id for the specified clearing system.
			// Mandatory only when Clearing System Id Code has been provided.
			MemberID string `json:"memberId,omitempty"`

			// Creditor agent’s name.
			Name string `json:"name"`

			// Information about the creditor agent’s address.
			AddressDetails struct {
				AddressLine1 string `json:"addressLine1,omitempty"`
				AddressLine2 string `json:"addressLine2,omitempty"`
				AddressLine3 string `json:"addressLine3,omitempty"`
				PostCode     string `json:"postCode,omitempty"`
				Country      string `json:"country"`
			} `json:"addressDetails"`
		} `json:"financialInstitutionIdentification"`
	} `json:"creditorAgent"`
}

type MCCYTransactionResponse added in v0.3.0

type MCCYTransactionResponse struct {
	TransactionID       uuid.UUID     `json:"transactionId"`
	AccountID           uuid.UUID     `json:"accountId"`
	VirtualAccountID    uuid.NullUUID `json:"virtualAccountId"`
	EndToEndID          string        `json:"endToEndId"`
	Reference           string        `json:"reference"`
	UltimateBeneficiary struct {
		AccountIdentifiers []MCCYAccountIdentifier `json:"accountIdentifiers"`
		PayeeName          string                  `json:"payeeName"`
	} `json:"ultimateBeneficiary"`
	UltimateRemitter struct {
		AccountIdentifiers []MCCYAccountIdentifier `json:"accountIdentifiers"`
		PayerName          string                  `json:"payerName"`
	} `json:"ultimateRemitter"`
	Amount           float64 `json:"amount"`
	Currency         string  `json:"currency"`
	CurrencyExchange struct {
		Rate     float64 `json:"rate"`
		Margin   float64 `json:"margin"`
		Currency string  `json:"currency"`
		Amount   float64 `json:"amount"`
	} `json:"currencyExchangeRate"`
	ActualPaymentMethod    string                `json:"actualPaymentMethod"`
	RequestedPaymentMethod string                `json:"requestedPaymentMethod"`
	Kind                   string                `json:"kind"`
	CreatedAt              Time                  `json:"createdAt"`
	SettledAt              string                `json:"settledAt"`
	ValueAt                string                `json:"valueAt"`
	CancelledAt            string                `json:"cancelledAt"`
	CancellationCode       string                `json:"cancellationCode"`
	Reason                 string                `json:"reason"`
	Status                 MCCYTransactionStatus `json:"status"`
	AdditionalProperties   []struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	} `json:"additionalProperties"`
	Identifiers []struct {
		Scope      string `json:"scope"`
		Name       string `json:"name"`
		Identifier string `json:"identifier"`
	} `json:"identifiers"`
}

type MCCYTransactionStatus added in v0.3.0

type MCCYTransactionStatus string
const (
	MCCYTransactionStatusClearing  MCCYTransactionStatus = "Clearing"
	MCCYTransactionStatusSettled   MCCYTransactionStatus = "Settled"
	MCCYTransactionStatusCancelled MCCYTransactionStatus = "Cancelled" // nolint: misspell
)

type MCCYTransactionsClient added in v0.3.0

type MCCYTransactionsClient interface {
	InitiateInternalTransaction(context.Context, CreateInternalTransactionPayload) error
	InitiateMCCYTransactions(context.Context, CreateMCCYTransactionsPayload) error
	InitiateMCCYInboundPayment(ctx context.Context, accountUniqueID string, payload CreateMCCYInboundPaymentPayload) (MCCYInboundPaymentResponse, error)
	FetchMCCYTransaction(ctx context.Context, trxID uuid.UUID) (MCCYTransactionResponse, error)
	FetchMCCYTransactionsForAccount(ctx context.Context, accountID uuid.UUID, currency string, params FetchTransactionsParams) (MCCYTransactionsResponse, error)
	FetchMCCYTransactionsForVirtualAccount(ctx context.Context, virtualAccountID uuid.UUID, currency string, params FetchTransactionsParams) (MCCYTransactionsResponse, error)
}

type MCCYTransactionsResponse added in v0.3.0

type MCCYTransactionsResponse struct {
	Transactions []MCCYTransactionResponse `json:"transactions"`
}

type MCCYVirtualAccountResponse added in v0.3.0

type MCCYVirtualAccountResponse struct {
	ID                uuid.UUID               `json:"id"`
	AccountID         uuid.UUID               `json:"accountId"`
	Owner             string                  `json:"owner"`
	Identifiers       []MCCYAccountIdentifier `json:"identifiers"`
	Status            MCCYAccountStatus       `json:"status"`
	StatusReason      string                  `json:"statusReason"`
	StatusInformation string                  `json:"statusInformation"`
}

func (MCCYVirtualAccountResponse) GetIdentifier added in v0.10.0

func (r MCCYVirtualAccountResponse) GetIdentifier() string

GetIdentifier returns first identifier.

type MCCYVirtualAccountsResponse added in v0.3.0

type MCCYVirtualAccountsResponse struct {
	VirtualAccounts []MCCYVirtualAccountResponse `json:"virtualAccounts"`
}

type MarketrateParams

type MarketrateParams struct {
	SellCurrency     string
	BuyCurrency      string
	InstructedAmount float64
	FixedSide        FixedSide
	ValueDate        string
}

type MarketrateResponse

type MarketrateResponse struct {
	Symbol     string  `json:"symbol"`
	MarketRate float64 `json:"marketRate"`
	ValueDate  Time    `json:"valueDate"`
}

type NegotiateResponse

type NegotiateResponse struct {
	URL string `json:"url"`
}

type PaymentInitiatedResponse added in v0.9.0

type PaymentInitiatedResponse struct {
	PaymentID uuid.UUID `json:"paymentId"`
}

type PaymentInstruction added in v0.3.0

type PaymentInstruction struct {
	// Details about the account holder.
	Debtor struct {
		// The legal entity identifier of the account holder (eg: charity number).
		// This should be supplied if known.
		LegalEntityIdentifier string `json:"legalEntityIdentifier,omitempty"`

		// The name of the account holder.
		Name string `json:"name,omitempty"`

		// The address of the account holder.
		Address string `json:"address"`
	} `json:"debtor"`

	// Information about the counterpart in a given transaction.
	DebtorAccount struct {
		// The identifiable information of an account.
		Identification struct {
			// The International Bank Account Number (IBAN).
			IBAN string `json:"iban"`
		} `json:"identification"`
	} `json:"debtorAccount"`

	// A series of payments that should be made from the debtor account.
	CreditTransfers []CreditTransfer `json:"creditTransfers"`

	// The unique identifier for the payment instruction.
	PaymentInstructionIdentification string `json:"paymentInstructionIdentification"`
}

type QuoteFixedSide added in v0.9.0

type QuoteFixedSide string
const (
	QuoteFixedSideBuy  QuoteFixedSide = "Buy"
	QuoteFixedSideSell QuoteFixedSide = "Sell"
)

type RateClient

type RateClient interface {
	FetchMarketrate(context.Context, MarketrateParams) (MarketrateResponse, error)
	Negotiate(context.Context) (NegotiateResponse, error)
}

type RequestIdGen added in v0.9.0

type RequestIdGen func() string

type RoutingCodeKind added in v0.3.0

type RoutingCodeKind string
const RoutingCodeKindGB RoutingCodeKind = "GBSortCode"

type Signer added in v0.8.0

type Signer interface {
	signature.Signer
}

type StatementClient added in v0.3.0

type StatementClient interface {
	RequestStatement(context.Context, StatementPayload) error
	RequestStatementFor(context.Context, string, StatementPayload) error
}

type StatementPayload added in v0.3.0

type StatementPayload struct {
	Year     int    `json:"year"`
	Month    int    `json:"month"`
	Format   string `json:"format"`
	Currency string `json:"currency"`
}

type TestClient

type TestClient interface {
	Test(context.Context, string) error
}

type TestPayload

type TestPayload struct {
	Data string `json:"data"`
}

type Time

type Time struct {
	time.Time
}

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type TransactionResponse added in v0.3.0

type TransactionResponse struct {
	Transaction TransactionResponseData `json:"transaction"`
}

type TransactionResponseData added in v0.7.0

type TransactionResponseData struct {
	Amount struct {
		InstructedAmount float64 `json:"instructedAmount"`
		Currency         string  `json:"currency"`
	} `json:"amount"`
	CounterpartAccount struct {
		Identification struct {
			IBAN          string `json:"iban"`
			AccountName   string `json:"accountName"`
			SortCode      string `json:"sortCode"`
			AccountNumber string `json:"accountNumber"`
			Reference     string `json:"reference"`
		} `json:"identification"`
	} `json:"counterpartAccount"`
	DebitCreditCode            string    `json:"debitCreditCode"`
	EndToEndIdentifier         string    `json:"endToEndIdentifier"`
	TransactionID              uuid.UUID `json:"transactionId"`
	TransactionReference       string    `json:"transactionReference"`
	TransactionTime            time.Time `json:"transactionTime"`
	Status                     string    `json:"status"`
	UltimateBeneficiaryAccount *struct {
		ID   uuid.UUID `json:"id"`
		IBAN string    `json:"iban"`
	} `json:"ultimateBeneficiaryAccount"`
	UltimateRemitterAccount *struct {
		ID   uuid.UUID `json:"id"`
		IBAN string    `json:"iban"`
	} `json:"ultimateRemitterAccount"`
}

func (TransactionResponseData) GetAmount added in v0.11.0

func (r TransactionResponseData) GetAmount() float64

type TransactionsClient added in v0.3.0

type TransactionsClient interface {
	InitiateFPSTransactions(context.Context, CreateTransactionsPayload) (TransactionsCreatedResponse, error)
	InitiateCHAPSPayment(context.Context, CreateCHAPSPaymentPayload) (PaymentInitiatedResponse, error)
	InitiateFPSPaymentOriginatedOverseas(context.Context, CreateFPSPaymentOriginatedOverseasPayload) (TransactionsCreatedResponse, error)
	FetchTransactions(ctx context.Context, params FetchTransactionsParams) (TransactionsResponse, error)
	FetchTransactionForAccount(ctx context.Context, accountID uuid.UUID, trxID uuid.UUID) (TransactionResponse, error)
	FetchTransactionsForAccount(ctx context.Context, accountID uuid.UUID, params FetchTransactionsParams) (TransactionsResponse, error)
	FetchTransactionForVirtualAccount(ctx context.Context, accountID, virtualAccountID uuid.UUID, trxID uuid.UUID) (TransactionResponse, error)
	FetchTransactionsForVirtualAccount(ctx context.Context, accountID, virtualAccountID uuid.UUID, params FetchTransactionsParams) (TransactionsResponse, error)
}

type TransactionsCreatedResponse added in v0.3.0

type TransactionsCreatedResponse struct {
	Transactions []struct {
		EndToEndIdentification string `json:"endToEndIdentification"`
		Response               string `json:"response"`
	}
}

type TransactionsResponse added in v0.3.0

type TransactionsResponse struct {
	Transactions []TransactionResponseData `json:"transactions"`
}

type UnexpectedResponse

type UnexpectedResponse struct {
	Status int
	Body   string
}

func (UnexpectedResponse) Error

func (r UnexpectedResponse) Error() string

type UpdateAccountPayload added in v0.3.0

type UpdateAccountPayload struct {
	Status           string `json:"status,omitempty"`
	StatusReason     string `json:"statusReason,omitempty"`
	OwnerName        string `json:"ownerName,omitempty"`
	LegalOwnerType   string `json:"legalOwnerType,omitempty"`
	RelationshipType string `json:"relationshipType,omitempty"`
	MinimumBalance   int    `json:"minimumBalance,omitempty"`
}

type UpdateMCCYAccountPayload added in v0.3.0

type UpdateMCCYAccountPayload struct {
	Label string `json:"label"`
	Owner string `json:"owner"`
}

type UpdateMCCYAccountStatusPayload added in v0.3.0

type UpdateMCCYAccountStatusPayload struct {
	Status       string `json:"status"`
	StatusReason string `json:"statusReason,omitempty"`
	Information  string `json:"information,omitempty"`
}

type UpdateMCCYVirtualAccountPayload added in v0.3.0

type UpdateMCCYVirtualAccountPayload struct {
	Owner string `json:"owner"`
}

type UpdateMCCYVirtualAccountStatusPayload added in v0.3.0

type UpdateMCCYVirtualAccountStatusPayload struct {
	Status       string `json:"status"`
	StatusReason string `json:"statusReason,omitempty"`
	Information  string `json:"information,omitempty"`
}

type UpdateVirtualAccountPayload added in v0.3.0

type UpdateVirtualAccountPayload struct {
	OwnerName        string `json:"ownerName,omitempty"`
	LegalOwnerType   string `json:"legalOwnerType,omitempty"`
	RelationshipType string `json:"relationshipType,omitempty"`
}

type VirtualAccountStatus added in v0.3.0

type VirtualAccountStatus string

type VirtualAccountsResponse added in v0.3.0

type VirtualAccountsResponse struct {
	Accounts []struct {
		ID         uuid.UUID            `json:"id"`
		Name       string               `json:"name"`
		Owner      string               `json:"label"`
		Type       string               `json:"type"`
		Status     VirtualAccountStatus `json:"status"`
		Currencies []string             `json:"currency"`
		IBAN       string               `json:"iban"`
	} `json:"accounts"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL