aiogram-stars 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aiogram_stars-0.1.0/.gitignore +17 -0
- aiogram_stars-0.1.0/CHANGELOG.md +53 -0
- aiogram_stars-0.1.0/LICENSE +21 -0
- aiogram_stars-0.1.0/PKG-INFO +724 -0
- aiogram_stars-0.1.0/README.md +677 -0
- aiogram_stars-0.1.0/README.ru.md +690 -0
- aiogram_stars-0.1.0/examples/shop_bot.py +176 -0
- aiogram_stars-0.1.0/pyproject.toml +103 -0
- aiogram_stars-0.1.0/src/aiogram_stars/__init__.py +33 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_callbacks.py +56 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_errors.py +28 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_models.py +103 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_outbox.py +221 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_payload.py +103 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_payments.py +645 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_policy.py +64 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_storage.py +108 -0
- aiogram_stars-0.1.0/src/aiogram_stars/_time.py +20 -0
- aiogram_stars-0.1.0/src/aiogram_stars/memory.py +176 -0
- aiogram_stars-0.1.0/src/aiogram_stars/py.typed +0 -0
- aiogram_stars-0.1.0/src/aiogram_stars/sqlalchemy.py +369 -0
- aiogram_stars-0.1.0/tests/__init__.py +0 -0
- aiogram_stars-0.1.0/tests/conftest.py +74 -0
- aiogram_stars-0.1.0/tests/helpers.py +94 -0
- aiogram_stars-0.1.0/tests/telegram.py +229 -0
- aiogram_stars-0.1.0/tests/test_concurrency.py +70 -0
- aiogram_stars-0.1.0/tests/test_errors.py +18 -0
- aiogram_stars-0.1.0/tests/test_example.py +98 -0
- aiogram_stars-0.1.0/tests/test_invoices.py +121 -0
- aiogram_stars-0.1.0/tests/test_lifecycle.py +359 -0
- aiogram_stars-0.1.0/tests/test_models.py +11 -0
- aiogram_stars-0.1.0/tests/test_packaging.py +46 -0
- aiogram_stars-0.1.0/tests/test_payload.py +135 -0
- aiogram_stars-0.1.0/tests/test_payments.py +350 -0
- aiogram_stars-0.1.0/tests/test_pre_checkout.py +310 -0
- aiogram_stars-0.1.0/tests/test_readme.py +72 -0
- aiogram_stars-0.1.0/tests/test_refunds.py +422 -0
- aiogram_stars-0.1.0/tests/test_storage.py +324 -0
- aiogram_stars-0.1.0/tests/test_subscriptions.py +45 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-10-17
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `StarsPayments`: one object that registers the pre-checkout and successful-payment
|
|
12
|
+
handlers for `XTR` on an aiogram `Router` or `Dispatcher`, ahead of the routers included
|
|
13
|
+
there, and starts and stops the refund outbox with the dispatcher, for polling and webhooks.
|
|
14
|
+
- Invoice helpers `send_invoice` and `create_invoice_link` (with `subscription_period`), and
|
|
15
|
+
`make_payload` for other invoice kinds. Payloads carry the order id and an HMAC-SHA256 tag
|
|
16
|
+
bound to the amount; `PayloadSigner` signs and verifies them, with `previous_secrets` for key
|
|
17
|
+
rotation.
|
|
18
|
+
- Pre-checkout: payloads not signed with the secret, or paid with another amount, are declined
|
|
19
|
+
before the `check` callback runs; `check` approves by returning nothing and declines with
|
|
20
|
+
`RejectPayment(reason)`, and any other return value or exception declines with
|
|
21
|
+
`checkout_error`; a check slower than `checkout_timeout` (8 s by default) is cancelled and the
|
|
22
|
+
query is declined before Telegram's 10-second deadline, also when the check is slow to stop.
|
|
23
|
+
- Successful payments are recorded once per `telegram_payment_charge_id`; `on_paid` runs once
|
|
24
|
+
per charge, also for redelivered updates and for several bot processes on one database.
|
|
25
|
+
`RejectPayment` from `on_paid` marks the payment rejected and queues a refund in the same
|
|
26
|
+
storage transaction; a payment whose payload does not verify is rejected and refunded without
|
|
27
|
+
calling `on_paid`. Shutdown waits up to `payment_lease` for the `on_paid` calls that are
|
|
28
|
+
running, since Telegram does not send their updates again. A payment left behind by a process
|
|
29
|
+
that died is handled again by a redelivered update once its lease (`payment_lease`) runs out.
|
|
30
|
+
- Refund outbox: refunds (compensating, and manual through `StarsPayments.refund`) are stored
|
|
31
|
+
first and sent by a background task with exponential backoff (`RefundPolicy`), at most one
|
|
32
|
+
refund per charge, claimed with a lease so two workers never send it at the same time.
|
|
33
|
+
`CHARGE_ALREADY_REFUNDED` counts as done; flood control (`retry_after`) pauses every refund,
|
|
34
|
+
not only the one that hit it; `on_refunded` and `on_refund_failed` callbacks;
|
|
35
|
+
`send_due_refunds` makes one attempt at every due refund from the calling task.
|
|
36
|
+
- Callbacks get the handler data they name, as aiogram handlers do; `on_paid` also gets the
|
|
37
|
+
`message`, and the outbox callbacks get `bot` and the dispatcher's data.
|
|
38
|
+
- `get_payment` and `get_refund` read the stored records; `Payment`, `Refund`, `PaymentStatus`
|
|
39
|
+
and `RefundStatus` describe them, and the statuses read as their string value.
|
|
40
|
+
- Subscriptions: `Payment.is_recurring`, `is_first_recurring` and `subscription_expires_at`,
|
|
41
|
+
and `cancel_subscription` (`editUserStarSubscription`).
|
|
42
|
+
- Storage: the `Storage` protocol, `MemoryStorage`, and `aiogram_stars.sqlalchemy.SqlAlchemyStorage`
|
|
43
|
+
for SQLite and PostgreSQL (SQLAlchemy 2 async). The extras `sqlite` and `postgres` install
|
|
44
|
+
SQLAlchemy with the driver; `sqlalchemy` installs SQLAlchemy alone.
|
|
45
|
+
- Settings that cannot work (`checkout_timeout` outside (0, 10), a blank `checkout_error`, a
|
|
46
|
+
`RefundPolicy` lease no longer than its request timeout, and others) raise `ValueError` when
|
|
47
|
+
the object is created.
|
|
48
|
+
- Python 3.10 to 3.13 and aiogram 3.15 or later; the package ships `py.typed` and passes
|
|
49
|
+
`mypy --strict`.
|
|
50
|
+
- `examples/shop_bot.py`, a runnable bot with `/buy`, `/refund <charge_id>` and `/paysupport`.
|
|
51
|
+
- README in English and Russian; its quick start runs in the test suite.
|
|
52
|
+
|
|
53
|
+
[0.1.0]: https://github.com/sinnercode228/aiogram-stars/releases/tag/v0.1.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sinnercode228
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|