Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added payment method with provider id #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ print(api.balance)

api.pay(account="ТЕЛЕФОН ПОЛУЧАТЕЛЯ", amount=1, comment='Привет мир!')

print(api.balance)
```
### Переводим деньги на счет провайдера QIWI
```python
from SimpleQIWI import *

token = "ВАШ ТОКЕН" # https://qiwi.com/api
phone = "ВАШ ТЕЛЕФОН"

api = QApi(token=token, phone=phone)

print(api.balance)

# fields НЕОБЯЗАТЕЛЬНЫЙ ПАРАМЕТР (Зависит от оплачиваемой услуги)
# В большинстве случаев хватает provider (идентификатор провайдера) и account (лицевой счет)

fields{
"account_type": "1",
"account":"1111********2222",
"exp_date": "MMYY"
}

api.pay(provider='ИДЕНТИФИКАТОР ПРОВАЙДЕРА',account="ПОЛЬЗОВАТЕЛЬСКИЙ СЧЕТ", amount=1, fields=fields)

print(api.balance)
```
### Получаем входящие платежи
Expand Down
19 changes: 16 additions & 3 deletions SimpleQIWI/Session.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,27 @@ def decorator(func):

return decorator

def pay(self, account, amount, currency='643', comment=None, tp='Account', acc_id='643'):
def pay(self, provider, account, amount, fields=None, currency='643', comment=None, tp='Account', acc_id='643'):
"""
Transfer to QIWI Wallet

:type provider: str
:type account: str
:type amount: int
:type currency: str
:type comment: str
:type tp: str
:type acc_id: str

:type fields: dict

:param provider: Provider ID (e.g. https://qiwi.com/payment/form/26580 = 26580)
:param account: Phone number of payee
:param amount: Amount of money for transaction
:param currency: Currency
:param comment: Comment for transaction
:param tp: Type of payee
:param acc_id: Currency
:param fields: whatever you need

:return: response
"""
Expand All @@ -222,8 +226,17 @@ def pay(self, account, amount, currency='643', comment=None, tp='Account', acc_i
if comment is not None:
post_args['comment'] = comment

if fields is not None:
for key,value in fields.items():
post_args['fields'][key] = value

if provider is not None:
url = 'https://edge.qiwi.com/sinap/api/v2/terms/'+provider+'/payments'
else:
url= 'https://edge.qiwi.com/sinap/api/v2/terms/99/payments'

response = self._s.post(
url='https://edge.qiwi.com/sinap/api/v2/terms/99/payments',
url=url,
json=post_args
)

Expand Down