Skip to content

Add Payment model with Decimal amounts and PaymentStatus. - #44

Closed
sainath5001 wants to merge 2 commits into
ShadeProtocol:mainfrom
sainath5001:feat/payment-model
Closed

Add Payment model with Decimal amounts and PaymentStatus.#44
sainath5001 wants to merge 2 commits into
ShadeProtocol:mainfrom
sainath5001:feat/payment-model

Conversation

@sainath5001

@sainath5001 sainath5001 commented Jul 21, 2026

Copy link
Copy Markdown

Description

Introduce ShadeObject base for from_dict / to_dict, add Payment and PaymentStatus (str, Enum for Python 3.10), validate amount > 0, declare pydantic in pyproject.toml, and cover the model with unit tests.

This adds the typed Payment API response model so monetary amounts use Decimal (not float) and status values are validated via enum.

Dependency: pydantic >= 2.0 (added to pyproject.toml; poetry.lock content-hash updated).

Fixes #37

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • pytest — full suite (146 passed)
  • tests/models/test_payment.pyfrom_dict, Decimal amount, PaymentStatus enum, invalid status errors, amount > 0
pytest tests/models/test_payment.py -v
pytest

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • Added support for representing payment records with statuses including pending, completed, cancelled, expired, and partially paid.
    • Payment details now include amount, currency, descriptions, transaction information, payment addresses, and timestamps.
    • Payment amounts must be greater than zero and preserve precise decimal values.
    • Payment data can be parsed from and serialized back to API-compatible formats.

Introduce ShadeObject base for from_dict/to_dict, add Payment and
PaymentStatus (str, Enum for Python 3.10), validate amount > 0, declare
pydantic in pyproject.toml, and cover the model with unit tests.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 848ae3a0-322b-4548-9932-b35fbfa88ea5

📥 Commits

Reviewing files that changed from the base of the PR and between 8298b2a and 7ad6db5.

📒 Files selected for processing (2)
  • pyproject.toml
  • src/shade/models/__init__.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

📝 Walkthrough

Walkthrough

Adds a Pydantic Payment model with lifecycle statuses, typed payment fields, positive amount validation, package exports, and parsing, validation, and serialization tests.

Changes

Payment models

Layer / File(s) Summary
Pydantic dependency and package exports
pyproject.toml, src/shade/models/__init__.py
Adds the Pydantic ^2.0 dependency and exports Payment and PaymentStatus from shade.models.
Payment resource contract
src/shade/models/payment.py
Defines PaymentStatus, the typed Payment model, optional payment fields, timestamps, and validation requiring a positive amount.
Payment parsing and validation coverage
tests/models/test_payment.py
Tests model construction, timestamp parsing, Decimal precision, status validation, optional fields, extra API fields, and round-trip serialization.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

Suggested reviewers: codebestia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding the Payment model with Decimal amounts and PaymentStatus.
Description check ✅ Passed The description includes the change summary, issue reference, motivation, dependency, testing details, change type, and completed checklist.
Linked Issues check ✅ Passed The changes implement the Payment model, required fields, Decimal amounts, PaymentStatus validation, positive amounts, and conversion tests required by issue #37.
Out of Scope Changes check ✅ Passed The dependency, exports, Payment model, validator, and tests directly support the Payment model objectives in issue #37.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codebestia

codebestia commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

GM @sainath5001
Please link to right issue in the issue description.
The wrong issue is linked.

@codebestia codebestia closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Payment model

2 participants