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.
72 lines
2.1 KiB
Go
72 lines
2.1 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzo-fi/payments/pkg/domain/metrics"
|
|
"github.com/stripe/stripe-go/v80"
|
|
)
|
|
|
|
func (c *client) GetExternalAccounts(
|
|
ctx context.Context,
|
|
accountID string,
|
|
timeline Timeline,
|
|
pageSize int64,
|
|
) (results []*stripe.BankAccount, _ Timeline, hasMore bool, err error) {
|
|
results = make([]*stripe.BankAccount, 0, int(pageSize))
|
|
|
|
// this call cannot be used against the root account
|
|
if accountID == c.rootAccountID {
|
|
return results, timeline, false, nil
|
|
}
|
|
|
|
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_bank_accounts_scan")
|
|
itr := c.bankAccountClient.List(&stripe.BankAccountListParams{
|
|
Account: &accountID,
|
|
ListParams: params,
|
|
})
|
|
return itr.BankAccountList(), wrapSDKErr(itr.Err())
|
|
})
|
|
if err != nil {
|
|
return results, timeline, false, err
|
|
}
|
|
for _, a := range backlog {
|
|
results = append(results, a.(*stripe.BankAccount))
|
|
}
|
|
|
|
return results, timeline, hasMore, err
|
|
}
|
|
|
|
itr := c.bankAccountClient.List(&stripe.BankAccountListParams{
|
|
Account: &accountID,
|
|
ListParams: stripe.ListParams{
|
|
Context: metrics.OperationContext(ctx, "list_bank_accounts"),
|
|
Limit: &pageSize,
|
|
EndingBefore: &timeline.LatestID,
|
|
},
|
|
})
|
|
if err := itr.Err(); err != nil {
|
|
return nil, timeline, false, wrapSDKErr(err)
|
|
}
|
|
data := reverseBankAccounts(itr.BankAccountList().Data)
|
|
results = append(results, data...)
|
|
if len(results) == 0 {
|
|
return results, timeline, itr.BankAccountList().HasMore, nil
|
|
}
|
|
timeline.LatestID = results[len(results)-1].ID
|
|
return results, timeline, itr.BankAccountList().HasMore, nil
|
|
}
|
|
|
|
// Stripe now returns data in reverse chronological order no matter which params we provide so we need to reverse the slice
|
|
func reverseBankAccounts(in []*stripe.BankAccount) []*stripe.BankAccount {
|
|
out := make([]*stripe.BankAccount, 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
|
|
}
|