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.
105 lines
3.7 KiB
Go
105 lines
3.7 KiB
Go
package increase
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"strings"
|
|
|
|
"github.com/hanzo-fi/payments/ce/plugins/increase/client"
|
|
"github.com/hanzo-fi/payments/pkg/domain/models"
|
|
)
|
|
|
|
func (p *Plugin) validatePayoutRequests(pi models.PSPPaymentInitiation) error {
|
|
payoutMethod := models.ExtractNamespacedMetadata(pi.Metadata, client.IncreasePayoutMethodMetadataKey)
|
|
if payoutMethod == "" {
|
|
return models.NewConnectorValidationError(client.IncreasePayoutMethodMetadataKey, models.ErrMissingConnectorMetadata)
|
|
}
|
|
|
|
validMethods := map[string]bool{
|
|
increaseACHPayoutMethod: true,
|
|
increaseWirePaymentMethod: true,
|
|
increaseCheckPaymentMethod: true,
|
|
increaseRTPPaymentMethod: true,
|
|
}
|
|
|
|
if !validMethods[payoutMethod] {
|
|
return models.NewConnectorValidationError(client.IncreasePayoutMethodMetadataKey, models.ErrInvalidRequest)
|
|
}
|
|
|
|
if pi.Description == "" {
|
|
return models.NewConnectorValidationError("description", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
if pi.Amount == nil {
|
|
return models.NewConnectorValidationError("amount", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
if pi.SourceAccount == nil {
|
|
return models.NewConnectorValidationError("sourceAccount", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
if pi.DestinationAccount == nil {
|
|
return models.NewConnectorValidationError("destinationAccount", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
if payoutMethod == increaseCheckPaymentMethod && models.ExtractNamespacedMetadata(pi.Metadata, client.IncreaseFulfillmentMethodMetadataKey) == "" {
|
|
return models.NewConnectorValidationError(client.IncreaseFulfillmentMethodMetadataKey, models.ErrMissingConnectorMetadata)
|
|
}
|
|
|
|
sourceAccountNumberID := models.ExtractNamespacedMetadata(pi.Metadata, client.IncreaseSourceAccountNumberIdMetadataKey)
|
|
if sourceAccountNumberID == "" && (payoutMethod == increaseCheckPaymentMethod || payoutMethod == increaseRTPPaymentMethod) {
|
|
return models.NewConnectorValidationError(client.IncreaseSourceAccountNumberIdMetadataKey, models.ErrMissingConnectorMetadata)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (p *Plugin) validateTransferRequests(pi models.PSPPaymentInitiation) error {
|
|
if pi.Amount == nil {
|
|
return models.NewConnectorValidationError("amount", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
if pi.SourceAccount == nil {
|
|
return models.NewConnectorValidationError("sourceAccount", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
if pi.DestinationAccount == nil {
|
|
return models.NewConnectorValidationError("destinationAccount", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
if pi.Description == "" {
|
|
return models.NewConnectorValidationError("description", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (p *Plugin) validateBankAccountRequests(ba models.BankAccount) error {
|
|
routingNumber := models.ExtractNamespacedMetadata(ba.Metadata, client.IncreaseRoutingNumberMetadataKey)
|
|
if routingNumber == "" {
|
|
return models.NewConnectorValidationError(client.IncreaseRoutingNumberMetadataKey, models.ErrMissingConnectorMetadata)
|
|
}
|
|
|
|
accountHolder := models.ExtractNamespacedMetadata(ba.Metadata, client.IncreaseAccountHolderMetadataKey)
|
|
if accountHolder == "" {
|
|
return models.NewConnectorValidationError(client.IncreaseAccountHolderMetadataKey, models.ErrMissingConnectorMetadata)
|
|
}
|
|
|
|
description := models.ExtractNamespacedMetadata(ba.Metadata, client.IncreaseDescriptionMetadataKey)
|
|
if description == "" {
|
|
return models.NewConnectorValidationError(client.IncreaseDescriptionMetadataKey, models.ErrMissingConnectorMetadata)
|
|
}
|
|
|
|
if ba.AccountNumber == nil {
|
|
return models.NewConnectorValidationError("AccountNumber", models.ErrMissingConnectorField)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (p *Plugin) generateIdempotencyKey(values ...string) string {
|
|
joined := strings.Join(values, "-")
|
|
hash := sha256.Sum256([]byte(joined))
|
|
return hex.EncodeToString(hash[:])
|
|
}
|