Page MenuHomePhabricator

Refactor PaymentMonitor
Open, Needs TriagePublic

Description

The application/models/PaymentMonitor.php file throws PHP notices when an unknown payment type is in the donation database.

Acceptance Criteria:

  • Change configuration to have a an additional thresholds value. thresholds should contain the minimum amount of donations for a payment type. A value of 0 disables the check for that payment type.
  • Change the code to check the thresholds
  • Change the code to change the notification when it encounters a donation with an unknown payment type.
  • Change the code to return English notifications instead of German ones
  • Code coverage for the new code should be >= 90%

Implementation Details:
application/models/PaymentMonitor.php is legacy code that should be split up:

  • Put the logic and coordination of finding the right value in the config file, querying the database, checking the payments and assembling a result into a use case class. The class should return a value object that contains the following information:
      • used configuration key
      • start and end of search interval
      • payment types and how many payments were found in the interval. Use the payment types from the Donation bounded context to avoid duplication.
      • Success/Failure ("failure" means one of the payment tapes did not reach its threshold)
      • unexpected payment types
    • Put the "Lock File for preventing message spam" logic into its own class.
    • Put the rendering of the mail text into a separate class that can process the value object from the use case
    • You may put the query for monitoring into the PaymentRepository or create a MonitoringReader interface + implementation for this.
    • The MonitorPaymentsCommand should use the use case and lock file class to generate the result. Some of its code should be moved into the other classes.
    • At the end of this task, application/models/PaymentMonitor.php should be deleted