refactored payment orchestration
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package model
|
||||
package account_role
|
||||
|
||||
import (
|
||||
"strings"
|
||||
@@ -86,8 +86,9 @@ func (n ChainNetwork) IsEVM() bool {
|
||||
func (n ChainNetwork) IsTestnet() bool {
|
||||
switch n {
|
||||
case ChainNetworkTronNile:
|
||||
case ChainNetworkArbitrumSepolia:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ type ConfirmationRequest struct {
|
||||
TimeoutSeconds int32 `bson:"timeoutSeconds,omitempty" json:"timeout_seconds,omitempty"`
|
||||
SourceService string `bson:"sourceService,omitempty" json:"source_service,omitempty"`
|
||||
Rail string `bson:"rail,omitempty" json:"rail,omitempty"`
|
||||
OperationRef string `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
|
||||
IntentRef string `bson:"intentRef,omitempty" json:"intent_ref,omitempty"`
|
||||
}
|
||||
|
||||
type ConfirmationResult struct {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"github.com/tech/sendico/pkg/model/account_role"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
@@ -63,7 +64,7 @@ type LedgerAccount struct {
|
||||
// Role defines the functional purpose of the account within an organization
|
||||
// (e.g., pending, operating, settlement, hold, etc.).
|
||||
// Must be set for organization accounts and omitted for system accounts.
|
||||
Role AccountRole `bson:"role,omitempty" json:"role,omitempty"`
|
||||
Role account_role.AccountRole `bson:"role,omitempty" json:"role,omitempty"`
|
||||
|
||||
// AccountCode is a logical classification code of the account
|
||||
// (e.g., "asset:cash:usd") used for reporting and grouping.
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package model
|
||||
|
||||
type Money struct {
|
||||
Currency string `bson:"currency" json:"currency"`
|
||||
Amount string `bson:"amount" json:"amount"`
|
||||
}
|
||||
@@ -144,3 +144,24 @@ func (m *PaymentMethod) UnmarshalJSON(data []byte) error {
|
||||
m.Data = raw
|
||||
return nil
|
||||
}
|
||||
|
||||
type PaymentStatus string
|
||||
|
||||
const (
|
||||
PaymentStatusUnspecified PaymentStatus = "unspecified"
|
||||
|
||||
// Intent exists, no funds touched yet.
|
||||
PaymentStatusCreated PaymentStatus = "created"
|
||||
|
||||
// Internal Sendico operations: holds, ledger, FX, fee calc.
|
||||
PaymentStatusAuthorizing PaymentStatus = "authorizing"
|
||||
|
||||
// Funds are outside Sendico (rail/gateway/blockchain/provider).
|
||||
// Observe lives ONLY in this state.
|
||||
PaymentStatusExecuting PaymentStatus = "executing"
|
||||
|
||||
// Final states.
|
||||
PaymentStatusSucceeded PaymentStatus = "success"
|
||||
PaymentStatusFailed PaymentStatus = "failed"
|
||||
PaymentStatusCancelled PaymentStatus = "cancelled"
|
||||
)
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
package model
|
||||
|
||||
import paymenttypes "github.com/tech/sendico/pkg/payments/types"
|
||||
import (
|
||||
"github.com/tech/sendico/pkg/payments/rail"
|
||||
paymenttypes "github.com/tech/sendico/pkg/payments/types"
|
||||
)
|
||||
|
||||
type PaymentGatewayIntent struct {
|
||||
PaymentRef string `bson:"paymentRef,omitempty" json:"payment_ref,omitempty"`
|
||||
PaymentIntentID string `bson:"paymentIntentId,omitempty" json:"payment_intent_id,omitempty"`
|
||||
IdempotencyKey string `bson:"idempotencyKey,omitempty" json:"idempotency_key,omitempty"`
|
||||
OutgoingLeg string `bson:"outgoingLeg,omitempty" json:"outgoing_leg,omitempty"`
|
||||
QuoteRef string `bson:"quoteRef,omitempty" json:"quote_ref,omitempty"`
|
||||
IntentRef string `bson:"intentRef,omitempty" json:"intent_ref,omitempty"`
|
||||
OperationRef string `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
|
||||
RequestedMoney *paymenttypes.Money `bson:"requestedMoney,omitempty" json:"requested_money,omitempty"`
|
||||
TargetChatID string `bson:"targetChatId,omitempty" json:"target_chat_id,omitempty"`
|
||||
}
|
||||
|
||||
type PaymentGatewayExecution struct {
|
||||
PaymentIntentID string `bson:"paymentIntentId,omitempty" json:"payment_intent_id,omitempty"`
|
||||
IdempotencyKey string `bson:"idempotencyKey,omitempty" json:"idempotency_key,omitempty"`
|
||||
QuoteRef string `bson:"quoteRef,omitempty" json:"quote_ref,omitempty"`
|
||||
ExecutedMoney *paymenttypes.Money `bson:"executedMoney,omitempty" json:"executed_money,omitempty"`
|
||||
Status ConfirmationStatus `bson:"status,omitempty" json:"status,omitempty"`
|
||||
RequestID string `bson:"requestId,omitempty" json:"request_id,omitempty"`
|
||||
RawReply *TelegramMessage `bson:"rawReply,omitempty" json:"raw_reply,omitempty"`
|
||||
PaymentIntentID string `bson:"paymentIntentId,omitempty" json:"payment_intent_id,omitempty"`
|
||||
PaymentRef string `bson:"paymentRef,omitempty" json:"payment_ref,omitempty"`
|
||||
IdempotencyKey string `bson:"idempotencyKey,omitempty" json:"idempotency_key,omitempty"`
|
||||
ExecutedMoney *paymenttypes.Money `bson:"executedMoney,omitempty" json:"executed_money,omitempty"`
|
||||
Status rail.OperationResult `bson:"status,omitempty" json:"status,omitempty"`
|
||||
OperationRef string `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
|
||||
TransferRef string `bson:"transferRef,omitempty" json:"transfer_ref,omitempty"`
|
||||
Error string `bson:"error,omitempty" json:"error,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user