services

package
v0.0.0-...-9cf9cea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const MaxErrorMessageLength = 255

Variables

View Source
var (
	ErrDisbursementNotFound        = errors.New("disbursement not found")
	ErrDisbursementNotReadyToStart = errors.New("disbursement is not ready to be started")
	ErrDisbursementNotReadyToPause = errors.New("disbursement is not ready to be paused")
	ErrDisbursementWalletDisabled  = errors.New("disbursement wallet is disabled")

	ErrDisbursementStatusCantBeChanged = errors.New("disbursement status can't be changed to the requested status")
	ErrDisbursementStartedByCreator    = errors.New("disbursement can't be started by its creator")
)
View Source
var (
	ErrPaymentNotFound            = errors.New("payment not found")
	ErrPaymentNotReadyToCancel    = errors.New("payment is not ready to be canceled")
	ErrPaymentStatusCantBeChanged = errors.New("payment status can't be changed to the requested status")
)

Functions

func SetupAssetsForProperNetwork

func SetupAssetsForProperNetwork(ctx context.Context, dbConnectionPool db.DBConnectionPool, network utils.NetworkType, assetsNetworkMap AssetsNetworkMapType) error

SetupAssetsForProperNetwork updates and inserts assets for the given Network Passphrase (`network`). So it avoids the application having same asset code with multiple issuers.

func SetupWalletsForProperNetwork

func SetupWalletsForProperNetwork(ctx context.Context, dbConnectionPool db.DBConnectionPool, network utils.NetworkType, walletsNetworkMap WalletsNetworkMapType) error

SetupWalletsForProperNetwork updates and inserts wallets for the given Network Passphrase (`network`). So it avoids the application having wallets that doesn't support the given network.

Types

type AssetsNetworkMapType

type AssetsNetworkMapType map[utils.NetworkType][]data.Asset

type CreateAuthUserService

type CreateAuthUserService struct {
	// contains filtered or unexported fields
}

func NewCreateUserService

func NewCreateUserService(models *data.Models, dbConnectionPool db.DBConnectionPool, authManager auth.AuthManager, messengerClient message.MessengerClient) *CreateAuthUserService

func (*CreateAuthUserService) CreateUser

func (s *CreateAuthUserService) CreateUser(ctx context.Context, newUser auth.User, uiBaseURL string) (*auth.User, error)

type DisbursementManagementService

type DisbursementManagementService struct {
	// contains filtered or unexported fields
}

DisbursementManagementService is a service for managing disbursements.

func NewDisbursementManagementService

func NewDisbursementManagementService(
	models *data.Models,
	dbConnectionPool db.DBConnectionPool,
	authManager auth.AuthManager,
	horizonClient horizonclient.ClientInterface,
	eventProducer events.Producer,
) *DisbursementManagementService

NewDisbursementManagementService is a factory function for creating a new DisbursementManagementService.

func (*DisbursementManagementService) AppendUserMetadata

func (s *DisbursementManagementService) AppendUserMetadata(ctx context.Context, disbursements []*data.Disbursement) ([]*DisbursementWithUserMetadata, error)

func (*DisbursementManagementService) GetDisbursementReceiversWithCount

func (s *DisbursementManagementService) GetDisbursementReceiversWithCount(ctx context.Context, disbursementID string, queryParams *data.QueryParams) (*utils.ResultWithTotal, error)

func (*DisbursementManagementService) GetDisbursementsWithCount

func (s *DisbursementManagementService) GetDisbursementsWithCount(ctx context.Context, queryParams *data.QueryParams) (*utils.ResultWithTotal, error)

func (*DisbursementManagementService) PauseDisbursement

func (s *DisbursementManagementService) PauseDisbursement(ctx context.Context, disbursementID string, user *auth.User) error

PauseDisbursement pauses a disbursement and all its payments.

func (*DisbursementManagementService) StartDisbursement

func (s *DisbursementManagementService) StartDisbursement(ctx context.Context, disbursementID string, user *auth.User, distributionPubKey string) error

StartDisbursement starts a disbursement and all its payments and receivers wallets.

type DisbursementWithUserMetadata

