mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
- go.mod module path + all self-imports: github.com/formancehq/payments -> github.com/hanzo-fi/payments (1590 .go files / 3152 refs; 20 modules: root, pkg/client, pkg/domain, 18 ce/plugins). External dep kept: formancehq/go-libs. - plugins: each ce/plugins/* consumed a *published* pkg/domain; added local 'replace .../pkg/domain => ../../../pkg/domain' (consistent with root) so every standalone plugin module builds in-monorepo. compile-plugin.sh MOD var rebranded too. - branding: README, LICENSE (dual MIT+EE; upstream copyright retained + Hanzo added), goreleaser (release images -> registry.hanzo.ai/hanzo-fi, OCI labels, homepage), proto go_package, renovate, speakeasy gen.yaml, connector-template *.gotpl. - CI: removed Numary/Formance workflows + composite action; added canonical hanzo.yml + cicd.yml (hanzoai/ci, gated HANZO_CI_ENABLED) + secretless ci.yml (go build/vet). - kept as data/compat keys: wire capability enums ALLOW_FORMANCE_*, generated SDK type client.Formance, domain field FormanceRedirectURL, OTEL_SERVICE_NAME, upstream base image. - verified: go build ./... (default + -tags ee) + all 20 nested modules green.
63 lines
2.6 KiB
Go
63 lines
2.6 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/hanzo-fi/payments/pkg/domain/httpwrapper"
|
|
"github.com/hanzo-fi/payments/pkg/domain/metrics"
|
|
"golang.org/x/oauth2/clientcredentials"
|
|
)
|
|
|
|
//go:generate mockgen -source client.go -destination client_generated.go -package client . Client
|
|
type Client interface {
|
|
CreateIBANBankAccount(ctx context.Context, userID string, req *CreateIBANBankAccountRequest) (*BankAccount, error)
|
|
CreateUSBankAccount(ctx context.Context, userID string, req *CreateUSBankAccountRequest) (*BankAccount, error)
|
|
CreateCABankAccount(ctx context.Context, userID string, req *CreateCABankAccountRequest) (*BankAccount, error)
|
|
CreateGBBankAccount(ctx context.Context, userID string, req *CreateGBBankAccountRequest) (*BankAccount, error)
|
|
CreateOtherBankAccount(ctx context.Context, userID string, req *CreateOtherBankAccountRequest) (*BankAccount, error)
|
|
GetBankAccounts(ctx context.Context, userID string, page, pageSize int) ([]BankAccount, error)
|
|
GetPayin(ctx context.Context, payinID string) (*PayinResponse, error)
|
|
InitiatePayout(ctx context.Context, payoutRequest *PayoutRequest) (*PayoutResponse, error)
|
|
GetPayout(ctx context.Context, payoutID string) (*PayoutResponse, error)
|
|
GetRefund(ctx context.Context, refundID string) (*Refund, error)
|
|
GetTransactions(ctx context.Context, walletsID string, page, pageSize int, afterCreatedAt time.Time) ([]Payment, error)
|
|
InitiateWalletTransfer(ctx context.Context, transferRequest *TransferRequest) (*TransferResponse, error)
|
|
GetWalletTransfer(ctx context.Context, transferID string) (TransferResponse, error)
|
|
GetUsers(ctx context.Context, page int, pageSize int) ([]User, error)
|
|
GetWallets(ctx context.Context, userID string, page, pageSize int) ([]Wallet, error)
|
|
GetWallet(ctx context.Context, walletID string) (*Wallet, error)
|
|
ListAllHooks(ctx context.Context) ([]*Hook, error)
|
|
CreateHook(ctx context.Context, eventType EventType, URL string) error
|
|
UpdateHook(ctx context.Context, hookID string, URL string) error
|
|
}
|
|
|
|
// TODO(polo): Fetch Client wallets (FEES, ...) in the future
|
|
type client struct {
|
|
httpClient httpwrapper.Client
|
|
|
|
clientID string
|
|
endpoint string
|
|
}
|
|
|
|
func New(connectorName, clientID, apiKey, endpoint string) Client {
|
|
endpoint = strings.TrimSuffix(endpoint, "/")
|
|
|
|
config := &httpwrapper.Config{
|
|
Transport: metrics.NewTransport(connectorName, metrics.TransportOpts{}),
|
|
OAuthConfig: &clientcredentials.Config{
|
|
ClientID: clientID,
|
|
ClientSecret: apiKey,
|
|
TokenURL: endpoint + "/v2.01/oauth/token",
|
|
},
|
|
}
|
|
|
|
return &client{
|
|
httpClient: httpwrapper.NewClient(config),
|
|
|
|
clientID: clientID,
|
|
endpoint: endpoint,
|
|
}
|
|
}
|