core

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddXNode

func AddXNode(node *models.Xnode) error

func ConnectToXNode

func ConnectToXNode(node *models.Xnode) (pb.XNodeGrpcClient, error)

Types

type AdminPurchaseNotify added in v0.4.1

type AdminPurchaseNotify struct {
	Tuser    *models.Tuser
	Purchase *models.Purchase
	Photo    *tele.Photo
}

AdminPurchaseNotify used to send notification to admins on new card2card event

type CallbackParameters added in v0.4.1

type CallbackParameters struct {
	TransactionId string
	OrderId       int64
	Amount        int64
}

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) Status

func (u *UserService) Status(uid uint64) (*models.Tuser, error)

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

func (u *UserService) Upgrade(user *models.Tuser, pck *models.Package) error

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)

type VerifyResponse added in v0.4.1

type VerifyResponse struct {
	Code        int64  `json:"code"`
	Amount      int64  `json:"amount"`
	OrderId     string `json:"order_id"`
	CardHolder  string `json:"card_holder"`
	ShaparakRef string `json:"Shaparak_Ref_Id"`
	Custom      interface{}
}

Directories

Path Synopsis
e

Jump to

Keyboard shortcuts

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