# aiocloudpayments
Python Async [CloudPayments](https://developers.cloudpayments.ru/#api) Library
# Client Basic Usage Example
```
from datetime import date
from aiocloudpayments import AioCpClient
async def main():
client = AioCpClient(PUBLIC_ID, API_SECRET)
await client.test()
await client.charge_card(
amount=10,
currency="RUB",
invoice_id="1234567",
ip_address="123.123.123.123",
description="Payment for goods in example.com",
account_id="user_x",
name="CARDHOLDER NAME",
card_cryptogram_packet="01492500008719030128SMfLeYdKp5dSQVIiO5l6ZCJiPdel4uDjdFTTz1UnXY+3QaZcNOW8lmXg0H670MclS4lI+qLkujKF4pR5Ri+T/E04Ufq3t5ntMUVLuZ998DLm+OVHV7FxIGR7snckpg47A73v7/y88Q5dxxvVZtDVi0qCcJAiZrgKLyLCqypnMfhjsgCEPF6d4OMzkgNQiynZvKysI2q+xc9cL0+CMmQTUPytnxX52k9qLNZ55cnE8kuLvqSK+TOG7Fz03moGcVvbb9XTg1oTDL4pl9rgkG3XvvTJOwol3JDxL1i6x+VpaRxpLJg0Zd9/9xRJOBMGmwAxo8/xyvGuAj85sxLJL6fA==",
payer=Person(
first_name="Test",
last_name="Test",
middle_name="Test",
birth=date(1998, 1, 16),
address="12A, 123",
street="Test Avenue",
city="LosTestels, City of Test Angels",
country="Testland",
phone="+1 111 11 11",
post_code="101011010"
)
)
await client.disconnect()
```
# AiohttpDispatcher Basic Usage Example
```
from aiocloudpayments import AiohttpDispatcher, Result
from aiocloudpayments.types import PayNotification, CancelNotification, CheckNotification
CERT_FILE = "cert.pem"
CERT_FILE = "pkey.pem"
def main():
dp = AiohttpDispatcher()
# router is not needed here, but I am just showing the logic
router = Router()
# register with router
@router.cancel(lambda n: 5 > n.amount > 1)
async def foo(notification: CancelNotification):
print(f"{notification=}")
# return {"result": 0}
return Result.OK
# register with router
@router.pay(lambda n: n.amount <= 1)
async def foo(notification: PayNotification):
print(f"{notification.amount=}")
# return {"result": 0}
return Result.OK
# register with router
@router.check()
async def foo(notification: CheckNotification):
print(f"{notification.amount=}")
# return {"result": 12}
return Result.WRONG_AMOUNT
# register with dp
@dp.cancel(lambda n: n.amount > 5)
async def foo(notification: CancelNotification):
print(f"{notification.amount=}, > 5")
# if you don't return anything, Result.OK is assumed
dp.include_router(router)
ssl_context = SSLContext()
ssl_context.load_cert_chain(CERT_FILE, KEY_FILE)
dp.run_app(
AioCpClient(PUBLIC_ID, API_SECRET),
"/test",
pay_path="/pay",
cancel_path="/cancel",
ssl_context=ssl_context,
check_hmac=False # disable hmac check, only use in development environments
)
```
architecture inspired by [aiogram](https://github.com/aiogram/aiogram)
Raw data
{
"_id": null,
"home_page": "https://github.com/drforse/aiocloudpayments",
"name": "aiocloudpayments",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "cloudpayments,python,asyncio",
"author": "drforse",
"author_email": "george.lifeslice@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/43/ff/5b20fa45a94c2799a35dbf61eadbd1c5b9f43f77eceba389ffa798bc4b46/aiocloudpayments-0.1.0.tar.gz",
"platform": null,
"description": "# aiocloudpayments\nPython Async [CloudPayments](https://developers.cloudpayments.ru/#api) Library\n# Client Basic Usage Example\n```\nfrom datetime import date\n\nfrom aiocloudpayments import AioCpClient\n\n\nasync def main():\n client = AioCpClient(PUBLIC_ID, API_SECRET)\n\n await client.test()\n\n await client.charge_card(\n amount=10,\n currency=\"RUB\",\n invoice_id=\"1234567\",\n ip_address=\"123.123.123.123\",\n description=\"Payment for goods in example.com\",\n account_id=\"user_x\",\n name=\"CARDHOLDER NAME\",\n card_cryptogram_packet=\"01492500008719030128SMfLeYdKp5dSQVIiO5l6ZCJiPdel4uDjdFTTz1UnXY+3QaZcNOW8lmXg0H670MclS4lI+qLkujKF4pR5Ri+T/E04Ufq3t5ntMUVLuZ998DLm+OVHV7FxIGR7snckpg47A73v7/y88Q5dxxvVZtDVi0qCcJAiZrgKLyLCqypnMfhjsgCEPF6d4OMzkgNQiynZvKysI2q+xc9cL0+CMmQTUPytnxX52k9qLNZ55cnE8kuLvqSK+TOG7Fz03moGcVvbb9XTg1oTDL4pl9rgkG3XvvTJOwol3JDxL1i6x+VpaRxpLJg0Zd9/9xRJOBMGmwAxo8/xyvGuAj85sxLJL6fA==\",\n payer=Person(\n first_name=\"Test\",\n last_name=\"Test\",\n middle_name=\"Test\",\n birth=date(1998, 1, 16),\n address=\"12A, 123\",\n street=\"Test Avenue\",\n city=\"LosTestels, City of Test Angels\",\n country=\"Testland\",\n phone=\"+1 111 11 11\",\n post_code=\"101011010\"\n )\n )\n\n await client.disconnect()\n```\n# AiohttpDispatcher Basic Usage Example\n```\nfrom aiocloudpayments import AiohttpDispatcher, Result\nfrom aiocloudpayments.types import PayNotification, CancelNotification, CheckNotification\n\n\nCERT_FILE = \"cert.pem\"\nCERT_FILE = \"pkey.pem\"\n\n\ndef main():\n dp = AiohttpDispatcher()\n\n # router is not needed here, but I am just showing the logic\n router = Router()\n\n # register with router\n @router.cancel(lambda n: 5 > n.amount > 1)\n async def foo(notification: CancelNotification):\n print(f\"{notification=}\")\n # return {\"result\": 0}\n return Result.OK\n\n # register with router\n @router.pay(lambda n: n.amount <= 1)\n async def foo(notification: PayNotification):\n print(f\"{notification.amount=}\")\n # return {\"result\": 0}\n return Result.OK\n \n # register with router\n @router.check()\n async def foo(notification: CheckNotification):\n print(f\"{notification.amount=}\")\n # return {\"result\": 12}\n return Result.WRONG_AMOUNT\n\n # register with dp\n @dp.cancel(lambda n: n.amount > 5)\n async def foo(notification: CancelNotification):\n print(f\"{notification.amount=}, > 5\")\n # if you don't return anything, Result.OK is assumed\n\n dp.include_router(router)\n\n ssl_context = SSLContext()\n ssl_context.load_cert_chain(CERT_FILE, KEY_FILE)\n\n dp.run_app(\n AioCpClient(PUBLIC_ID, API_SECRET),\n \"/test\",\n pay_path=\"/pay\",\n cancel_path=\"/cancel\",\n ssl_context=ssl_context,\n check_hmac=False # disable hmac check, only use in development environments\n )\n```\n\narchitecture inspired by [aiogram](https://github.com/aiogram/aiogram)",
"bugtrack_url": null,
"license": "",
"summary": "CloudPayments Python Async Library",
"version": "0.1.0",
"split_keywords": [
"cloudpayments",
"python",
"asyncio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "de23d9cae3467e314dad332dcb5687b324cacb60a385eb91120afe64c69b3cd7",
"md5": "be36cbf0567bedd3d02abccb444387ff",
"sha256": "dbe1f172539bc381ad8990dd2b50dbd9bcb2d1805e64ee5cfe63fc14c364a3cf"
},
"downloads": -1,
"filename": "aiocloudpayments-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "be36cbf0567bedd3d02abccb444387ff",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 40429,
"upload_time": "2023-04-05T08:04:22",
"upload_time_iso_8601": "2023-04-05T08:04:22.132539Z",
"url": "https://files.pythonhosted.org/packages/de/23/d9cae3467e314dad332dcb5687b324cacb60a385eb91120afe64c69b3cd7/aiocloudpayments-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "43ff5b20fa45a94c2799a35dbf61eadbd1c5b9f43f77eceba389ffa798bc4b46",
"md5": "5e39f6c32c599c604789f79d4438eccf",
"sha256": "aed78ac87e64f8c5d99de58740ce38d988da59e33843aae3c7ff4acaa6027c40"
},
"downloads": -1,
"filename": "aiocloudpayments-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "5e39f6c32c599c604789f79d4438eccf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 17022,
"upload_time": "2023-04-05T08:04:23",
"upload_time_iso_8601": "2023-04-05T08:04:23.475036Z",
"url": "https://files.pythonhosted.org/packages/43/ff/5b20fa45a94c2799a35dbf61eadbd1c5b9f43f77eceba389ffa798bc4b46/aiocloudpayments-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-05 08:04:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "drforse",
"github_project": "aiocloudpayments",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aiocloudpayments"
}