+address book service
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
This commit is contained in:
66
api/pkg/model/payment.go
Normal file
66
api/pkg/model/payment.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type PaymentType int
|
||||
|
||||
const (
|
||||
PaymentTypeIban PaymentType = iota
|
||||
PaymentTypeCard
|
||||
PaymentTypeBankAccount
|
||||
PaymentTypeWallet
|
||||
)
|
||||
|
||||
var paymentTypeToString = map[PaymentType]string{
|
||||
PaymentTypeIban: "iban",
|
||||
PaymentTypeCard: "card",
|
||||
PaymentTypeBankAccount: "bankAccount",
|
||||
PaymentTypeWallet: "wallet",
|
||||
}
|
||||
|
||||
var paymentTypeFromString = map[string]PaymentType{
|
||||
"iban": PaymentTypeIban,
|
||||
"card": PaymentTypeCard,
|
||||
"bankAccount": PaymentTypeBankAccount,
|
||||
"wallet": PaymentTypeWallet,
|
||||
}
|
||||
|
||||
func (t PaymentType) String() string {
|
||||
if v, ok := paymentTypeToString[t]; ok {
|
||||
return v
|
||||
}
|
||||
return "iban"
|
||||
}
|
||||
|
||||
func (t PaymentType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(t.String())
|
||||
}
|
||||
|
||||
func (t *PaymentType) UnmarshalJSON(data []byte) error {
|
||||
var val string
|
||||
if err := json.Unmarshal(data, &val); err != nil {
|
||||
return err
|
||||
}
|
||||
v, ok := paymentTypeFromString[val]
|
||||
if !ok {
|
||||
return merrors.InvalidArgument(fmt.Sprintf("unknown PaymentType: %q", val))
|
||||
}
|
||||
*t = v
|
||||
return nil
|
||||
}
|
||||
|
||||
type PaymentMethod struct {
|
||||
PermissionBound `bson:",inline" json:",inline"`
|
||||
|
||||
RecipientRef primitive.ObjectID `bson:"recipientRef" json:"recipientRef"`
|
||||
Type PaymentType `bson:"type" json:"type"`
|
||||
IsActive bool `bson:"isActive" json:"isActive"`
|
||||
Data bson.Raw `bson:"data" json:"data"`
|
||||
}
|
||||
Reference in New Issue
Block a user