QIWI API¶
- class glQiwiApi.qiwi.client.QiwiWrapper(api_access_token: Optional[str] = None, phone_number: Optional[str] = None, secret_p2p: Optional[str] = None, without_context: bool = False, cache_time: Union[float, int] = 0, *args: Any, **kwargs: Any)[source]¶
Bases:
glQiwiApi.core.abc.wrapper.Wrapper
,glQiwiApi.core.mixins.HandlerCollectionMixin
,glQiwiApi.core.mixins.DataMixin
,glQiwiApi.core.mixins.ContextInstanceMixin
[QiwiWrapper
]Delegates the work of QIWI API, webhooks, polling. Fast and versatile wrapper.
- __init__(api_access_token: Optional[str] = None, phone_number: Optional[str] = None, secret_p2p: Optional[str] = None, cache_time_in_seconds: Union[float, int] = 0, session_holder: Optional[glQiwiApi.core.session.holder.AbstractSessionHolder[Any]] = None) None [source]¶
- Parameters
api_access_token – QIWI API token received from https://qiwi.com/api
phone_number – your phone number starting with +
secret_p2p – QIWI P2P secret key received from https://p2p.qiwi.com/
cache_time_in_seconds – Time to cache requests in seconds, default 0, respectively the request will not use the cache by default
session_holder – obtains session and helps to manage session lifecycle. You can pass your own session holder, for example using httpx lib and use it
- phone_number¶
- api_access_token¶
- secret_p2p¶
- async get_current_webhook() glQiwiApi.types.qiwi.webhooks.WebHookConfig [source]¶
List of active (active) notification handlers, associated with your wallet can be obtained with this request. Since now only one type of hook is used - webhook, then the response contains only one data object
- async get_webhook_secret_key(hook_id: str) str [source]¶
Each notification contains a digital signature of the message, encrypted with a key. To obtain a signature verification key, use this request.
- Parameters
hook_id – UUID of webhook
- Returns
Base64 encoded key
- async change_webhook_secret(hook_id: str) str [source]¶
Use this request to change the encryption key for notifications.
- Parameters
hook_id – UUID of webhook
- Returns
Base64 encoded key
- async bind_webhook(url: Optional[Union[str, glQiwiApi.ext.webhook_url.WebhookURL]] = None, transactions_type: int = 2, *, send_test_notification: bool = False, delete_old: bool = False) Tuple[Optional[glQiwiApi.types.qiwi.webhooks.WebHookConfig], str] [source]¶
[NON-API] EXCLUSIVE method to register new webhook or get old
- Parameters
url – service url
transactions_type – 0 => incoming, 1 => outgoing, 2 => all
send_test_notification – test_qiwi will send you test webhook update
delete_old – boolean, if True - delete old webhook
- Returns
Tuple of Hook and Base64-encoded key
- async transactions(rows: int = 50, operation: glQiwiApi.types.qiwi.transaction.TransactionType = TransactionType.ALL, sources: Optional[List[glQiwiApi.types.qiwi.transaction.Source]] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None) List[glQiwiApi.types.qiwi.transaction.Transaction] [source]¶
Method for receiving transactions on the account More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#payments_list
- Parameters
rows – number of transactions you want to receive
operation – The type of operations in the report for selection.
sources – List of payment sources, for filter
start_date – The starting date for searching for payments. Used only in conjunction with end_date.
end_date – the end date of the search for payments. Used only in conjunction with start_date.
- async transaction_info(transaction_id: Union[str, int], transaction_type: glQiwiApi.types.qiwi.transaction.TransactionType) glQiwiApi.types.qiwi.transaction.Transaction [source]¶
Method for obtaining complete information about a transaction
Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?python#txn_info
- Parameters
transaction_id –
transaction_type – only IN or OUT
- Returns
Transaction object
- async get_restriction() List[glQiwiApi.types.qiwi.restriction.Restriction] [source]¶
Method to check limits on your qiwi wallet Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?python#restrictions
- Returns
List where the dictionary is located with restrictions, if there are no restrictions, it returns an empty list
- async get_identification() glQiwiApi.types.qiwi.identification.Identification [source]¶
This method allows get your wallet identification data More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#ident
- async check_transaction(amount: Union[int, float], transaction_type: glQiwiApi.types.qiwi.transaction.TransactionType = TransactionType.IN, sender: Optional[str] = None, rows_num: int = 50, comment: Optional[str] = None) bool [source]¶
[ NON API METHOD ]
Method for verifying a transaction. This method uses self.transactions (rows = rows) “under the hood” to check payment.
For a little optimization, you can decrease rows by setting it, however, this does not guarantee the correct result
- Possible values for the transaction_type parameter:
‘IN’
‘OUT’
‘QIWI_CARD’
- Parameters
amount – amount of payment
transaction_type – type of payment
sender – number of receiver
rows_num – number of payments to be checked
comment – comment by which the transaction will be verified
- async get_limits(limit_types: Optional[List[str]] = None) Dict[str, glQiwiApi.types.qiwi.limit.Limit] [source]¶
Function for getting limits on the qiwi wallet account Returns wallet limits as a list, if there is no limit for a certain country, then it does not include it in the list Detailed documentation:
https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#limits
- async get_list_of_cards() List[glQiwiApi.types.qiwi.qiwi_master.Card] [source]¶
- async authenticate(birth_date: str, first_name: str, last_name: str, patronymic: str, passport: str, oms: Optional[str] = None, inn: Optional[str] = None, snils: Optional[str] = None) Dict[Any, Any] [source]¶
This request allows you to send data to identify your QIWI wallet. It is allowed to identify no more than 5 wallets per owner
To identify the wallet, you must send your full name, passport series number and date of birth. If the data has been verified, then the response will display your TIN and simplified wallet identification will be installed. If the data has not been verified, the wallet remains in the “Minimum” status.
- Parameters
birth_date – Date of birth as a format string 1998-02-11
first_name – First name
last_name – Last name
patronymic – Middle name
passport – Series / Number of the passport. Ex: 4400111222
oms –
snils –
inn –
- async get_receipt(transaction_id: Union[str, int], transaction_type: glQiwiApi.types.qiwi.transaction.TransactionType, file_format: str = 'PDF') glQiwiApi.types.arbitrary.file.File [source]¶
Method for receiving a receipt in byte format or file.
- Possible transaction_type values:
‘IN’
‘OUT’
‘QIWI_CARD’
- Parameters
transaction_id – transaction id, can be obtained by calling the to_wallet method, to_card
transaction_type – type of transaction: ‘IN’, ‘OUT’, ‘QIWI_CARD’
file_format – format of file
- async get_account_info() glQiwiApi.types.qiwi.account_info.QiwiAccountInfo [source]¶
Метод для получения информации об аккаунте
- async fetch_statistics(start_date: datetime.datetime, end_date: datetime.datetime, operation: glQiwiApi.types.qiwi.transaction.TransactionType = TransactionType.ALL, sources: Optional[List[str]] = None) glQiwiApi.types.qiwi.stats.Statistic [source]¶
This query is used to get summary statistics by the amount of payments for a given period. More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#payments_list
:param start_date:The start date of the statistics period. :param end_date: End date of the statistics period. :param operation: The type of operations taken into account when calculating statistics.
- Allowed values:
ALL - все операции, IN - только пополнения, OUT - только платежи, QIWI_CARD - только платежи по картам QIWI (QVC, QVP). По умолчанию ALL.
- Parameters
sources – The sources of payments QW_RUB - рублевый счет кошелька, QW_USD - счет кошелька в долларах, QW_EUR - счет кошелька в евро, CARD - привязанные и непривязанные к кошельку банковские карты, MK - счет мобильного оператора. Если не указан, учитываются все источники платежа.
- async list_of_balances() List[glQiwiApi.types.qiwi.account.Account] [source]¶
The request gets the current account balances of your QIWI Wallet. More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#balances_list
- async create_new_balance(currency_alias: str) Optional[Dict[str, bool]] [source]¶
The request creates a new account and balance in your QIWI Wallet
- Parameters
currency_alias – New account alias
- async available_balances() List[glQiwiApi.types.qiwi.balance.Balance] [source]¶
The request displays account aliases, available for creation in your QIWI Wallet
- async set_default_balance(currency_alias: str) Dict[Any, Any] [source]¶
The request sets up an account for your QIWI Wallet, whose balance will be used for funding all payments by default. The account must be contained in the list of accounts, you can get the list by calling list_of_balances method
- Parameters
currency_alias –
- async to_wallet(to_number: str, amount: Union[int, float, str], currency: str = '643', comment: Optional[str] = None) glQiwiApi.types.qiwi.payment_info.PaymentInfo [source]¶
Method for transferring money to another wallet
Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?python#p2p
- Parameters
to_number – recipient number
amount – the amount of money you want to transfer
currency – special currency code
comment – payment comment
- async to_card(trans_sum: Union[float, int], to_card: str) glQiwiApi.types.qiwi.payment_info.PaymentInfo [source]¶
Method for sending funds to the card. More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/#cards
- async predict_commission(to_account: str, pay_sum: Union[int, float]) glQiwiApi.types.qiwi.commission.Commission [source]¶
Full calc_commission of QIWI Wallet is refunded for payment in favor of the specified provider taking into account all tariffs for a given set of payment details.
- Parameters
to_account –
pay_sum –
- Returns
Commission object
- async get_cross_rates() List[glQiwiApi.types.qiwi.other.CrossRate] [source]¶
The method returns the current exchange rates and cross-rates of the QIWI Bank’s currencies.
- async payment_by_payment_details(payment_sum: glQiwiApi.types.amount.CurrencyAmount, payment_method: glQiwiApi.types.qiwi.other.PaymentMethod, fields: glQiwiApi.types.qiwi.other.FreePaymentDetailsFields, payment_id: Optional[str] = None) glQiwiApi.types.qiwi.payment_info.PaymentInfo [source]¶
Payment for services of commercial organizations according to their bank details.
- Parameters
payment_id – payment id, if not transmitted, is used uuid4 by default
payment_sum – a Sum object, which indicates the amount of the payment
payment_method – payment method
fields – payment details
- async buy_qiwi_master() glQiwiApi.types.qiwi.payment_info.PaymentInfo [source]¶
Method for buying QIWI Master package To call API methods, you need the QIWI Wallet API token with permissions to do the following: 1. Management of virtual cards, 2. Request information about the wallet profile, 3. View payment history, 4. Making payments without SMS. You can choose these rights when creating a new api token, to use api QIWI Master
- async issue_qiwi_master_card(card_alias: str = 'qvc-cpa') Optional[glQiwiApi.types.qiwi.qiwi_master.OrderDetails] [source]¶
Issuing a new card using the Qiwi Master API
When issuing a card, 3, and possibly 3 requests are made, namely, according to the following scheme:
_pre_qiwi_master_request - this method creates a request
_confirm_qiwi_master_request - confirms the issue of the card
_buy_new_qiwi_card - buys a new card, if such a card is not free
Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/#qiwi-master-issue-card
- async reject_p2p_bill(bill_id: str) glQiwiApi.types.qiwi.bill.Bill [source]¶
Use this method to cancel unpaid invoice.
- async check_p2p_bill_status(bill_id: str) str [source]¶
Method for checking the status of a p2p transaction.
Possible transaction types:
WAITING Bill is waiting for pay
PAID Bill was paid
REJECTED Bill was rejected
EXPIRED The bill has expired. Invoice not paid
Docs: https://developer.qiwi.com/ru/p2p-payments/?shell#invoice-status
- Parameters
bill_id –
- Returns
status of bill
- async create_p2p_bill(amount: Union[int, float], bill_id: Optional[str] = None, comment: Optional[str] = None, life_time: Optional[datetime.datetime] = None, theme_code: Optional[str] = None, pay_source_filter: Optional[List[str]] = None) glQiwiApi.types.qiwi.bill.Bill [source]¶
It is the reliable method for integration. Parameters are sent by means of server2server requests with authorization. Method allows you to issue an invoice, successful
response contains payUrl link to redirect client on Payment Form.
- Possible values of pay_source_filter:
‘qw’
‘card’
‘mobile’
- Parameters
amount – amount of payment
bill_id – unique transaction number, if not transmitted, generated automatically,
life_time – the date until which the invoice will be available for payment.
comment –
theme_code –
pay_source_filter – When you open the form, the following will be displayed only the translation methods specified in this parameter
- async retrieve_bills(rows: int, statuses: str = 'READY_FOR_PAY') List[glQiwiApi.types.qiwi.bill.Bill] [source]¶
A method for getting a list of your wallet’s outstanding bills.
The list is built in reverse chronological order.
By default, the list is paginated with 50 items each, but you can specify a different number of elements (no more than 50).
Filters by billing time can be used in the request, the initial account identifier.
- async pay_the_invoice(invoice_uid: str, currency: str) glQiwiApi.types.qiwi.bill.InvoiceStatus [source]¶
Execution of unconditional payment of the invoice without SMS-confirmation.
! Warning ! To use this method correctly you need to tick “Проведение платежей без SMS” when registering QIWI API and retrieve token
- Parameters
invoice_uid – Bill ID in QIWI system
currency –
- async refund_bill(bill_id: Union[str, int], refund_id: Union[str, int], json_bill_data: Union[glQiwiApi.types.amount.PlainAmount, Dict[str, Union[str, int]]]) glQiwiApi.types.qiwi.bill.RefundBill [source]¶
- The method allows you to make a refund on a paid invoice.
in the JSON body of the request for the json_bill_data parameter: amount.value - refund amount. amount.currency - return currency.
- Can be a dictionary or an OptionalSum object
Dictionary example: {
- “amount”: {
“currency”: “RUB”, “value”: 1 }
}
- Parameters
bill_id – unique account identifier in the merchant’s system
refund_id – unique identifier of the refund in the merchant’s system.
json_bill_data –
- Returns
RefundBill object