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.
66 lines
2.0 KiB
Go
66 lines
2.0 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzo-fi/payments/pkg/domain/metrics"
|
|
"github.com/stripe/stripe-go/v80"
|
|
)
|
|
|
|
func (c *client) GetRootAccount() (result *stripe.Account, err error) {
|
|
result, err = c.accountClient.Get()
|
|
return result, wrapSDKErr(err)
|
|
}
|
|
|
|
func (c *client) GetAccounts(
|
|
ctx context.Context,
|
|
timeline Timeline,
|
|
pageSize int64,
|
|
) (results []*stripe.Account, _ Timeline, hasMore bool, err error) {
|
|
results = make([]*stripe.Account, 0, int(pageSize))
|
|
|
|
if !timeline.IsCaughtUp() {
|
|
var backlog []interface{}
|
|
backlog, timeline, hasMore, err = fetchBacklog(timeline, pageSize, func(params stripe.ListParams) (stripe.ListContainer, error) {
|
|
params.Context = metrics.OperationContext(ctx, "list_accounts_scan")
|
|
itr := c.accountClient.List(&stripe.AccountListParams{ListParams: params})
|
|
return itr.AccountList(), wrapSDKErr(itr.Err())
|
|
})
|
|
if err != nil {
|
|
return results, timeline, false, err
|
|
}
|
|
for _, a := range backlog {
|
|
results = append(results, a.(*stripe.Account))
|
|
}
|
|
|
|
return results, timeline, hasMore, err
|
|
}
|
|
|
|
filters := stripe.ListParams{
|
|
Context: metrics.OperationContext(ctx, "list_accounts"),
|
|
Limit: limit(pageSize, len(results)),
|
|
EndingBefore: &timeline.LatestID,
|
|
Single: true, // turn off autopagination
|
|
}
|
|
|
|
itr := c.accountClient.List(&stripe.AccountListParams{ListParams: filters})
|
|
data := reverseAccounts(itr.AccountList().Data)
|
|
results = append(results, data...)
|
|
if len(results) == 0 {
|
|
return results, timeline, itr.AccountList().HasMore, wrapSDKErr(itr.Err())
|
|
}
|
|
|
|
timeline.LatestID = results[len(results)-1].ID
|
|
return results, timeline, itr.AccountList().HasMore, wrapSDKErr(itr.Err())
|
|
}
|
|
|
|
// Stripe now returns data in reverse chronological order no matter which params we provide so we need to reverse the slice
|
|
func reverseAccounts(in []*stripe.Account) []*stripe.Account {
|
|
out := make([]*stripe.Account, len(in))
|
|
copy(out, in)
|
|
for i, j := 0, len(out)-1; i < j; i, j = i+1, j-1 {
|
|
out[i], out[j] = out[j], out[i]
|
|
}
|
|
return out
|
|
}
|