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

Payment review #67

Merged
merged 62 commits into from
Oct 27, 2023
Merged

Payment review #67

merged 62 commits into from
Oct 27, 2023

Commits on Oct 26, 2023

  1. adding payment application

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    814ce48 View commit details
    Browse the repository at this point in the history
  2. adding transaction model 1/n

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    4a16881 View commit details
    Browse the repository at this point in the history
  3. starting the payment view

    Leyknn authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    c72c47d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c94c670 View commit details
    Browse the repository at this point in the history
  5. correcting some bugs on the pay method

    Leyknn authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    9d46cd6 View commit details
    Browse the repository at this point in the history
  6. added product model, work on views

    Leyknn authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    5df59dc View commit details
    Browse the repository at this point in the history
  7. fixed tokens and init url

    Leyknn authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    f39c06d View commit details
    Browse the repository at this point in the history
  8. added static urls object

    Leyknn authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    57859cb View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    0d5ec99 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    e529063 View commit details
    Browse the repository at this point in the history
  11. trying to debug pay View

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    a76b5cf View commit details
    Browse the repository at this point in the history
  12. this commit adds:

    - logging debug capability
    - payment /pay route
    - handles helloasso intent
    UNSTABLE, far from working as indented
    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    5f1623b View commit details
    Browse the repository at this point in the history
  13. adding verbose_name

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    369bdd6 View commit details
    Browse the repository at this point in the history
  14. Fixing typo in tokens.py, correct amount computation, add ordering in

    transaction and remove pagination
    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    08b5869 View commit details
    Browse the repository at this point in the history
  15. ⬆️ Add admin models for payment, centralize amount

    - Centralize amount calculation in a function of the `Transaction` model
    - Add admin entries for Transaction and Product, and tweak the
      Transaction form so that it can compute the amount itself on save.
    
      NOTE: currently, if you save and keep editing, the amount will not
      change. See #69
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    6b1adce View commit details
    Browse the repository at this point in the history
  16. cleaning code

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    2bdb165 View commit details
    Browse the repository at this point in the history
  17. forget ()

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    b7b7e0b View commit details
    Browse the repository at this point in the history
  18. clarify doc

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    0cbdc3b View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    c0b51a4 View commit details
    Browse the repository at this point in the history
  20. 🥖translating

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    39e0731 View commit details
    Browse the repository at this point in the history
  21. Modify product M2M to use a through field

    Use a M2M through table that also stores the amount of each product used
    in a transaction, sorting out the issue of not being able to have
    duplicate entries for a product in a Transaction.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    eac5b84 View commit details
    Browse the repository at this point in the history
  22. Implement basic handling of payment return

    Implement the basic logic that verifies that a payment succeeded or
    failed on the main return path provided by HelloAsso.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    dcd79a5 View commit details
    Browse the repository at this point in the history
  23. 💰 Formatting of payment models file

    Change the ordering of headers and fix a typo in payment models (typo is
    in the payment status for a transaction)
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    9c6df4d View commit details
    Browse the repository at this point in the history
  24. 💸 Introduct more product fields

    Introduce:
    - Product category, that allows the system to know what category the
      product belongs to
    - Associated tournament, a potential foreign key to a tournament when
      the product is a tournament registration
    - Allow a product to be a null key in a ProductCount pair, and set it to
      null when it is deleted
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    696c5cb View commit details
    Browse the repository at this point in the history
  25. 💶 Introduce the product category hook system

    This commit introduces the product category hook system, which allows
    applications to create a class derived from an interface that implements
    callbacks for payment success and failure handling.
    
    A module can simply inherit the `PaymentHooks` class in one of its
    classes, and register it with the `PaymentCallbackSystem` class.
    
    An example is provided with the tournament class, which now implements a
    way to validate a pending registration with a payment.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    2170196 View commit details
    Browse the repository at this point in the history
  26. 🫰 Show new fields in the admin view of a product

    Show all fields introduced earlier in the product admin page
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    2c540c8 View commit details
    Browse the repository at this point in the history
  27. 🪙 Execute product callback hooks on payment

    In the payment API, when a payment is initiated, call the preparation
    hooks of a payment hook class. In the return view, call the accept
    hooks.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    2c31f3d View commit details
    Browse the repository at this point in the history
  28. 📒 Several tournament models modifications

    Models in the tournament field are modified thusly:
    - The whole file is formatted
    - A team is now always attached to a tournament, including when it is
      not validated. A boolean is added in `Team` to know if it has been
      validated
    - Both player and manager registrations now have a foreign key to their
      ticket, which is null until the payment of their ticket has succeeded
    - Admin view updated
    - Tests updated
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    35e0e9a View commit details
    Browse the repository at this point in the history
  29. 🔄 Move payment callbacks in Transaction

    Move payment callbacks in the transaction model, such that all of the
    iteration work is abstracted away from views. Also add the "id" field of
    a product to be shown in the admin view.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    0b724a3 View commit details
    Browse the repository at this point in the history
  30. 🌐 Use HELLOASSO_HOSTNAME to compute CSRF URL

    Use the environment variable given to us as `HELLOASSO_HOSTNAME` to
    compute the hostname used for helloasso in our CSRF trusted origins.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    03e83b4 View commit details
    Browse the repository at this point in the history
  31. 📜 Set root logger level based on DEBUG status

    If the environment variable indicating debug is set, the root logger is
    set to "DEBUG" levels of verbosity. Otherwise, it's set to "INFO".
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    2ea997c View commit details
    Browse the repository at this point in the history
  32. 🎟️ Refactor and document the HA OAuth2 token class

    Refactor and document the helloasso oauth2 token retrieval class,
    renaming it in the process from Tokens to Token (singular).
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    8929620 View commit details
    Browse the repository at this point in the history
  33. FIX: default to localhost for helloasso hostname

    Otherwise the CI cannot work
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    6bf2727 View commit details
    Browse the repository at this point in the history
  34. Creating associated products

    This commit makes the final connection between Tournament object and
    Product object by creating on save() the Products associated to the
    Tournament
    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    6d7781c View commit details
    Browse the repository at this point in the history
  35. Writing test and fixing broken test

    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    42e2a16 View commit details
    Browse the repository at this point in the history
  36. Use the is_announced field (#81)

    * Use the is_announced field
    If this field is set to false, the /tournament/tournament/<id>/full
    returns only the requested id. This allows the creation of tournaments
    before the announcement date.
    
    * adding is_announced in the list display
    ShiroUsagi-san authored and Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    bbc7eb5 View commit details
    Browse the repository at this point in the history
  37. 🎟️ Link a ticket with a tournament

    Add a `tournament` field to a Ticket that lets us know what tournament
    it is linked to.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    6e51076 View commit details
    Browse the repository at this point in the history
  38. 💰 Add cashprizes to the Tournament fields

    Use an ArrayField, which is Postgresql specific, to store a list of
    Decimal fields that have a minimal value of 0.
    
    Also adds tests, and is needed for #49.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    21972a7 View commit details
    Browse the repository at this point in the history
  39. 📅 Add product and tournament expiry/origin times

    Add fields to a Product and a Tournament that reflect the starting
    moment at which they can be bought/you can register, and the time limit
    to do so.
    
    Also add foreign keys to a tournament to store the products it creates,
    so as to not created them multiple times. These products are updated
    whenever their Tournament gets changed, but not the other way back (that
    will be done later).
    
    The API also enforces time constraints, as well as whether or not a
    tournament is announced.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    803f01b View commit details
    Browse the repository at this point in the history
  40. ❌ Do not reuse args/kwargs in second save

    Do not reuse the same args and kwargs used to create the first instance
    of a Tournament in a second call so as to not try and re-insert the same
    object with the same primary key a second time.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    d8cd512 View commit details
    Browse the repository at this point in the history
  41. 🌍 Translate tiem check validation errors

    Translate the strings used for validation errors introduced in the
    second to last commit, c357aaf.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    c4f0331 View commit details
    Browse the repository at this point in the history
  42. 🏆 Add a method to compute the validity of a Team

    Add a method that computes whether or not a team can be considered valid
    at any given point, based on quotas of people who paid.
    
    For now, the parameter `n` used is the number of people who joined the
    team. Very soon, it will be changed by the number of slots in a team
    (which is tournament dependent).
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    dee6811 View commit details
    Browse the repository at this point in the history
  43. 🛑 Add django admin action to refund a transaction

    Add a Django admin action that triggers a refund of a transaction.
    Consequently, add a hook to the payment callback class that performs
    post-refund actions. For tournament, this post-refund hook finds any
    registration paid linked to the tournament and user in question,
    destroys it, and cancels associated tickets.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    ddd7423 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    644d6e8 View commit details
    Browse the repository at this point in the history
  45. Formatting and proper errors

    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    447e2b8 View commit details
    Browse the repository at this point in the history
  46. Improve Token class, add refresh on demand

    - Actually use the singleton object
    - Implement an expiration date
    - Check the expiration date when we get the token, refreshing it if need
      be
    - Add timeout parameters to the request calls, and propagate/log on
      errors if need be
    - Refactor some code
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    7c24b9e View commit details
    Browse the repository at this point in the history
  47. Clean up HA vars: stop reading env all day long

    Transform all HelloAsso variables into constants in the settings of the
    whole project.
    
    Also adds organization slug, and normalizes variable names.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    53a4f7e View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    2e0f90e View commit details
    Browse the repository at this point in the history
  49. Foundations of the notification system

    So far, it does nothing
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    07a7ea2 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    2539fa3 View commit details
    Browse the repository at this point in the history
  51. Fix tests and data leak in event deref route

    - Fix tests (I hate timezones)
    - Fix a leak of data that resulted in all tournament information being
      visible in the `event/<id>/tournaments/` dereferencement route, which
      did not take into account the `is_announced` key
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    4c4ac80 View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    ba5ff57 View commit details
    Browse the repository at this point in the history
  53. Refactor tournament payment hooks, add prepare

    - Fix ticket creation missing a mandatory key (tournament)
    - Fix bug where despite buying a player ticket, you could end up
      validating a manager one
    - Change fetch_registration method to determine your type of
      registration from your product, not from the fact that a registration
      is available
    - Introduct the preparation hook to detect if a single registration of
      the correct type is ready to be paid before payment is initiated
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    e58831e View commit details
    Browse the repository at this point in the history
  54. Payment admin: add Payment admin view

    Similar to Transactions, Payments cannot be deleted or manipulated, only
    viewed.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    8b3de70 View commit details
    Browse the repository at this point in the history
  55. Introduct order_id into Transaction

    Register the order_id (which is not the same as the intent id) into a
    Transaction, also displaying it in the admin view
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    76c8bfb View commit details
    Browse the repository at this point in the history
  56. Fix initial HA token retrieval using wrong grant

    The grant_type used to retrieve an OAuth token is different whether or
    not you are using client credentials (first login), or refreshing a
    token (refreshes). Without this patch, initial obtention of tokens is
    impossible.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    419b296 View commit details
    Browse the repository at this point in the history
  57. Implement proper use of prepare_hook + redirect

    Properly redirect the user… by not redirecting them. Redirects in Django
    only really work within the same domain, so instead we return the URL in
    a JSON reply, and will let the frontend do its magic.
    
    At the same time, we move the call to the prepare_hook after creation of
    the transaction object (for validation purposes), but before the intent
    creation on HelloAsso's side. If the hooks return `False`, then
    something is wrong, and we cannot proceed with payment, needing instead
    to delete the Transaction.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    ad23c69 View commit details
    Browse the repository at this point in the history
  58. Implement the notification system + refund

    Implement the notification channel that receives and handles two kinds
    of messages:
    - Order: those messages give us the layout of payments (typically here
      for us only one of them) and order number associated with our
      transaction, which we can add and update into the database
    - Payment: those messages let us known the status of a payment, which
      can trigger validation or invalidation of a transaction (invalidation
      has not been tested yet, as notifications only come when a payment
      succeeds)
    
    Properly implement refunding by iterating over defined payments for a
    transaction and refunding them individually. Note that that part has not
    been entirely tested yet, because our credentials do not allow us to
    refund yet.
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    e0120a0 View commit details
    Browse the repository at this point in the history
  59. Properly handle unknown transactions notified

    Properly handle the fact that we could get notified about a transaction
    we do not know
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    41645af View commit details
    Browse the repository at this point in the history
  60. Remove refund action, normalize state methods

    - Remove the transaction refund admin action, mostly by commenting it
      out
    - Normalize state methods, so that if you want to change the state of an
      action, you do not have to run the hooks yourself or touch the
      transaction or verify states or anything (it also logs stuff)
    - Add Refunded as a supported Payment message type
    Lymkwi committed Oct 26, 2023
    Configuration menu
    Copy the full SHA
    3de3597 View commit details
    Browse the repository at this point in the history
  61. Configuration menu
    Copy the full SHA
    f777427 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2023

  1. Fix typo in tourney serializer RO fields

    We had `manager_price_onsite` in there twice.
    Lymkwi committed Oct 27, 2023
    Configuration menu
    Copy the full SHA
    9a45e6e View commit details
    Browse the repository at this point in the history