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

114 lines
2.5 KiB
Go

package workflow
import (
"fmt"
"github.com/hanzo-fi/payments/internal/connectors/engine/activities"
"github.com/hanzo-fi/payments/pkg/domain/models"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)
type PollPayout struct {
TaskID models.TaskID
ConnectorID models.ConnectorID
PaymentInitiationID models.PaymentInitiationID
PayoutID string
ScheduleID string
}
func (w Workflow) runPollPayout(
ctx workflow.Context,
pollPayout PollPayout,
) error {
paymentID, err := w.pollPayout(ctx, pollPayout)
if err != nil {
return w.updateTasksError(
ctx,
pollPayout.TaskID,
&pollPayout.ConnectorID,
err,
)
}
if paymentID != "" {
return w.updateTaskSuccess(
ctx,
pollPayout.TaskID,
&pollPayout.ConnectorID,
paymentID,
)
}
return nil
}
func (w Workflow) pollPayout(
ctx workflow.Context,
pollPayout PollPayout,
) (string, error) {
pollPayoutStatusResponse, err := activities.PluginPollPayoutStatus(
infiniteRetryContext(ctx),
pollPayout.ConnectorID,
models.PollPayoutStatusRequest{
PayoutID: pollPayout.PayoutID,
},
)
if err != nil {
return "", err
}
paymentID := ""
var piErr error
switch {
case pollPayoutStatusResponse.Payment == nil && pollPayoutStatusResponse.Error == nil:
// payment not yet available and no error, waiting for the next polling
return "", nil
case pollPayoutStatusResponse.Payment != nil:
payment, err := models.FromPSPPaymentToPayment(*pollPayoutStatusResponse.Payment, pollPayout.ConnectorID)
if err != nil {
return "", temporal.NewNonRetryableApplicationError(
"failed to translate psp payment",
ErrValidation,
err,
)
}
if err := w.storePIPaymentWithStatus(
ctx,
payment,
pollPayout.PaymentInitiationID,
getPIStatusFromPayment(payment.Status),
); err != nil {
return "", err
}
paymentID = payment.ID.String()
case pollPayoutStatusResponse.Error != nil:
// Means that the payment initiation failed, and we need to register
// the error in the task as well as stopping the schedule polling.
piErr = fmt.Errorf("%s", *pollPayoutStatusResponse.Error)
}
// everything is done, delete the related schedule
if err := activities.TemporalScheduleDelete(
infiniteRetryContext(ctx),
pollPayout.ScheduleID,
); err != nil {
return "", err
}
if err := activities.StorageSchedulesDelete(
infiniteRetryContext(ctx),
pollPayout.ScheduleID,
); err != nil {
return "", err
}
return paymentID, piErr
}
const RunPollPayout = "PollPayout"