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
27 lines
719 B
Go
27 lines
719 B
Go
package model
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/tech/sendico/pkg/merrors"
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
type IbanPaymentData struct {
|
|
Iban string `bson:"iban" json:"iban"`
|
|
AccountHolder string `bson:"accountHolder" json:"accountHolder"`
|
|
Bic *string `bson:"bic,omitempty" json:"bic,omitempty"`
|
|
BankName *string `bson:"bankName,omitempty" json:"bankName,omitempty"`
|
|
}
|
|
|
|
func (m *PaymentMethod) AsIban() (*IbanPaymentData, error) {
|
|
if m.Type != PaymentTypeIban {
|
|
return nil, merrors.InvalidArgument(fmt.Sprintf("payment method type is %s, not iban", m.Type), "type")
|
|
}
|
|
var d IbanPaymentData
|
|
if err := bson.Unmarshal(m.Data, &d); err != nil {
|
|
return nil, err
|
|
}
|
|
return &d, nil
|
|
}
|