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

✨ Is922/add autorecharge functionality #5036

Conversation

matusdrobuliak66
Copy link
Contributor

@matusdrobuliak66 matusdrobuliak66 commented Nov 16, 2023

What do these changes do?

  • ✨ Introduce auto recharge functionality to the Payments service

NOTE: Introduced variable PAYMENTS_AUTORECHARGE_ENABLED to the Payments service. Based on this variable we pay via the payment gateway (pay_with_payment_method). It is a temporary solution so we can turn on/off this functionality.

  • Auto recharge concept: Payment service subscribes to RabbitMQ and listens on the wallet credits events. When the message comes, the Payment service starts to process the message, there are a series of steps to check whether the auto recharge should be done, if some of them are not met the auto recharge is not done.
    • Step 1: Check if wallet credits are below the threshold
    • Step 2: Check auto-recharge conditions (whether auto-recharge is enabled for the concrete wallet)
    • Step 3: Get Payment method
    • Step 4: Check spending limits (if the user set monthly limits)
    • Step 5: Check the last top-up time (Protective measure: As Payment service can in theory receive multiple messages, we need to make sure, that we do not initialize top-up multiple times. The current approach is that we allow just one top-up in 5 minutes, which should be reasonable for now)
    • Step 6: Perform auto-recharge

Related issue/s

How to test

Webserver:
pytest tests/unit/test_services_auto_recharge_listener.p

Payments service:
pytest tests/unit/with_dbs/03/products/test_products_rpc.py

Dev Checklist

DevOps Checklist

Added to payments service:

  • PAYMENTS_AUTORECHARGE_DEFAULT_MONTHLY_LIMIT=10000
  • PAYMENTS_AUTORECHARGE_DEFAULT_TOP_UP_AMOUNT=100.0
  • PAYMENTS_AUTORECHARGE_MIN_BALANCE_IN_CREDITS=100
  • PAYMENTS_AUTORECHARGE_ENABLED=1

@matusdrobuliak66 matusdrobuliak66 marked this pull request as ready for review November 16, 2023 19:51
@matusdrobuliak66 matusdrobuliak66 changed the title WIP: Is922/add autorecharge functionality ✨ Is922/add autorecharge functionality Nov 16, 2023
Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good. some initial comments. I will follow later ...

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! thanks

@matusdrobuliak66
Copy link
Contributor Author

@pcrespov I will wait for your approval

Copy link
Contributor

@YuryHrytsuk YuryHrytsuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gut gemacht. Thank you!

services/docker-compose.yml Show resolved Hide resolved
Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! 🎉

.env-devel Show resolved Hide resolved
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

codeclimate bot commented Nov 17, 2023

Code Climate has analyzed commit 1d46a7d and detected 0 issues on this pull request.

View more on Code Climate.

@matusdrobuliak66 matusdrobuliak66 enabled auto-merge (squash) November 17, 2023 14:34
@matusdrobuliak66 matusdrobuliak66 merged commit 8f207be into ITISFoundation:master Nov 17, 2023
55 checks passed
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.

5 participants