type DisbursementWithUserMetadata struct {
	data.Disbursement
	CreatedBy UserReference `json:"created_by"`
	StartedBy UserReference `json:"started_by"`
}

type InsufficientBalanceError

type InsufficientBalanceError struct {
	DisbursementID     string
	DisbursementAsset  data.Asset
	AvailableBalance   float64
	DisbursementAmount float64
	TotalPendingAmount float64
}

func (InsufficientBalanceError) Error

func (e InsufficientBalanceError) Error() string

type PatchAnchorPlatformTransactionCompletionService

type PatchAnchorPlatformTransactionCompletionService struct {
	// contains filtered or unexported fields
}

func (*PatchAnchorPlatformTransactionCompletionService) PatchAPTransactionForPaymentEvent

func (*PatchAnchorPlatformTransactionCompletionService) PatchAPTransactionsForPayments

func (s *PatchAnchorPlatformTransactionCompletionService) PatchAPTransactionsForPayments(ctx context.Context) error

func (*PatchAnchorPlatformTransactionCompletionService) SetModels

type PatchAnchorPlatformTransactionCompletionServiceInterface

type PatchAnchorPlatformTransactionCompletionServiceInterface interface {
	PatchAPTransactionForPaymentEvent(ctx context.Context, tx schemas.EventPaymentCompletedData) error
	PatchAPTransactionsForPayments(ctx context.Context) error
}

type PaymentFromSubmitterService

type PaymentFromSubmitterService struct {
	// contains filtered or unexported fields
}

PaymentFromSubmitterService is a service that monitors TSS transactions that were complete and sync their completion state with the SDP payments.

func NewPaymentFromSubmitterService

func NewPaymentFromSubmitterService(models *data.Models, tssDBConnectionPool db.DBConnectionPool) *PaymentFromSubmitterService

NewPaymentFromSubmitterService is a PaymentFromSubmitterService constructor.

func (PaymentFromSubmitterService) SyncBatchTransactions

func (s PaymentFromSubmitterService) SyncBatchTransactions(ctx context.Context, batchSize int, tenantID string) error

SyncBatchTransactions monitors TSS transactions that were complete and sync their completion state with the SDP payments.

func (PaymentFromSubmitterService) SyncTransaction

SyncTransaction syncs the completed TSS transaction with the SDP's payment.

type PaymentFromSubmitterServiceInterface

type PaymentFromSubmitterServiceInterface interface {
	SyncTransaction(ctx context.Context, tx *schemas.EventPaymentCompletedData) error
	SyncBatchTransactions(ctx context.Context, batchSize int, tenantID string) error
}

type PaymentManagementService

type PaymentManagementService struct {
	// contains filtered or unexported fields
}

PaymentManagementService is a service for managing disbursements.

func NewPaymentManagementService

func NewPaymentManagementService(models *data.Models, dbConnectionPool db.DBConnectionPool) *PaymentManagementService

NewPaymentManagementService is a factory function for creating a new PaymentManagementService.

func (*PaymentManagementService) CancelPayment

func (s *PaymentManagementService) CancelPayment(ctx context.Context, paymentID string) error

CancelPayment update payment to status 'canceled'

type PaymentToSubmitterService

type PaymentToSubmitterService struct {
	// contains filtered or unexported fields
}

PaymentToSubmitterService is a service that pushes SDP's ready-to-pay payments to the transaction submission service.

func NewPaymentToSubmitterService

func NewPaymentToSubmitterService(models *data.Models, tssDBConnectionPool db.DBConnectionPool) *PaymentToSubmitterService

func (PaymentToSubmitterService) SendBatchPayments

func (s PaymentToSubmitterService) SendBatchPayments(ctx context.Context, batchSize int) error

SendBatchPayments sends SDP's ready-to-pay payments (in batches) to the transaction submission service.

func (PaymentToSubmitterService) SendPaymentsReadyToPay

func (s PaymentToSubmitterService) SendPaymentsReadyToPay(ctx context.Context, paymentsReadyToPay schemas.EventPaymentsReadyToPayData) error

SendPaymentsReadyToPay sends SDP's ready-to-pay payments (in batches) to the transaction submission service.

type PaymentToSubmitterServiceInterface

type PaymentToSubmitterServiceInterface interface {
	SendPaymentsReadyToPay(ctx context.Context, paymentsReadyToPay schemas.EventPaymentsReadyToPayData) error
	SendBatchPayments(ctx context.Context, batchSize int) error
}

type ReadyPaymentsCancellationService

type ReadyPaymentsCancellationService struct {
	// contains filtered or unexported fields
}

func NewReadyPaymentsCancellationService

func NewReadyPaymentsCancellationService(models *data.Models) *ReadyPaymentsCancellationService

func (ReadyPaymentsCancellationService) CancelReadyPayments

func (s ReadyPaymentsCancellationService) CancelReadyPayments(ctx context.Context) error

CancelReadyPayments cancels SDP's ready-to-pay payments that are older than the specified period.

type ReadyPaymentsCancellationServiceInterface

type ReadyPaymentsCancellationServiceInterface interface {
	CancelReadyPayments(ctx context.Context) error
}

type SendReceiverWalletInviteService

type SendReceiverWalletInviteService struct {
	Models *data.Models
	// contains filtered or unexported fields
}

func NewSendReceiverWalletInviteService

func NewSendReceiverWalletInviteService(models *data.Models, messengerClient message.MessengerClient, sep10SigningPrivateKey string, maxInvitationSMSResendAttempts int64, crashTrackerClient crashtracker.CrashTrackerClient) (*SendReceiverWalletInviteService, error)

func (SendReceiverWalletInviteService) SendInvite

func (s SendReceiverWalletInviteService) SendInvite(ctx context.Context, receiverWalletInvitationData ...schemas.EventReceiverWalletSMSInvitationData) error

SendInvite sends the invitation’s deep link to the wallet’s application. The approach to sending the invitation is to send the deep link for each asset the wallet will pay based on the payment. For instance, the Wallet Foo is in two Ready Payments, one with USDC and the other with EUROC. So the receiver who has a Stellar Address pending registration (status:READY) in this wallet will receive both invites for USDC and EUROC. This would not impact the user receiving both token amounts. It's only for the registration process.

type SendReceiverWalletInviteServiceInterface

type SendReceiverWalletInviteServiceInterface interface {
	SendInvite(ctx context.Context, receiverWalletInvitationData ...schemas.EventReceiverWalletSMSInvitationData) error
}

type UserReference

type UserReference struct {
	ID        string `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}
type WalletDeepLink struct {
	// DeepLink is the deep link used to open the wallet invitation link.
	DeepLink string
	// Route is an optional parameter that can be used to specify the route to open in the wallet, in case it's not already present in the DeepLink.
	Route string // (optional)
	// OrganizationName is the name of the organization that is sending the invitation.
	OrganizationName string
	// AssetCode is the code of the Stellar asset that the receiver will be able to receive.
	AssetCode string
	// AssetIssuer is the issuer of the Stellar asset that the receiver will be able to receive.
	AssetIssuer string
	// TenantBaseURL is the base URL for the tenant that the receiver wallet belongs to.
	TenantBaseURL string
}

func (WalletDeepLink) BaseURLWithRoute

func (wdl WalletDeepLink) BaseURLWithRoute() (string, error)

BaseURLWithRoute returns the base URL of the deep link with the route appended.

func (wdl WalletDeepLink) GetSignedRegistrationLink(stellarSecretKey string) (string, error)

GetSignedRegistrationLink will return the registration link accompanied with an extra query parameter containing the signature of the registration link, where the signature is created using the stellarSecretKey with the unsigned link as the message, keeping in mind that the insigned link query parameters were sorted in alphabetical order to generate the signature.

func (wdl WalletDeepLink) GetUnsignedRegistrationLink() (string, error)

GetUnsignedRegistrationLink creates a deep link for the wallet registration using the format below: <deep_link></route>?<domain>&<name>&<asset>.

func (WalletDeepLink) TomlFileDomain

func (wdl WalletDeepLink) TomlFileDomain() (string, error)

type WalletsNetworkMapType

type WalletsNetworkMapType map[utils.NetworkType][]data.Wallet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL