refactored payment orchestration

This commit is contained in:
Stephan D
2026-02-03 00:40:46 +01:00
parent 05d998e0f7
commit 5e87e2f2f9
184 changed files with 3920 additions and 2219 deletions

View File

@@ -3,19 +3,32 @@ package rail
import (
"context"
"github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/model/account_role"
paymenttypes "github.com/tech/sendico/pkg/payments/types"
)
// Money represents a currency amount using decimal-safe strings.
type Money = paymenttypes.Money
type TransferStatus string
const (
TransferStatusUnspecified = "UNSPECIFIED"
TransferStatusSuccess = "SUCCESS"
TransferStatusFailed = "FAILED"
TransferStatusRejected = "REJECTED"
TransferStatusPending = "PENDING"
TransferStatusUnspecified TransferStatus = "unspecified"
TransferStatusCreated TransferStatus = "created"
TransferStatusSuccess TransferStatus = "success"
TransferStatusFailed TransferStatus = "failed"
TransferStatusWaiting TransferStatus = "waiting"
TransferStatusProcessing TransferStatus = "processing"
TransferStatusCancelled TransferStatus = "cancelled"
)
// OperationResult represents the outcome status of an operation in a gateway
type OperationResult string
const (
OperationResultSuccess OperationResult = "success"
OperationResultFailed OperationResult = "failed"
OperationResultCancelled OperationResult = "cancelled"
)
// RailCapabilities are declared per gateway instance.
@@ -39,6 +52,9 @@ type FeeBreakdown struct {
// TransferRequest defines the inputs for sending value through a rail gateway.
type TransferRequest struct {
OrganizationRef string
IntentRef string
OperationRef string
PaymentRef string
FromAccountID string
ToAccountID string
Currency string
@@ -48,10 +64,9 @@ type TransferRequest struct {
Fees []FeeBreakdown
IdempotencyKey string
Metadata map[string]string
ClientReference string
DestinationMemo string
FromRole model.AccountRole
ToRole model.AccountRole
FromRole account_role.AccountRole
ToRole account_role.AccountRole
}
// BlockRequest defines the inputs for reserving value through a rail gateway.
@@ -62,35 +77,35 @@ type BlockRequest struct {
Amount string
IdempotencyKey string
Metadata map[string]string
ClientReference string
PaymentRef string
}
// ReleaseRequest defines the inputs for releasing a prior block.
type ReleaseRequest struct {
ReferenceID string
IdempotencyKey string
Metadata map[string]string
ClientReference string
ReferenceID string
IdempotencyKey string
Metadata map[string]string
PaymentRef string
}
// RailResult reports the outcome of a rail gateway operation.
type RailResult struct {
ReferenceID string
Status string
Status TransferStatus
FinalAmount *Money
Error *RailError
Error *Error
}
// ObserveResult reports the outcome of a confirmation observation.
type ObserveResult struct {
ReferenceID string
Status string
Status TransferStatus
FinalAmount *Money
Error *RailError
Error *Error
}
// RailError captures structured failure details from a gateway.
type RailError struct {
// Error captures structured failure details from a gateway.
type Error struct {
Code string
Message string
CanRetry bool