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.6 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 PollTransfer struct {
TaskID models.TaskID
ConnectorID models.ConnectorID
PaymentInitiationID models.PaymentInitiationID
TransferID string
ScheduleID string
}
func (w Workflow) runPollTransfer(
ctx workflow.Context,
pollTransfer PollTransfer,
) error {
paymentID, err := w.pollTransfer(ctx, pollTransfer)
if err != nil {
return w.updateTasksError(
ctx,
pollTransfer.TaskID,
&pollTransfer.ConnectorID,
err,
)
}
if paymentID != "" {
return w.updateTaskSuccess(
ctx,
pollTransfer.TaskID,
&pollTransfer.ConnectorID,
paymentID,
)
}
return nil
}
func (w Workflow) pollTransfer(
ctx workflow.Context,
pollTransfer PollTransfer,
) (string, error) {
pollTransferStatusResponse, err := activities.PluginPollTransferStatus(
infiniteRetryContext(ctx),
pollTransfer.ConnectorID,
models.PollTransferStatusRequest{
TransferID: pollTransfer.TransferID,
},
)
if err != nil {
return "", err
}
paymentID := ""
var piErr error
switch {
case pollTransferStatusResponse.Payment == nil && pollTransferStatusResponse.Error == nil:
// payment not yet available and no error, waiting for the next polling
return "", nil
case pollTransferStatusResponse.Payment != nil:
payment, err := models.FromPSPPaymentToPayment(*pollTransferStatusResponse.Payment, pollTransfer.ConnectorID)
if err != nil {
return "", temporal.NewNonRetryableApplicationError(
"failed to translate psp payment",
ErrValidation,
err,
)
}
if err := w.storePIPaymentWithStatus(
ctx,
payment,
pollTransfer.PaymentInitiationID,
getPIStatusFromPayment(payment.Status),
); err != nil {
return "", err
}
paymentID = payment.ID.String()
case pollTransferStatusResponse.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", *pollTransferStatusResponse.Error)
}
// everything is done, delete the related schedule
if err := activities.TemporalScheduleDelete(
infiniteRetryContext(ctx),
pollTransfer.ScheduleID,
); err != nil {
return "", err
}
if err := activities.StorageSchedulesDelete(
infiniteRetryContext(ctx),
pollTransfer.ScheduleID,
); err != nil {
return "", err
}
return paymentID, piErr
}
const RunPollTransfer = "PollTransfer"