Documentation ¶
Index ¶
- Constants
- Variables
- type ConfirmTransaction
- type CreateOpt
- type CreateTransaction
- type Filter
- type MetaData
- type ReceiveTransaction
- type Service
- func (s *Service) Cancel(ctx context.Context, tx *Transaction, status Status, reason string, ...) error
- func (s *Service) Confirm(ctx context.Context, merchantID, txID int64, params ConfirmTransaction) (*Transaction, error)
- func (s *Service) Create(ctx context.Context, merchantID int64, params CreateTransaction, ...) (*Transaction, error)
- func (s *Service) EagerLoadByPaymentIDs(ctx context.Context, merchantID int64, paymentIDs []int64) ([]*Transaction, error)
- func (s *Service) GetByFilter(ctx context.Context, filter Filter) (*Transaction, error)
- func (s *Service) GetByHash(ctx context.Context, networkID, txHash string) (*Transaction, error)
- func (s *Service) GetByID(ctx context.Context, merchantID, id int64) (*Transaction, error)
- func (s *Service) GetLatestByPaymentID(ctx context.Context, paymentID int64) (*Transaction, error)
- func (s *Service) ListByFilter(ctx context.Context, filter Filter, limit int64) ([]*Transaction, error)
- func (s *Service) Receive(ctx context.Context, merchantID, txID int64, params ReceiveTransaction) (*Transaction, error)
- func (s *Service) UpdateTransactionHash(ctx context.Context, merchantID, txID int64, txHash string) error
- type Status
- type Transaction
- type Type
Constants ¶
const ( MetaComment wallet.MetaDataKey = "comment" MetaErrorReason wallet.MetaDataKey = "errorReason" MetaTransactionID = "transactionId" MetaRecipientWalletID = "recipientWalletId" MetaMerchantID = "merchantId" )
const ( // MerchantIDWildcard discards filtration by merchant id MerchantIDWildcard = int64(-1) // SystemMerchantID indicates txs related to system SystemMerchantID = int64(0) )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ConfirmTransaction ¶
type ConfirmTransaction struct { Status Status SenderAddress string TransactionHash string FactAmount money.Money NetworkFee money.Money MetaData MetaData // contains filtered or unexported fields }
func (*ConfirmTransaction) AllowZeroNetworkFee ¶
func (c *ConfirmTransaction) AllowZeroNetworkFee()
type CreateOpt ¶
type CreateOpt func(p *CreateTransaction)
func IncomingUnexpected ¶
func IncomingUnexpected() CreateOpt
IncomingUnexpected marks that tx should be stored as StatusCompleted w/o any further processing.
type CreateTransaction ¶
type CreateTransaction struct { Type Type // EntityID that is related to that tx. // In case of incoming tx that's payment id // In case of internal tx that's 0 // In case of withdrawal tx that's payment (withdrawal) id EntityID int64 SenderAddress string SenderWallet *wallet.Wallet RecipientAddress string RecipientWallet *wallet.Wallet TransactionHash string Currency money.CryptoCurrency Amount money.Money USDAmount money.Money ServiceFee money.Money IsTest bool // contains filtered or unexported fields }
type Filter ¶
type Filter struct { RecipientWalletID int64 NetworkID string Currency string Types []Type Statuses []Status HashIsEmpty bool }
Filter filter for resolving tx by wallet, network & currency and possible types/statuses. If types/statuses field is empty, then filter this type is omitted.
type ReceiveTransaction ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New( store *repository.Store, blockchainService blockchain.Resolver, wallets *wallet.Service, logger *zerolog.Logger, ) *Service
func (*Service) Confirm ¶
func (s *Service) Confirm( ctx context.Context, merchantID, txID int64, params ConfirmTransaction, ) (*Transaction, error)
func (*Service) Create ¶
func (s *Service) Create( ctx context.Context, merchantID int64, params CreateTransaction, opts ...CreateOpt, ) (*Transaction, error)
Create creates transaction record in the database. If Type is TypeInternal, merchantID should be zero.
func (*Service) EagerLoadByPaymentIDs ¶
func (*Service) GetByFilter ¶
GetByFilter returns tx filtered by recipient wallet id and other stuff.
func (*Service) GetLatestByPaymentID ¶
func (*Service) ListByFilter ¶
func (s *Service) ListByFilter(ctx context.Context, filter Filter, limit int64) ([]*Transaction, error)
ListByFilter returns several txs filtered by recipient wallet id and other stuff.
func (*Service) Receive ¶
func (s *Service) Receive( ctx context.Context, merchantID, txID int64, params ReceiveTransaction, ) (*Transaction, error)
Receive updates tx when system notices tx on the blockchain, but it's not confirmed yet.
type Status ¶
type Status string
const ( // StatusPending tx was created StatusPending Status = "pending" // StatusInProgress tx is in progress: blockchain transaction is not confirmed yet StatusInProgress Status = "inProgress" // StatusInProgressInvalid tx is in progress: blockchain transaction is not confirmed yet // but system already sees that amount is not expected StatusInProgressInvalid Status = "inProgressInv" // StatusCompleted transaction completed StatusCompleted Status = "completed" // StatusCompletedInvalid transaction completed but not as expected // e.g. user deposits more than required StatusCompletedInvalid Status = "completedInv" // StatusCancelled transaction was canceled w/o actual appearance on blockchain StatusCancelled Status = "canceled" // StatusFailed transaction was confirmed in blockchain as failed (reverted) // but gas was consumed StatusFailed Status = "failed" )
type Transaction ¶
type Transaction struct { ID int64 CreatedAt time.Time UpdatedAt time.Time MerchantID int64 RecipientAddress string RecipientWalletID *int64 SenderAddress *string SenderWalletID *int64 HashID *string Type Type EntityID int64 Status Status Currency money.CryptoCurrency Amount money.Money USDAmount money.Money FactAmount *money.Money ServiceFee money.Money NetworkFee *money.Money IsTest bool MetaData MetaData }
func (*Transaction) ExplorerLink ¶
func (tx *Transaction) ExplorerLink() (string, error)
ExplorerLink returns link with blockchain explorer e.g. EtherScan
func (*Transaction) IsFinalized ¶
func (tx *Transaction) IsFinalized() bool
func (*Transaction) IsInProgress ¶
func (tx *Transaction) IsInProgress() bool
func (*Transaction) NetworkID ¶
func (tx *Transaction) NetworkID() string
func (*Transaction) PaymentLink ¶
func (tx *Transaction) PaymentLink() (string, error)
PaymentLink returns link for payment QR code generation.