From 8e2ea64b6be96585598e708dc16e1c053d5cc882 Mon Sep 17 00:00:00 2001 From: SimplifiedPrivacy Date: Fri, 22 May 2026 21:10:38 -0400 Subject: [PATCH] Controller for invoice checks if an invoice already exists to avoid wiping paid ones --- .../tickets/TicketPayController.py | 20 ++++++++----------- .../payment_phase/do_we_have_billing_id.py | 13 ++++++++++++ pyproject.toml | 2 +- 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 core/services/payment_phase/do_we_have_billing_id.py diff --git a/core/controllers/tickets/TicketPayController.py b/core/controllers/tickets/TicketPayController.py index c3123a0..6c6b78f 100644 --- a/core/controllers/tickets/TicketPayController.py +++ b/core/controllers/tickets/TicketPayController.py @@ -19,6 +19,8 @@ from core.errors.exceptions import * from core.errors.logger import logger from core.controllers.tickets.TicketSyncController import sync_ticket_prices +from core.services.payment_phase.do_we_have_billing_id import do_we_have_billing_id + """ Inputs: Which plan (key), which crypto, and how many profiles @@ -47,6 +49,12 @@ def initiate_payment( invoice_data_object.add_error_code("already_exists") return invoice_data_object + billing_id = do_we_have_billing_id() + if billing_id: + invoice_data_object.add_error_code("billing_code_exists") + invoice_data_object.temp_billing_code = billing_id + return invoice_data_object + rejected_choices = [None, "", False] if how_many_profiles in rejected_choices: @@ -67,18 +75,6 @@ def initiate_payment( invoice_data_object.add_error_code("no_keyplan") return invoice_data_object - # confirm the key choice is among the choices from their sync file, - # and if not, then sync again, and try the results from that new file, - # is_valid_key = confirm_its_a_valid_key_choice(which_key, ticket_observer) - # if not is_valid_key: - # sync_results = sync_ticket_prices(ticket_observer, connection_observer) - # second_try_to_match = confirm_its_a_valid_key_choice( - # which_key, ticket_observer - # ) - # if not second_try_to_match: - # invoice_data_object.add_error_code("invalid_key") - # return invoice_data_object - # get & save the public key: public_key_results = get_pub_key(which_key, connection_observer, "local") diff --git a/core/services/payment_phase/do_we_have_billing_id.py b/core/services/payment_phase/do_we_have_billing_id.py new file mode 100644 index 0000000..68fb5ff --- /dev/null +++ b/core/services/payment_phase/do_we_have_billing_id.py @@ -0,0 +1,13 @@ +from core.utils.basic_operations.write_or_read_from_json import get_value_from_json_file +from core.Constants import Constants + +def do_we_have_billing_id() -> str | None: + try: + billing_folder = Constants.HV_TICKETING_CONFIG_HOME + filepath = f"{billing_folder}/billing_choices.json" + + billing_id = get_value_from_json_file(filepath, "temp_billing_code") + return billing_id + + except: + return None diff --git a/pyproject.toml b/pyproject.toml index 6812189..f89aa21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "sp-hydra-veil-core" -version = "2.3.2" +version = "2.3.4" authors = [ { name = "Simplified Privacy" }, ]