qiwi

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2017 License: MIT Imports: 12 Imported by: 2

README

Qiwi GoDoc

An golang qiwi.com api client

Qiwi.com - CIS and Russian Payment system and this package relevant for Russian-speaking users. All the following documentation will be in Russian.

Чтобы получить токен доступа, перейдите по ссылке

Установка

go get -u github.com/zhuharev/qiwi

Использование

token = "YOUR_TOKEN"
qw := qiwi.New(token)

// get last 10 payments
resp, err := qw.History.Payments(10)
if err != nil {
  // handle error
}
log.Printf("%v", resp)

Documentation

Index

Constants

View Source
const (
	// BaseURL represent base url
	BaseURL = "https://edge.qiwi.com"
	// OpenBaseURL open base url
	OpenBaseURL = "https://qiwi.com"
	// VersionAPI current qiwi.com api version
	VersionAPI = "v1"
)
View Source
const (
	// EndpointProfile endpoint
	EndpointProfile = "person-profile/v1/profile/current"
	// EndpointIdent identification endpoint
	EndpointIdent = "identification/v1/persons/%s/identification" // %s - wallet
	// EndpointPaymentsHistory get history
	EndpointPaymentsHistory = "payment-history/v1/persons/%s/payments" // %s - wallet
	// EndpointStat get stat of payments
	EndpointStat = "payment-history/v1/persons/%s/payments/total" // %s - wallet
	// EndpointTxnInfo get info anout single txn
	EndpointTxnInfo = "payment-history/v1/transactions/%s" // %s - txn_id
	// EndpointBalance get wallet balance
	EndpointBalance = "funding-sources/v1/accounts/current"
	// EndpointCardsDetect detect code of PS
	EndpointCardsDetect = "card/detect.action"
	// EndpointCardsPayment send money from wallet
	EndpointCardsPayment = "sinap/api/v2/terms/%d/payments"
)

Variables

View Source
var (
	// OpenMethods not require Bearer token
	OpenMethods = map[string]bool{
		EndpointCardsDetect: true,
	}
)

Functions

func Debug

func Debug(c *Client)

Debug enable debug

func Wallet

func Wallet(wallet string) func(c *Client)

Wallet set wallet to client example: qw := qiwi.New(token, qiwi.Wallet("70000000000"))

Types

type Balance

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

Balance for payment-history endpoints

func NewBalance

func NewBalance(c *Client) *Balance

NewBalance returns new Balance obj

func (*Balance) Current

func (b *Balance) Current() (hr *BalanceResponse, err error)

Current call api and get current user balance

type BalanceResponse

type BalanceResponse struct {
	Accounts []struct {
		Alias   string `json:"alias"`
		FsAlias string `json:"fsAlias"`
		Title   string `json:"title"`
		Type    struct {
			ID    string `json:"id"`
			Title string `json:"title"`
		} `json:"type"`
		HasBalance bool `json:"hasBalance"`
		Balance    struct {
			Amount   float64 `json:"amount"`
			Currency int     `json:"currency"`
		} `json:"balance"`
		Currency int `json:"currency"`
	} `json:"accounts"`
}

BalanceResponse response of balance request

type Cards

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

Cards for payment-history endpoints

func NewCards

func NewCards(c *Client) *Cards

NewCards returns new Cards obj

func (*Cards) Detect

func (c *Cards) Detect(cardNumber string) (id int64, err error)

Detect detect card PS

func (*Cards) Payment

func (c *Cards) Payment(psID int64, amount float64, cardNumber string) (res PaymentResponse, err error)

Payment make mayment

type CardsDetectResponse

type CardsDetectResponse struct {
	Code struct {
		Value json.Number `json:"value"`
		Name  string      `json:"_name"`
	} `json:"code"`
	Message json.Number `json:"message"`
}

CardsDetectResponse api response

type Client

type Client struct {
	History *History
	Profile *Profile
	Balance *Balance
	Cards   *Cards
	// contains filtered or unexported fields
}

Client main struct

func New

func New(token string, opts ...Opt) *Client

New returns client

func (*Client) SetWallet

func (c *Client) SetWallet(wallet string)

SetWallet set wallet for client

type History

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

History for payment-history endpoints

func NewHistory

func NewHistory(c *Client) *History

NewHistory returns new History obj

func (*History) Payments

func (h *History) Payments(rows uint, params ...url.Values) (hr *PaymentsResponse, err error)

Payments call api and get payments history

func (*History) Stat

func (h *History) Stat(startDate, endDate time.Time, params ...url.Values) (res StatResponse, err error)

Stat get sum of incoming and outgoing payments

type Opt

type Opt func(c *Client)

Opt returns func for changing client used for New

type PaymentRequest

type PaymentRequest struct {
	ID  string `json:"id"`
	Sum struct {
		Amount   float64 `json:"amount"`
		Currency string  `json:"currency"`
	} `json:"sum"`
	PaymentMethod struct {
		Type      string `json:"type"`
		AccountID string `json:"accountId"`
	} `json:"paymentMethod"`
	Fields struct {
		Account string `json:"account"`
	} `json:"fields"`
}

PaymentRequest request of payment

type PaymentResponse

