Files
zeekay 7d727874d5 chore: rebrand Formance Payments -> Hanzo Payments (hanzo-fi)
- 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.
2026-07-05 13:08:55 -07:00

76 lines
2.1 KiB
Go

package client
import (
"context"
"fmt"
"os"
"path"
"github.com/hanzo-fi/payments/pkg/domain/models"
)
type Client interface {
FetchAccounts(ctx context.Context, startToken int, pageSize int) ([]models.PSPAccount, int, error)
FetchBalance(ctx context.Context, accountID string) (*models.PSPBalance, error)
CreatePayment(ctx context.Context, paymentType models.PaymentType, paymentInit models.PSPPaymentInitiation) (*models.PSPPayment, error)
ReversePayment(ctx context.Context, paymentType models.PaymentType, reversal models.PSPPaymentInitiationReversal) (models.PSPPayment, error)
CreateUser(ctx context.Context, user models.PSPPaymentServiceUser) (string, error)
DeleteUser(ctx context.Context, userID string) error
CompleteLink(ctx context.Context, userID string, connectionID string) error
DeleteUserConnection(ctx context.Context, userID string, connectionID string) error
}
type client struct {
directory string
}
func New(dir string) Client {
return &client{
directory: dir,
}
}
func (c *client) writeFile(filename string, b []byte) error {
filePath := path.Join(c.directory, filename)
file, err := os.Create(filePath)
if err != nil {
return fmt.Errorf("failed to open %q for write: %w", filePath, err)
}
defer file.Close()
_, err = file.Write(b)
if err != nil {
return fmt.Errorf("failed to read file %q: %w", filePath, err)
}
return nil
}
func (c *client) readFile(filename string) (b []byte, err error) {
filePath := path.Join(c.directory, filename)
file, err := os.Open(filePath)
if err != nil {
if os.IsNotExist(err) {
return b, nil
}
return b, fmt.Errorf("failed to open %q for read: %w", filePath, err)
}
defer file.Close()
fileInfo, err := file.Stat()
if err != nil {
return b, fmt.Errorf("failed to stat file %q: %w", filePath, err)
}
buf := make([]byte, fileInfo.Size())
_, err = file.Read(buf)
if err != nil {
return b, fmt.Errorf("failed to read file %q: %w", filePath, err)
}
return buf, nil
}
func (c *client) deleteFile(filename string) error {
filePath := path.Join(c.directory, filename)
return os.Remove(filePath)
}