Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Implement unit tests and a model validator for the PaymentInfo pydantic model #1214

Closed
wants to merge 8 commits into from

Conversation

Sulai-maan
Copy link

@Sulai-maan Sulai-maan commented Mar 1, 2025

Description

I implemented a model validator that checks that the payment card has not expired. The payment card model previously only validated the character counts of the card number and cvc fields. Also, I replaced the now deprecated validator decorator with the field_validator decorator. Also,

Related Issue (Link to issue ticket)

#1218

Motivation and Context

We can now avoid callling the Stripe API with expired payment cards and save resources.

How Has This Been Tested?


Created and ran unit testing of the model using the pytest module.

Screenshots (if appropriate - Postman, etc):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • [x ] I have added tests to cover my changes.
  • All new and existing tests passed.

@samuelogboye
Copy link
Contributor

Please explain why this implementation is totally different from the approved issue

@Sulai-maan
Copy link
Author

I had spotted the issue while working on my approved issue - which required the PaymentInfo model. In hindsight, I should have created a different issue for it. Will do that now. Apologies.

@Sulai-maan Sulai-maan changed the title fix: add card expiry date validation and remove deprecated decorator for the PaymentInfo model fix: Implement unit tests and a model validator for the PaymentInfo pydantic model Mar 2, 2025
@Sulai-maan
Copy link
Author

@samuelogboye I have updated the linked issue for this PR but I can't seem to be able to reopen. Please take a look.

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.

2 participants