type PaymentResponse struct {
	ID     string `json:"id"`
	Terms  string `json:"terms"`
	Fields struct {
		Account string `json:"account"`
	} `json:"fields"`
	Sum struct {
		Amount   float64 `json:"amount"`
		Currency string  `json:"currency"`
	} `json:"sum"`
	Source      string `json:"source"`
	Transaction struct {
		ID    string `json:"id"`
		State struct {
			Code string `json:"code"`
		} `json:"state"`
	} `json:"transaction"`
}

PaymentResponse foemat of payment response

type PaymentsResponse

type PaymentsResponse struct {
	Data        []Txn       `json:"data"`
	NextTxnID   interface{} `json:"nextTxnId"`
	NextTxnDate interface{} `json:"nextTxnDate"`
}

PaymentsResponse api response format

type Profile

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

Profile for profile endpoints

func NewProfile

func NewProfile(c *Client) *Profile

NewProfile returns new Profile obj

func (*Profile) Current

func (h *Profile) Current() (hr *ProfileResponse, err error)

Current call api and get current user profile

type ProfileResponse

type ProfileResponse struct {
	AuthInfo struct {
		BoundEmail    string    `json:"boundEmail"`
		IP            string    `json:"ip"`
		LastLoginDate time.Time `json:"lastLoginDate"`
		MobilePinInfo struct {
			LastMobilePinChange time.Time `json:"lastMobilePinChange"`
			MobilePinUsed       bool      `json:"mobilePinUsed"`
			NextMobilePinChange time.Time `json:"nextMobilePinChange"`
		} `json:"mobilePinInfo"`
		PassInfo struct {
			LastPassChange time.Time `json:"lastPassChange"`
			NextPassChange time.Time `json:"nextPassChange"`
			PasswordUsed   bool      `json:"passwordUsed"`
		} `json:"passInfo"`
		PersonID int64 `json:"personId"`
		PinInfo  struct {
			PinUsed bool `json:"pinUsed"`
		} `json:"pinInfo"`
		RegistrationDate time.Time `json:"registrationDate"`
	} `json:"authInfo"`
	ContractInfo struct {
		Blocked            bool          `json:"blocked"`
		ContractID         int64         `json:"contractId"`
		CreationDate       time.Time     `json:"creationDate"`
		Features           []interface{} `json:"features"`
		IdentificationInfo []struct {
			BankAlias           string `json:"bankAlias"`
			IdentificationLevel string `json:"identificationLevel"`
		} `json:"identificationInfo"`
	} `json:"contractInfo"`
	UserInfo struct {
		DefaultPayCurrency int         `json:"defaultPayCurrency"`
		DefaultPaySource   int         `json:"defaultPaySource"`
		Email              interface{} `json:"email"`
		FirstTxnID         int64       `json:"firstTxnId"`
		Language           string      `json:"language"`
		Operator           string      `json:"operator"`
		PhoneHash          string      `json:"phoneHash"`
		PromoEnabled       interface{} `json:"promoEnabled"`
	} `json:"userInfo"`
}

ProfileResponse reponse

type StatResponse

type StatResponse struct {
	IncomingTotal []struct {
		Amount   float64 `json:"amount"`
		Currency int     `json:"currency"`
	} `json:"incomingTotal"`
	OutgoingTotal []struct {
		Amount   float64 `json:"amount"`
		Currency int     `json:"currency"`
	} `json:"outgoingTotal"`
}

StatResponse response of stat endpoind

type Txn

type Txn struct {
	TxnID      int64     `json:"txnId"`
	PersonID   int64     `json:"personId"`
	Date       time.Time `json:"date"`
	ErrorCode  int       `json:"errorCode"`
	Error      string    `json:"error"`
	Status     string    `json:"status"`
	Type       string    `json:"type"`
	StatusText string    `json:"statusText"`
	TrmTxnID   string    `json:"trmTxnId"`
	Account    string    `json:"account"`
	Sum        struct {
		Amount   float64 `json:"amount"`
		Currency int     `json:"currency"`
	} `json:"sum"`
	Commission struct {
		Amount   float64 `json:"amount"`
		Currency int     `json:"currency"`
	} `json:"commission"`
	Total struct {
		Amount   float64 `json:"amount"`
		Currency int     `json:"currency"`
	} `json:"total"`
	Provider struct {
		ID          int           `json:"id"`
		ShortName   string        `json:"shortName"`
		LongName    string        `json:"longName"`
		LogoURL     string        `json:"logoUrl"`
		Description string        `json:"description"`
		Keys        string        `json:"keys"`
		SiteURL     string        `json:"siteUrl"`
		Extras      []interface{} `json:"extras"`
	} `json:"provider"`
	Source                 interface{}   `json:"source"`
	Comment                string        `json:"comment"`
	CurrencyRate           int           `json:"currencyRate"`
	Extras                 []interface{} `json:"extras"`
	ChequeReady            bool          `json:"chequeReady"`
	BankDocumentAvailable  bool          `json:"bankDocumentAvailable"`
	BankDocumentReady      bool          `json:"bankDocumentReady"`
	RepeatPaymentEnabled   bool          `json:"repeatPaymentEnabled"`
	FavoritePaymentEnabled bool          `json:"favoritePaymentEnabled"`
	RegularPaymentEnabled  bool          `json:"regularPaymentEnabled"`
}

Txn represent qiwi transaction

Jump to

Keyboard shortcuts

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