monetix gateway

This commit is contained in:
Stephan D
2025-12-04 21:16:15 +01:00
parent f439f53524
commit 396a0c0c88
47 changed files with 3835 additions and 3 deletions

View File

@@ -11,6 +11,10 @@ type CardPaymentData struct {
Pan string `bson:"pan" json:"pan"`
FirstName string `bson:"firstName" json:"firstName"`
LastName string `bson:"lastName" json:"lastName"`
ExpMonth string `bson:"expMonth" json:"expMonth"`
ExpYear string `bson:"expYear" json:"expYear"`
Network string `bson:"network,omitempty" json:"network,omitempty"`
Country string `bson:"country,omitempty" json:"country,omitempty"`
}
func (m *PaymentMethod) AsCard() (*CardPaymentData, error) {

32
api/pkg/model/ctoken.go Normal file
View File

@@ -0,0 +1,32 @@
package model
import (
"fmt"
"github.com/tech/sendico/pkg/merrors"
"go.mongodb.org/mongo-driver/bson"
)
// TokenPaymentData represents a network or gateway-issued card token.
type TokenPaymentData struct {
Token string `bson:"token" json:"token"`
Network string `bson:"network,omitempty" json:"network,omitempty"`
Last4 string `bson:"last4,omitempty" json:"last4,omitempty"`
ExpMonth string `bson:"expMonth,omitempty" json:"expMonth,omitempty"`
ExpYear string `bson:"expYear,omitempty" json:"expYear,omitempty"`
CardholderName string `bson:"cardholderName,omitempty" json:"cardholderName,omitempty"`
Country string `bson:"country,omitempty" json:"country,omitempty"`
}
func (m *PaymentMethod) AsCardToken() (*TokenPaymentData, error) {
if m.Type != PaymentTypeCardToken {
return nil, merrors.InvalidArgument(fmt.Sprintf("payment method type is %s, not cardToken", m.Type), "type")
}
var d TokenPaymentData
if err := bson.Unmarshal(m.Data, &d); err != nil {
return nil, err
}
return &d, nil
}

View File

@@ -14,6 +14,7 @@ type PaymentType int
const (
PaymentTypeIban PaymentType = iota
PaymentTypeCard
PaymentTypeCardToken
PaymentTypeBankAccount
PaymentTypeWallet
PaymentTypeCryptoAddress
@@ -22,6 +23,7 @@ const (
var paymentTypeToString = map[PaymentType]string{
PaymentTypeIban: "iban",
PaymentTypeCard: "card",
PaymentTypeCardToken: "cardToken",
PaymentTypeBankAccount: "bankAccount",
PaymentTypeWallet: "wallet",
PaymentTypeCryptoAddress: "cryptoAddress",
@@ -30,6 +32,7 @@ var paymentTypeToString = map[PaymentType]string{
var paymentTypeFromString = map[string]PaymentType{
"iban": PaymentTypeIban,
"card": PaymentTypeCard,
"cardToken": PaymentTypeCardToken,
"bankAccount": PaymentTypeBankAccount,
"wallet": PaymentTypeWallet,
"cryptoAddress": PaymentTypeCryptoAddress,

View File

@@ -12,6 +12,7 @@ const (
Changes Type = "changes" // Tracks changes made to resources
Clients Type = "clients" // Represents client information
ChainGateway Type = "chain_gateway" // Represents chain gateway microservice
MntxGateway Type = "mntx_gateway" // Represents Monetix gateway microservice
FXOracle Type = "fx_oracle" // Represents FX oracle microservice
FeePlans Type = "fee_plans" // Represents fee plans microservice
FilterProjects Type = "filter_projects" // Represents comments on tasks or other resources
@@ -49,7 +50,7 @@ const (
func StringToSType(s string) (Type, error) {
switch Type(s) {
case Accounts, Confirmations, Amplitude, Site, Changes, Clients, ChainGateway, ChainWallets, ChainWalletBalances,
ChainTransfers, ChainDeposits, FXOracle, FeePlans, FilterProjects, Invitations, Invoices, Logo, Ledger,
ChainTransfers, ChainDeposits, MntxGateway, FXOracle, FeePlans, FilterProjects, Invitations, Invoices, Logo, Ledger,
LedgerAccounts, LedgerBalances, LedgerEntries, LedgerOutbox, LedgerParties, LedgerPlines, Notifications,
Organizations, Payments, PaymentOrchestrator, Permissions, Policies, PolicyAssignements,
RefreshTokens, Roles, Storage, Tenants, Workflows: