Chimera Settle service
This commit is contained in:
65
api/gateway/chsettle/storage/model/execution.go
Normal file
65
api/gateway/chsettle/storage/model/execution.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
paymenttypes "github.com/tech/sendico/pkg/payments/types"
|
||||
)
|
||||
|
||||
type PaymentStatus string
|
||||
|
||||
const (
|
||||
PaymentStatusCreated PaymentStatus = "created" // created
|
||||
PaymentStatusProcessing PaymentStatus = "processing" // processing
|
||||
PaymentStatusWaiting PaymentStatus = "waiting" // waiting external action
|
||||
PaymentStatusSuccess PaymentStatus = "success" // final success
|
||||
PaymentStatusFailed PaymentStatus = "failed" // final failure
|
||||
PaymentStatusCancelled PaymentStatus = "cancelled" // cancelled final
|
||||
)
|
||||
|
||||
type PaymentRecord struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
OperationRef string `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
|
||||
IdempotencyKey string `bson:"idempotencyKey,omitempty" json:"idempotency_key,omitempty"`
|
||||
ConfirmationRef string `bson:"confirmationRef,omitempty" json:"confirmation_ref,omitempty"`
|
||||
ConfirmationMessageID string `bson:"confirmationMessageId,omitempty" json:"confirmation_message_id,omitempty"`
|
||||
ConfirmationReplyMessageID string `bson:"confirmationReplyMessageId,omitempty" json:"confirmation_reply_message_id,omitempty"`
|
||||
PaymentIntentID string `bson:"paymentIntentId,omitempty" json:"payment_intent_id,omitempty"`
|
||||
QuoteRef string `bson:"quoteRef,omitempty" json:"quote_ref,omitempty"`
|
||||
IntentRef string `bson:"intentRef,omitempty" json:"intent_ref,omitempty"`
|
||||
PaymentRef string `bson:"paymentRef,omitempty" json:"payment_ref,omitempty"`
|
||||
Scenario string `bson:"scenario,omitempty" json:"scenario,omitempty"`
|
||||
OutgoingLeg string `bson:"outgoingLeg,omitempty" json:"outgoing_leg,omitempty"`
|
||||
TargetChatID string `bson:"targetChatId,omitempty" json:"target_chat_id,omitempty"`
|
||||
RequestedMoney *paymenttypes.Money `bson:"requestedMoney,omitempty" json:"requested_money,omitempty"`
|
||||
ExecutedMoney *paymenttypes.Money `bson:"executedMoney,omitempty" json:"executed_money,omitempty"`
|
||||
Status PaymentStatus `bson:"status,omitempty" json:"status,omitempty"`
|
||||
FailureReason string `bson:"failureReason,omitempty" json:"Failure_reason,omitempty"`
|
||||
ExecutedAt time.Time `bson:"executedAt,omitempty" json:"executed_at,omitempty"`
|
||||
ExpiresAt time.Time `bson:"expiresAt,omitempty" json:"expires_at,omitempty"`
|
||||
ExpiredAt time.Time `bson:"expiredAt,omitempty" json:"expired_at,omitempty"`
|
||||
}
|
||||
|
||||
type TelegramConfirmation struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
RequestID string `bson:"requestId,omitempty" json:"request_id,omitempty"`
|
||||
PaymentIntentID string `bson:"paymentIntentId,omitempty" json:"payment_intent_id,omitempty"`
|
||||
QuoteRef string `bson:"quoteRef,omitempty" json:"quote_ref,omitempty"`
|
||||
RawReply *model.TelegramMessage `bson:"rawReply,omitempty" json:"raw_reply,omitempty"`
|
||||
ReceivedAt time.Time `bson:"receivedAt,omitempty" json:"received_at,omitempty"`
|
||||
}
|
||||
|
||||
type PendingConfirmation struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
RequestID string `bson:"requestId,omitempty" json:"request_id,omitempty"`
|
||||
MessageID string `bson:"messageId,omitempty" json:"message_id,omitempty"`
|
||||
TargetChatID string `bson:"targetChatId,omitempty" json:"target_chat_id,omitempty"`
|
||||
AcceptedUserIDs []string `bson:"acceptedUserIds,omitempty" json:"accepted_user_ids,omitempty"`
|
||||
RequestedMoney *paymenttypes.Money `bson:"requestedMoney,omitempty" json:"requested_money,omitempty"`
|
||||
SourceService string `bson:"sourceService,omitempty" json:"source_service,omitempty"`
|
||||
Rail string `bson:"rail,omitempty" json:"rail,omitempty"`
|
||||
Clarified bool `bson:"clarified,omitempty" json:"clarified,omitempty"`
|
||||
ExpiresAt time.Time `bson:"expiresAt,omitempty" json:"expires_at,omitempty"`
|
||||
}
|
||||
29
api/gateway/chsettle/storage/model/storable.go
Normal file
29
api/gateway/chsettle/storage/model/storable.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
paymentsCollection = "payments"
|
||||
telegramConfirmationsCollection = "telegram_confirmations"
|
||||
pendingConfirmationsCollection = "pending_confirmations"
|
||||
treasuryRequestsCollection = "treasury_requests"
|
||||
treasuryTelegramUsersCollection = "treasury_telegram_users"
|
||||
)
|
||||
|
||||
func (*PaymentRecord) Collection() string {
|
||||
return paymentsCollection
|
||||
}
|
||||
|
||||
func (*TelegramConfirmation) Collection() string {
|
||||
return telegramConfirmationsCollection
|
||||
}
|
||||
|
||||
func (*PendingConfirmation) Collection() string {
|
||||
return pendingConfirmationsCollection
|
||||
}
|
||||
|
||||
func (*TreasuryRequest) Collection() string {
|
||||
return treasuryRequestsCollection
|
||||
}
|
||||
|
||||
func (*TreasuryTelegramUser) Collection() string {
|
||||
return treasuryTelegramUsersCollection
|
||||
}
|
||||
59
api/gateway/chsettle/storage/model/treasury.go
Normal file
59
api/gateway/chsettle/storage/model/treasury.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
)
|
||||
|
||||
type TreasuryOperationType string
|
||||
|
||||
const (
|
||||
TreasuryOperationFund TreasuryOperationType = "fund"
|
||||
TreasuryOperationWithdraw TreasuryOperationType = "withdraw"
|
||||
)
|
||||
|
||||
type TreasuryRequestStatus string
|
||||
|
||||
const (
|
||||
TreasuryRequestStatusCreated TreasuryRequestStatus = "created"
|
||||
TreasuryRequestStatusConfirmed TreasuryRequestStatus = "confirmed"
|
||||
TreasuryRequestStatusScheduled TreasuryRequestStatus = "scheduled"
|
||||
TreasuryRequestStatusExecuted TreasuryRequestStatus = "executed"
|
||||
TreasuryRequestStatusCancelled TreasuryRequestStatus = "cancelled"
|
||||
TreasuryRequestStatusFailed TreasuryRequestStatus = "failed"
|
||||
)
|
||||
|
||||
type TreasuryRequest struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
RequestID string `bson:"requestId,omitempty" json:"request_id,omitempty"`
|
||||
OperationType TreasuryOperationType `bson:"operationType,omitempty" json:"operation_type,omitempty"`
|
||||
TelegramUserID string `bson:"telegramUserId,omitempty" json:"telegram_user_id,omitempty"`
|
||||
LedgerAccountID string `bson:"ledgerAccountId,omitempty" json:"ledger_account_id,omitempty"`
|
||||
LedgerAccountCode string `bson:"ledgerAccountCode,omitempty" json:"ledger_account_code,omitempty"`
|
||||
OrganizationRef string `bson:"organizationRef,omitempty" json:"organization_ref,omitempty"`
|
||||
ChatID string `bson:"chatId,omitempty" json:"chat_id,omitempty"`
|
||||
Amount string `bson:"amount,omitempty" json:"amount,omitempty"`
|
||||
Currency string `bson:"currency,omitempty" json:"currency,omitempty"`
|
||||
Status TreasuryRequestStatus `bson:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
ConfirmedAt time.Time `bson:"confirmedAt,omitempty" json:"confirmed_at,omitempty"`
|
||||
ScheduledAt time.Time `bson:"scheduledAt,omitempty" json:"scheduled_at,omitempty"`
|
||||
ExecutedAt time.Time `bson:"executedAt,omitempty" json:"executed_at,omitempty"`
|
||||
CancelledAt time.Time `bson:"cancelledAt,omitempty" json:"cancelled_at,omitempty"`
|
||||
|
||||
IdempotencyKey string `bson:"idempotencyKey,omitempty" json:"idempotency_key,omitempty"`
|
||||
LedgerReference string `bson:"ledgerReference,omitempty" json:"ledger_reference,omitempty"`
|
||||
ErrorMessage string `bson:"errorMessage,omitempty" json:"error_message,omitempty"`
|
||||
|
||||
Active bool `bson:"active,omitempty" json:"active,omitempty"`
|
||||
}
|
||||
|
||||
type TreasuryTelegramUser struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
TelegramUserID string `bson:"telegramUserId,omitempty" json:"telegram_user_id,omitempty"`
|
||||
LedgerAccountID string `bson:"ledgerAccountId,omitempty" json:"ledger_account_id,omitempty"`
|
||||
AllowedChatIDs []string `bson:"allowedChatIds,omitempty" json:"allowed_chat_ids,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user