No project description provided
Project description
keble-payment
keble-payment owns payment provider integration schemas and helpers for
Alipay, Stripe, and payment persistence used by Keble services.
Verified State
Checked on 2026-07-18 against pyproject.toml, keble_payment/, and tests
on fix/review2-money-scan-followup.
- Package:
keble-payment 2.4.3 - Python:
>=3.13,<3.14 - Critical deps:
keble-helpers,keble-db,keble-exceptions,python-alipay-sdk,stripe,httpx - Source roots:
alipay/,stripe/,paypal/,schemas/,crud/,main/ - Public exports: provider modules, payment schemas, and main client/helpers.
Runtime Contract
keble-payment 2.4.3writes payment, cancellation, deactivation, and coupon comparison instants from the shared aware UTC clock. Never persist a naive localdatetime.now()value: Mongo interprets naive values as UTC and can shift Asia/Shanghai payment times eight hours into the future, hiding a newly paid membership from enabled-period queries.keble-payment 2.4.1converts PayPal decimal strings through exactMoney.from_major_units/Money.to_major_unitsAPIs. Provider output uses each currency's audited scale (JPY 0, USD 2, BHD 3) instead of a hard-coded two-decimal formatter; unrepresentable precision fails before payout.- Alipay CNY transfer, WAP checkout, real notification, and admin-replay amounts
use one immutable
AlipayAmountschema. Provider values remain decimal text; no amount crosses binary float or truncatingint(value * 100)conversion. - Provider API details stay in provider modules. Backend checkout flows should consume package schemas and helpers rather than embedding provider payloads.
- Stripe stored models support optional
stripe_accountfor multi-account handling; preserve that field across schema changes. - Tests must not perform live payment requests in the local-full or portable-offline suites. Provider fixtures/assets belong under tests and must stay deterministic.
- Enabled provider live tests fail on provider request/schema errors; skips are only for missing live-test preconditions such as credentials or test price IDs.
- Reusable test settings and asset helpers live in
keble_payment.testing. - Payment tests resolve shared test env values through
keble_db.testing, so backend-level.envvalues can be reused without duplicating secrets in this package. OrderPricingPolicySnapshotis the immutable paid-order audit shape for service pricing policies. The snapshot records the selected policy/tag, original/base/deal prices, currency, validity window, and optional linked claim clue so backend callbacks can consume limited deals only after success.- Coupon histories snapshot currency, marketplace, and normalized tag/contributor attribution at payment success. Multiple tags split 10,000 basis points with deterministic largest-remainder allocation, so coupon/tag/contributor totals reconcile exactly.
CouponListQuery/CouponPageown server search, sort, and pagination. Coupon search usescoupon_search_text_idx; attribution review usesattribution_status_created_desc_idx; supported sort fields have explicit indexes.CouponPerformanceQueryis the only reporting contract. It uses closed-open time ranges, IANA timezones, DAY/MONTH/TOTAL buckets, and exact Decimal output grouped separately by currency and marketplace.- Historical attribution changes are explicit human-approved backfills through
abackfill_coupon_history_attribution; never infer current tags during reports. - Mongo and Redis integration tests must use per-test namespaces/databases and cleanup, not broad session-level deletes against shared databases.
- Executable tests stay under canonical layer roots:
tests/unit,tests/integration,tests/live,tests/contract,tests/evals, andtests/db_stack.
Testing
Detailed test-layer notes live in docs/testing.md.
Local-full development command:
uv sync --group test
RUN_INTEGRATION=1 RUN_REAL_DB=1 RUN_LOCAL_STACK=1 RUN_DB_STACK=1 \
uv run pytest -q -m "not live and not container"
Portable-offline command:
uv run pytest -q -m "not live and not slow and not eval and not local_stack and not db_stack and not container"
Real Mongo/Redis integration tests:
RUN_INTEGRATION=1 RUN_REAL_DB=1 RUN_LOCAL_STACK=1 uv run pytest -q -m integration
Eval selector:
uv run pytest -q -m eval
Syntax/type gate:
npx --yes pyright .
Latest proof on 2026-07-18:
- Local-full selector:
360 passed, 6 deselectedin8.51s. - Portable-offline selector:
291 passed, 75 deselectedin1.64s. - Unit selector:
291 passed, 75 deselectedin1.73s. - Eval selector:
366 deselectedin0.07s(no eval tests are registered). - Contract selector:
366 deselectedin0.07s(no contract tests are registered). - DB-stack selector:
366 deselected(no DB-stack-only tests are registered). - Integration selector:
69 passed, 297 deselectedin5.94s. - Stripe live canary:
1 passed, 3 skippedin3.65s; skipped cases lackedSTRIPE_TEST_PRICE_ID. - Alipay live canary:
2 skippedin1.46s; local Alipay key material was unavailable. npx --yes pyright .:0 errors.
Change Logs
Historical release notes and long AI change history live under logs/ when
archived.
Side Effect If Changes
- Backend checkout, membership upgrade, payment callback, and admin order routes depend on these provider schemas.
- Frontend purchase success tracking depends on backend payment state derived from this package.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keble_payment-2.4.3.tar.gz.
File metadata
- Download URL: keble_payment-2.4.3.tar.gz
- Upload date:
- Size: 429.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a994ab145b48c7bedba29d1b7c9702d2af258630df5b292b275b66321235749e
|
|
| MD5 |
f917faaf83bccabfd1a3018c37493c2e
|
|
| BLAKE2b-256 |
d03463a38990f458262374a95c3d3d51d7806324976c5d63f07dc7751e8e4e8e
|
File details
Details for the file keble_payment-2.4.3-py3-none-any.whl.
File metadata
- Download URL: keble_payment-2.4.3-py3-none-any.whl
- Upload date:
- Size: 202.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78b587464ca0dee781e19b303ee53cada723ba671bf0bc06804c991f06967a38
|
|
| MD5 |
26e3ab28acc6defebe5f47bdfa89d055
|
|
| BLAKE2b-256 |
f956ab6328a72ba3f82060b62b861b871c577822d8a70d51f5a42341caa82316
|