Documentation ¶
Index ¶
- func AddXNode(node *models.Xnode) error
- func ConnectToXNode(node *models.Xnode) (pb.XNodeGrpcClient, error)
- type AdminPurchaseNotify
- type CallbackParameters
- type NextPayTerminal
- type Notification
- type NotificationType
- type PaymentTerminal
- type SubService
- type UserService
- func (u *UserService) ConfirmPurchase(purchaseId string) error
- func (u *UserService) CreateBankTransaction(user *models.Tuser, pck *models.Package) (string, error)
- func (u *UserService) DisabledCallback() error
- func (u *UserService) GetRandomBankCard() (string, error)
- func (u *UserService) ListAvailablePackages() ([]*models.Package, error)
- func (u *UserService) ProcessPurchaseOnReceipt(user *models.Tuser) (AdminPurchaseNotify, error)
- func (u *UserService) Register(tid uint64, username string, packageName string) error
- func (u *UserService) RejectPurchase(purchaseId string) error
- func (u *UserService) SpawnRunners()
- func (u *UserService) Status(uid uint64) (*models.Tuser, error)
- func (u *UserService) SubscribeNotification(ch chan<- Notification)
- func (u *UserService) TrafficUsageRunner()
- func (u *UserService) Unregister(uid uint64) error
- func (u *UserService) Upgrade(user *models.Tuser, pck *models.Package) error
- func (u *UserService) VerifyBankTransaction(parameters CallbackParameters) (*models.Purchase, error)
- type VerifyResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectToXNode ¶
func ConnectToXNode(node *models.Xnode) (pb.XNodeGrpcClient, error)
Types ¶
type AdminPurchaseNotify ¶ added in v0.4.1
AdminPurchaseNotify used to send notification to admins on new card2card event
type CallbackParameters ¶ added in v0.4.1
type NextPayTerminal ¶ added in v0.4.1
type NextPayTerminal struct {
// contains filtered or unexported fields
}
func NewNextPayTerminal ¶ added in v0.4.1
func NewNextPayTerminal(apiKey, callbackUri string) NextPayTerminal
func (NextPayTerminal) CreateRedirectUrl ¶ added in v0.4.1
func (n NextPayTerminal) CreateRedirectUrl(transId string) string
func (NextPayTerminal) CreateToken ¶ added in v0.4.1
func (n NextPayTerminal) CreateToken(amount, purchaseId int64) (string, error)
func (NextPayTerminal) VerifyOrder ¶ added in v0.4.1
func (n NextPayTerminal) VerifyOrder(parameters CallbackParameters) (VerifyResponse, error)
type Notification ¶ added in v0.3.1
type Notification struct { Type NotificationType User *models.Tuser Extra interface{} }
type NotificationType ¶ added in v0.3.1
type NotificationType int
const ( PurchaseSuccessful NotificationType = iota PurchaseRejected PurchaseFailed UserMaxTrafficReached )
type PaymentTerminal ¶ added in v0.4.1
type PaymentTerminal interface { CreateToken(int64, int64) (string, error) VerifyOrder(CallbackParameters) (VerifyResponse, error) CreateRedirectUrl(transId string) string }
type SubService ¶ added in v0.2.1
type SubService struct {
// contains filtered or unexported fields
}
func NewSubService ¶ added in v0.2.1
func NewSubService() *SubService
func (*SubService) GenerateUserSub ¶ added in v0.2.1
func (s *SubService) GenerateUserSub(token string) (string, error)
GenerateUserSub requests user's sub-content from xNodes and merge them together
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewUserService ¶
func NewUserService(terminal PaymentTerminal) *UserService
func (*UserService) ConfirmPurchase ¶ added in v0.3.1
func (u *UserService) ConfirmPurchase(purchaseId string) error
func (*UserService) CreateBankTransaction ¶ added in v0.4.1
func (u *UserService) CreateBankTransaction(user *models.Tuser, pck *models.Package) (string, error)
CreateBankTransaction communicate with bank-terminal to get a new transaction and returns transaction id
func (*UserService) DisabledCallback ¶
func (u *UserService) DisabledCallback() error
DisabledCallback is a callback-function to be called by XrayPanels when they have disabled a user due to traffic limit
func (*UserService) GetRandomBankCard ¶ added in v0.3.1
func (u *UserService) GetRandomBankCard() (string, error)
func (*UserService) ListAvailablePackages ¶ added in v0.3.1
func (u *UserService) ListAvailablePackages() ([]*models.Package, error)
func (*UserService) ProcessPurchaseOnReceipt ¶ added in v0.3.1
func (u *UserService) ProcessPurchaseOnReceipt(user *models.Tuser) (AdminPurchaseNotify, error)
ProcessPurchaseOnReceipt process a purchase when the user paid the price and sent a receipt to the admins
func (*UserService) Register ¶
func (u *UserService) Register(tid uint64, username string, packageName string) error
Register a user on local repo and send a "AddClient" request to panels
func (*UserService) RejectPurchase ¶ added in v0.3.1
func (u *UserService) RejectPurchase(purchaseId string) error
func (*UserService) SpawnRunners ¶ added in v0.2.1
func (u *UserService) SpawnRunners()
func (*UserService) SubscribeNotification ¶ added in v0.3.1
func (u *UserService) SubscribeNotification(ch chan<- Notification)
func (*UserService) TrafficUsageRunner ¶ added in v0.2.1
func (u *UserService) TrafficUsageRunner()
TrafficUsageRunner runs periodically to fetch the latest traffic-usage from xPanels
func (*UserService) Unregister ¶
func (u *UserService) Unregister(uid uint64) error
func (*UserService) Upgrade ¶
Upgrade the user to a new package then send a command to all the available servers
func (*UserService) VerifyBankTransaction ¶ added in v0.4.1
func (u *UserService) VerifyBankTransaction(parameters CallbackParameters) (*models.Purchase, error)