All checks were successful
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
28 lines
717 B
Go
28 lines
717 B
Go
package model
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/tech/sendico/pkg/merrors"
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
type CryptoAddressPaymentData struct {
|
|
Address string `bson:"address" json:"address"`
|
|
Network string `bson:"network" json:"network"`
|
|
DestinationTag *string `bson:"destinationTag,omitempty" json:"destinationTag,omitempty"`
|
|
}
|
|
|
|
func (m *PaymentMethod) AsCryptoAddress() (*CryptoAddressPaymentData, error) {
|
|
if m.Type != PaymentTypeCryptoAddress {
|
|
return nil, merrors.InvalidArgument(fmt.Sprintf("payment method type is %s, not cryptoAddress", m.Type), "type")
|
|
}
|
|
|
|
var d CryptoAddressPaymentData
|
|
if err := bson.Unmarshal(m.Data, &d); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &d, nil
|
|
}
|