Skip to content

Commit

Permalink
v1.3.0 - Fixes + SBP Banks
Browse files Browse the repository at this point in the history
  • Loading branch information
kewldan committed Feb 6, 2024
1 parent c5365f5 commit 0f8cfac
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 32 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

<div align="center">

[//]: # (<a href="https://aaio.io/" target="_blank">)

[//]: # ( <img alt="AAIO Badge" src="https://aaio.io/assets/svg/banners/big/dark-2.svg" title="Aaio - Сервис по приему онлайн платежей">)

[//]: # (</a>)
<a href="https://aaio.so/" target="_blank">
<img alt="AAIO Badge" src="https://aaio.so/assets/svg/banners/big/dark-2.svg" title="Aaio - Сервис по приему онлайн платежей">
</a>

[![kewldan - AAIO](https://img.shields.io/static/v1?label=kewldan&message=AAIO&color=blue&logo=github)](https://github.com/kewldan/AAIO "Go to GitHub repo")
[![GitHub release](https://img.shields.io/github/release/kewldan/AAIO?include_prereleases=&sort=semver&color=blue)](https://github.com/kewldan/AAIO/releases/)
Expand All @@ -15,15 +13,15 @@
[![Upload Python Package](https://github.com/kewldan/AAIO/actions/workflows/python-publish.yml/badge.svg)](https://github.com/kewldan/AAIO/actions/workflows/python-publish.yml)
[![issues - AAIO](https://img.shields.io/github/issues/kewldan/AAIO)](https://github.com/kewldan/AAIO/issues)

[AAIO Official documentation](https://wiki.aaio.io/)
[AAIO Official documentation](https://wiki.aaio.so/)

</div>

## About

This library is a wrapper for the https://aaio.io API **from enthusiasts**. All methods are described and all types are
This library is a wrapper for the https://aaio.so API **from enthusiasts**. All methods are described and all types are
**explicitly** defined. Methods that create requests to
aaio.io
aaio.so
return a pydantic's models for each response. Please write about all problems related to the library
to [issues](https://github.com/kewldan/AAIO/issues)

Expand All @@ -34,7 +32,7 @@ API is up-to-date as of *19 December 2023*.
* Docs - https://kewldan.vercel.app/projects/aaio
* Demo - https://t.me/aaio_demo_bot
* Requirements: Python >= 3.7
* Added to [AAIO SDKs](https://wiki.aaio.io/priem-platezhei/gotovye-cms-moduli-i-sdk/python-3-sdk)
* Added to [AAIO SDKs](https://wiki.aaio.so/priem-platezhei/gotovye-cms-moduli-i-sdk/python-3-sdk)

### Features

Expand Down Expand Up @@ -81,7 +79,7 @@ from aaio import AAIO

async def main():
client = AAIO('MERCHANT ID', 'SECRET KEY', 'API KEY')
payment_url = client.create_payment(100, 'my_order_id', 'My order description', 'qiwi', 'support@aaio.io',
payment_url = client.create_payment(100, 'my_order_id', 'My order description', 'qiwi', 'support@aaio.so',
'referral code', currency='USD',
language='en')
print(payment_url) # Prints payment url for customer
Expand Down
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Главная

[![](https://aaio.io/assets/svg/banners/big/dark-2.svg)](https://aaio.io/)
[![](https://aaio.so/assets/svg/banners/big/dark-2.svg)](https://aaio.so/)

[AAIO Official documentat](https://wiki.aaio.io/)
[AAIO Official documentat](https://wiki.aaio.so/)

## О библиотеке

Expand All @@ -17,7 +17,7 @@ Python AAIO - библиотека, позволяющая удобно авто
* Docs - https://kewldan.vercel.app/projects/aaio
* Демо бот в Telegram - https://t.me/aaio\_demo\_bot
* Внешние зависимости: Python >= 3.7
* Добавлена в [AAIO SDKs](https://wiki.aaio.io/priem-platezhei/gotovye-cms-moduli-i-sdk/python-3-sdk)
* Добавлена в [AAIO SDKs](https://wiki.aaio.so/priem-platezhei/gotovye-cms-moduli-i-sdk/python-3-sdk)

## Установка

Expand Down
2 changes: 1 addition & 1 deletion docs/nachalo-raboty.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ client = aaio.AAIO(merchant_id, secret_key, api_key)

**api\_key** - API ключ, его можно указать как `''`, если вы не используете общие методы

[https://aaio.io/cabinet/api](https://aaio.io/cabinet/api)
[https://aaio.so/cabinet/api](https://aaio.so/cabinet/api)

<figure><img src=".gitbook/assets/image (1).png" alt=""><figcaption></figcaption></figure>
2 changes: 1 addition & 1 deletion docs/payments/proverka-statusa-platezha.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ info = await client.get_payment_info(order_id)
print(info) # in_process, success, hold, expired
```

Для остальных параметров запроса прошу смотреть оффициальную документацию AAIO по ссылке [https://wiki.aaio.io/api/informaciya-o-zakaze](https://wiki.aaio.io/api/informaciya-o-zakaze)
Для остальных параметров запроса прошу смотреть оффициальную документацию AAIO по ссылке [https://wiki.aaio.so/api/informaciya-o-zakaze](https://wiki.aaio.so/api/informaciya-o-zakaze)
2 changes: 1 addition & 1 deletion docs/payments/sozdanie-platezha.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ payment_url: str = client.create_payment(amount, order_id)

Прошу сразу посетить [khoroshie-praktiki.md](../khoroshie-praktiki.md "mention") для полезной информации

Для остальных параметров запроса прошу смотреть оффициальную документацию AAIO по ссылке [https://wiki.aaio.io/priem-platezhei/sozdanie-zakaza](https://wiki.aaio.io/priem-platezhei/sozdanie-zakaza)
Для остальных параметров запроса прошу смотреть оффициальную документацию AAIO по ссылке [https://wiki.aaio.so/priem-platezhei/sozdanie-zakaza](https://wiki.aaio.so/priem-platezhei/sozdanie-zakaza)
2 changes: 1 addition & 1 deletion docs/payoffs/proverka-statusa-zayavki.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ info = await client.get_payoff_info(payoff_id)
print(info.status) # in_process, cancel, success
```

Для остальных параметров запроса прошу смотреть официальную документацию AAIO по ссылке [https://wiki.aaio.io/api/informaciya-o-zayavke-na-vyvod-sredstv](https://wiki.aaio.io/api/informaciya-o-zayavke-na-vyvod-sredstv)
Для остальных параметров запроса прошу смотреть официальную документацию AAIO по ссылке [https://wiki.aaio.so/api/informaciya-o-zayavke-na-vyvod-sredstv](https://wiki.aaio.so/api/informaciya-o-zayavke-na-vyvod-sredstv)
2 changes: 1 addition & 1 deletion docs/payoffs/sozdanie-zayavki.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
</strong><strong>await client.create_payoff(method, amount, wallet, payoff_id)
</strong></code></pre>

Для остальных параметров запроса прошу смотреть официальную документацию AAIO по ссылке [https://wiki.aaio.io/api/vyvod-sredstv](https://wiki.aaio.io/api/vyvod-sredstv)
Для остальных параметров запроса прошу смотреть официальную документацию AAIO по ссылке [https://wiki.aaio.so/api/vyvod-sredstv](https://wiki.aaio.so/api/vyvod-sredstv)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "aaio"
version = "1.2.6"
version = "1.3.0"
description = "Async AAIO api wrapper for python"
readme = "README.md"
authors = [{ name = "kewldan", email = "[email protected]" }]
Expand Down
37 changes: 24 additions & 13 deletions src/aaio/AAIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from aaio.types.payoff_info import PayoffInfo
from aaio.types.payoff_methods import PayoffMethods
from aaio.types.payoff_rates import PayoffRates
from aaio.types.payoff_sbp_banks import PayoffSbpBanks


async def create_invoice(payment_url: str):
Expand All @@ -25,7 +26,7 @@ class AAIO:
AAIO client for API interaction
Session will be automatically closed
API for https://aaio.io/
API for https://aaio.so/
"""

def __init__(self, merchant_id: str, secret: str, api_key: str, default_currency: str = 'RUB',
Expand All @@ -34,9 +35,9 @@ def __init__(self, merchant_id: str, secret: str, api_key: str, default_currency
Creates instance of one AAIO merchant API client
Args:
merchant_id: Merchant ID from https://aaio.io/cabinet
secret: 1st secret key from https://aaio.io/cabinet
api_key: API key from https://aaio.io/cabinet/api
merchant_id: Merchant ID from https://aaio.so/cabinet
secret: 1st secret key from https://aaio.so/cabinet
api_key: API key from https://aaio.so/cabinet/api
default_currency: If not set - RUB, but can be overwritten for each request (Optional)
base_url: Base URL for requests (Optional)
"""
Expand All @@ -50,7 +51,7 @@ def __init__(self, merchant_id: str, secret: str, api_key: str, default_currency
def __generate_sign(self, amount: float, order_id: str, currency: str) -> str:
"""
Generates sign for payment creation
See https://wiki.aaio.io/priem-platezhei/sozdanie-zakaza/metodika-formirovaniya-podpisi
See https://wiki.aaio.so/priem-platezhei/sozdanie-zakaza/metodika-formirovaniya-podpisi
Args:
amount: Amount in your currency
Expand All @@ -77,7 +78,7 @@ def create_payment(self, amount: float, order_id: str, description: str = None,
language: str = 'ru') -> str:
"""
Creates payment URL (Not a request)
See https://wiki.aaio.io/priem-platezhei/sozdanie-zakaza for more detailed information
See https://wiki.aaio.so/priem-platezhei/sozdanie-zakaza for more detailed information
Args:
amount: Payment amount
Expand Down Expand Up @@ -120,7 +121,7 @@ async def get_ips(self) -> List[str]:
async def get_payment_info(self, order_id: str) -> PaymentInfo:
"""
Creates a request for get payment information
See https://wiki.aaio.io/api/informaciya-o-zakaze
See https://wiki.aaio.so/api/informaciya-o-zakaze
Args:
order_id: Your order ID
Expand All @@ -141,7 +142,7 @@ async def get_payment_info(self, order_id: str) -> PaymentInfo:
async def get_balances(self) -> Balance:
"""
Creates a request for get balances of user
See https://wiki.aaio.io/api/poluchenie-balansa
See https://wiki.aaio.so/api/poluchenie-balansa
Returns: Model from response JSON
"""
Expand All @@ -154,7 +155,7 @@ async def create_payoff(self, method: str, amount: float, wallet: str, payoff_id
commission_type: int = 0) -> CreatePayoff:
"""
Creates a request for payoff creating
See https://wiki.aaio.io/api/vyvod-sredstv
See https://wiki.aaio.so/api/vyvod-sredstv
Args:
method: Payoff method
Expand All @@ -179,10 +180,20 @@ async def create_payoff(self, method: str, amount: float, wallet: str, payoff_id

return CreatePayoff(**response)

async def get_payoff_sbp_banks(self) -> PayoffSbpBanks:
"""
Returns a list of available banks for payoff
See https://wiki.aaio.so/api/banki-dlya-vyvoda-sredstv-na-sbp
Returns: list of banks
"""
response = await self.__create_request('/api/sbp-banks-payoff')

return PayoffSbpBanks(**response)

async def get_payoff_info(self, payoff_id: str = None, aaio_id: str = None) -> PayoffInfo:
"""
Creates a request for get payoff information
See https://wiki.aaio.io/api/informaciya-o-zayavke-na-vyvod-sredstv
See https://wiki.aaio.so/api/informaciya-o-zayavke-na-vyvod-sredstv
One id is required!
Expand All @@ -206,7 +217,7 @@ async def get_payoff_info(self, payoff_id: str = None, aaio_id: str = None) -> P
async def get_payoff_rates(self) -> PayoffRates:
"""
Creates a request for get rates for payoff
See https://wiki.aaio.io/api/kurs-valyut-pri-vyvode-sredstv
See https://wiki.aaio.so/api/kurs-valyut-pri-vyvode-sredstv
Returns: Model from response JSON
Expand All @@ -219,7 +230,7 @@ async def get_payoff_rates(self) -> PayoffRates:
async def get_payoff_methods(self) -> PayoffMethods:
"""
Creates a request for get available payoff methods
See https://wiki.aaio.io/api/dostupnye-metody-dlya-vyvoda-sredstv
See https://wiki.aaio.so/api/dostupnye-metody-dlya-vyvoda-sredstv
Returns: Model from response JSON
Expand All @@ -232,7 +243,7 @@ async def get_payoff_methods(self) -> PayoffMethods:
async def get_payment_methods(self) -> PaymentMethods:
"""
Creates a request for get available payment methods
See https://wiki.aaio.io/api/dostupnye-metody-dlya-sozdaniya-zakaza
See https://wiki.aaio.so/api/dostupnye-metody-dlya-sozdaniya-zakaza
Returns: Model from response JSON
Expand Down
9 changes: 9 additions & 0 deletions src/aaio/types/create_payoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ class CreatePayoff(BaseModel):
commission: float
commission_type: int
status: Literal['in_process', 'cancel', 'success']

def is_success(self) -> bool:
return self.status == 'success'

def is_in_process(self) -> bool:
return self.status == 'in_process'

def is_cancelled(self) -> bool:
return self.status == 'cancel'
11 changes: 11 additions & 0 deletions src/aaio/types/payoff_sbp_banks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pydantic import BaseModel


class SbpBank(BaseModel):
bankId: str
bankName: str
bankIcon: str


class PayoffSbpBanks(BaseModel):
list: list[SbpBank]

0 comments on commit 0f8cfac

Please sign in to comment.