Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(c *Client)
- func Wallet(wallet string) func(c *Client)
- type Account
- type AuthInfo
- type Balance
- type BalanceResponse
- type Balances
- type CardsDetectResponse
- type Client
- type Code
- type ComissionResponse
- type Commission
- type Content
- type ContractInfo
- type DetermineOperatorParams
- type DeterminedProvider
- type ErrorResponse
- type Fields
- type History
- type HistoryParams
- type Identification
- type IdentificationInfo
- type Limit
- type MobilePinInfo
- type Opt
- type PassInfo
- type Payment
- type PaymentMethod
- type PaymentParams
- type PaymentRequest
- type PaymentResponse
- type PaymentStatistic
- type PaymentStatisticParams
- type Payments
- func (p *Payments) Comission(ctx context.Context, providerID int) (res ComissionResponse, err error)
- func (c *Payments) DetectProviderIDByCardNumber(ctx context.Context, cardNumber string) (id int, err error)
- func (p *Payments) History(ctx context.Context, rows uint, params ...url.Values) (pr PaymentsResponse, err error)
- func (c *Payments) Payment(ctx context.Context, psID int, amount float64, account string, ...) (res PaymentResponse, err error)
- func (p *Payments) SpecialComission(ctx context.Context, providerID int, to string, amount float64) (res SpecialComissionResponse, err error)
- func (p *Payments) Stat(ctx context.Context, startDate, endDate time.Time, params ...url.Values) (res StatResponse, err error)
- type PaymentsResponse
- type PinInfo
- type Profile
- type ProfileParams
- type ProfileResponse
- type Provider
- type PurchaseTotal
- type Range
- type SpecialComissionRequest
- type SpecialComissionResponse
- type SpecialRate
- type SpecialRateParams
- type StandardRate
- type StatResponse
- type State
- type Sum
- type SumNumeric
- type Terms
- type Transaction
- type TransactionMin
- type Txn
- type Type
- type UserInfo
- type UserProfile
Constants ¶
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" // QiwiProviderID used for payment to qiwi wallet QiwiProviderID = 99 // CurrencyRUB rub id CurrencyRUB = "643" // CurrencyUSD usd currency id CurrencyUSD = "840" // CurrencyEUR euro currency id CurrencyEUR = "978" // CurrencyKZT tenge currency id CurrencyKZT = "398" )
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" // EndpointPayment send money from wallet EndpointPayment = "sinap/api/v2/terms/%d/payments" // EndpointComission a provider comission EndpointComission = "sinap/providers/%d/form" // EndpointSpecialComission comission for specific amount EndpointSpecialComission = "sinap/providers/%d/onlineCommission" )
Variables ¶
var ( // ErrSyntaxError error with bad request ErrSyntaxError = fmt.Errorf("Ошибка синтаксиса запроса (неправильный формат данных)") // ErrTokenInvalid error ErrTokenInvalid = fmt.Errorf("Неверный токен или истек срок действия токена") // ErrNotFound error ErrNotFound = fmt.Errorf("Не найден кошелёк, транзакция или отсутствуют платежи с указанными признаками") // ErrRateLimitReached error ErrRateLimitReached = fmt.Errorf("Слишком много запросов, сервис временно недоступен") // ErrInsufficient error ErrInsufficient = fmt.Errorf("Недостаточно средств") )
var ( // OpenMethods not require Bearer token OpenMethods = map[string]bool{ EndpointCardsDetect: true, } )
Functions ¶
Types ¶
type Balance ¶
type Balance struct {
// contains filtered or unexported fields
}
Balance for payment-history endpoints
type BalanceResponse ¶
type BalanceResponse struct {
Accounts []Account
}
BalanceResponse response of balance request
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 {
Payments *Payments
Profile *Profile
Balance *Balance
// contains filtered or unexported fields
}
Client main struct
type ComissionResponse ¶ added in v0.0.2
type ComissionResponse struct {
Content struct {
Terms struct {
Commission struct {
Ranges []struct {
Bound float64 `json:"bound"`
Fixed float64 `json:"fixed"`
Rate float64 `json:"rate"`
Min float64 `json:"min"`
Max float64 `json:"max"`
} `json:"ranges"`
} `json:"commission"`
} `json:"terms"`
} `json:"content"`
}
ComissionResponse json unserialazer
type Commission ¶ added in v1.0.0
type Commission struct {
Ranges []Range `json:"ranges"`
}
type ContractInfo ¶ added in v1.0.0
type ContractInfo struct {
Blocked bool `json:"blocked"`
ContractID int64 `json:"contractId"`
CreationDate string `json:"creationDate"`
Features []interface{} `json:"features"`
IdentificationInfo []IdentificationInfo `json:"identificationInfo"`
}
type DetermineOperatorParams ¶ added in v1.0.0
type DetermineOperatorParams struct {
Phone string `json:"phone,omitempty" url:"phone,omitempty"`
}
type DeterminedProvider ¶ added in v1.0.0
type ErrorResponse ¶ added in v1.0.0
type History ¶
type History struct {
Data []Transaction `json:"data"`
NextTxnId int64 `json:"nextTxnId"`
NextTxnDate string `json:"nextTxnDate"`
}
type HistoryParams ¶ added in v1.0.0
type HistoryParams struct {
Rows int `json:"rows,omitempty" url:"rows,omitempty"`
Operation string `json:"operation,omitempty" url:"operation,omitempty"`
Sources []string `json:"sources,omitempty" url:"sources,omitempty"`
StartDate string `json:"startDate,omitempty" url:"startDate,omitempty"`
EndDate string `json:"endDate,omitempty" url:"endDate,omitempty"`
NextTxnDate string `json:"nextTxnDate,omitempty" url:"nextTxnDate,omitempty"`
NextTxnId int64 `json:"nextTxnId,omitempty" url:"nextTxnId,omitempty"`
}
all dates should be formatted in RFC3339
type Identification ¶ added in v1.0.0
type Identification struct {
Required bool `json:"required"`
}
type IdentificationInfo ¶ added in v1.0.0
type MobilePinInfo ¶ added in v1.0.0
type PaymentMethod ¶ added in v1.0.0
type PaymentParams ¶ added in v1.0.0
type PaymentRequest ¶
type PaymentRequest struct {
ID string `json:"id"`
Sum struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
} `json:"sum"`
PaymentMethod PaymentMethod `json:"paymentMethod"`
Fields struct {
Account string `json:"account"` // Номер банковской карты
RemName string `json:"rem_name,omitempty"` //Имя отправителя.
RemNameF string `json:"rem_name_f,omitempty"` // Фамилия отправителя.
RecAddress string `json:"rec_address,omitempty"` //Адрес отправителя
RecCity string `json:"rec_city,omitempty"` //Город отправителя.
RecCountry string `json:"rec_country,omitempty"` //Страна отправителя.
RegName string `json:"reg_name,omitempty"` //Имя получателя.
RegNameF string `json:"reg_name_f,omitempty"` //Фамилия получателя.
} `json:"fields"`
// Qiwi to qiwi related field
Comment string `json:"comment,omitempty"`
}
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"`
// Qiwi to qiwi related field
Comment string `json:"comment,omitempty"`
}
PaymentResponse foemat of payment response
type PaymentStatistic ¶ added in v1.0.0
type PaymentStatisticParams ¶ added in v1.0.0
type PaymentStatisticParams struct {
StartDate string `json:"startDate,omitempty" url:"startDate,omitempty"`
EndDate string `json:"endDate,omitempty" url:"endDate,omitempty"`
Operation string `json:"operation,omitempty" url:"operation,omitempty"`
Sources []string `json:"sources,omitempty" url:"sources,omitempty"`
}
all dates should be formatted in RFC3339
type Payments ¶ added in v0.0.2
type Payments struct {
// contains filtered or unexported fields
}
Payments for payment-history endpoints
func NewPayments ¶ added in v0.0.2
NewPayments returns new Payments obj
func (*Payments) Comission ¶ added in v0.0.2
func (p *Payments) Comission(ctx context.Context, providerID int) (res ComissionResponse, err error)
Comission get provider comission
func (*Payments) DetectProviderIDByCardNumber ¶ added in v1.0.0
func (c *Payments) DetectProviderIDByCardNumber(ctx context.Context, cardNumber string) (id int, err error)
Detect detect card PS
func (*Payments) History ¶ added in v0.0.2
func (p *Payments) History(ctx context.Context, rows uint, params ...url.Values) (pr PaymentsResponse, err error)
History return payments history
func (*Payments) Payment ¶ added in v1.0.0
func (c *Payments) Payment(ctx context.Context, psID int, amount float64, account string, comments ...string) (res PaymentResponse, err error)
Payment make mayment
func (*Payments) SpecialComission ¶ added in v0.0.2
func (p *Payments) SpecialComission(ctx context.Context, providerID int, to string, amount float64) (res SpecialComissionResponse, err error)
SpecialComission get provider comission
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
type ProfileParams ¶ added in v1.0.0
type ProfileParams struct {
AuthInfoEnabled bool `json:"authInfoEnabled,omitempty" url:"authInfoEnabled,omitempty"`
ContractInfoEnabled bool `json:"contractInfoEnabled,omitempty" url:"contractInfoEnabled,omitempty"`
UserInfoEnabled bool `json:"userInfoEnabled,omitempty" url:"userInfoEnabled,omitempty"`
}
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 PurchaseTotal ¶ added in v1.0.0
type PurchaseTotal struct {
Total Sum `json:"total"`
}
type SpecialComissionRequest ¶ added in v0.0.2
type SpecialComissionRequest struct {
Account string `json:"account"`
PaymentMethod struct {
Type string `json:"type"`
AccountID string `json:"accountId"`
} `json:"paymentMethod"`
PurchaseTotals struct {
Total struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
} `json:"total"`
} `json:"purchaseTotals"`
}
SpecialComissionRequest json serializer
type SpecialComissionResponse ¶ added in v0.0.2
type SpecialComissionResponse struct {
ProviderID int `json:"providerId"`
WithdrawSum struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
} `json:"withdrawSum"`
EnrollmentSum struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
} `json:"enrollmentSum"`
QwCommission struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
} `json:"qwCommission"`
FundingSourceCommission struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
} `json:"fundingSourceCommission"`
WithdrawToEnrollmentRate float64 `json:"withdrawToEnrollmentRate"`
}
SpecialComissionResponse json unserialazer
type SpecialRate ¶ added in v1.0.0
type SpecialRate struct {
ProviderId string `json:"providerId"`
WithdrawSum Sum `json:"withdrawSum"`
EnrollmentSum Sum `json:"enrollmentSum"`
QwCommission Sum `json:"qwCommission"`
FundingSourceCommission Sum `json:"fundingSourceCommission"`
WithdrawToEnrollmentRate int `json:"withdrawToEnrollmentRate"`
}
type SpecialRateParams ¶ added in v1.0.0
type SpecialRateParams struct {
Account string `json:"account"`
PaymentMethod PaymentMethod `json:"paymentMethod"`
PurchaseTotal PurchaseTotal `json:"purchaseTotal"`
}
type StandardRate ¶ added in v1.0.0
type StandardRate struct {
Content Content `json:"content"`
}
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 SumNumeric ¶ added in v1.0.0
type Terms ¶ added in v1.0.0
type Terms struct {
Cashbacks []interface{} `json:"cashbacks"`
Commission Commission `json:"commission"`
Description string `json:"description"`
ID string `json:"id"`
Identification Identification `json:"identification"`
Limits []Limit `json:"limits"`
Overpayment bool `json:"overpayment"`
RepeatablePayment bool `json:"repeatablePayment"`
Type string `json:"type"`
Underpayment bool `json:"underpayment"`
}
type Transaction ¶ added in v1.0.0
type Transaction struct {
TxnId int64 `json:"txnId"`
PersonId int64 `json:"personId"`
Date string `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 SumNumeric `json:"sum"`
Commission SumNumeric `json:"commission"`
Total SumNumeric `json:"total"`
Provider Provider `json:"provider"`
Comment string `json:"comment"`
CurrencyRate float64 `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"`
}
type TransactionMin ¶ added in v1.0.0
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 float64 `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
type UserInfo ¶ added in v1.0.0
type UserInfo struct {
DefaultPayCurrency int `json:"defaultPayCurrency"`
DefaultPaySource int `json:"defaultPaySource"`
Email string `json:"email"`
FirstTxnID int64 `json:"firstTxnId"`
Language string `json:"language"`
Operator string `json:"operator"`
PhoneHash string `json:"phoneHash"`
PromoEnabled string `json:"promoEnabled"`
}
type UserProfile ¶ added in v1.0.0
type UserProfile struct {
AuthInfo AuthInfo `json:"authInfo"`
ContractInfo ContractInfo `json:"contractInfo"`
UserInfo UserInfo `json:"userInfo"`
}