Controller for invoice checks if an invoice already exists to avoid wiping paid ones
This commit is contained in:
parent
dfdcb78fff
commit
8e2ea64b6b
3 changed files with 22 additions and 13 deletions
|
|
@ -19,6 +19,8 @@ from core.errors.exceptions import *
|
||||||
from core.errors.logger import logger
|
from core.errors.logger import logger
|
||||||
from core.controllers.tickets.TicketSyncController import sync_ticket_prices
|
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
|
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")
|
invoice_data_object.add_error_code("already_exists")
|
||||||
return invoice_data_object
|
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]
|
rejected_choices = [None, "", False]
|
||||||
|
|
||||||
if how_many_profiles in rejected_choices:
|
if how_many_profiles in rejected_choices:
|
||||||
|
|
@ -67,18 +75,6 @@ def initiate_payment(
|
||||||
invoice_data_object.add_error_code("no_keyplan")
|
invoice_data_object.add_error_code("no_keyplan")
|
||||||
return invoice_data_object
|
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:
|
# get & save the public key:
|
||||||
public_key_results = get_pub_key(which_key, connection_observer, "local")
|
public_key_results = get_pub_key(which_key, connection_observer, "local")
|
||||||
|
|
||||||
|
|
|
||||||
13
core/services/payment_phase/do_we_have_billing_id.py
Normal file
13
core/services/payment_phase/do_we_have_billing_id.py
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "sp-hydra-veil-core"
|
name = "sp-hydra-veil-core"
|
||||||
version = "2.3.2"
|
version = "2.3.4"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Simplified Privacy" },
|
{ name = "Simplified Privacy" },
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue