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

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
}