Use and connection with an existing billing code is now stable.

This commit is contained in:
SimplifiedPrivacy 2026-10-22 21:31:41 -04:00
parent 38535aee1c
commit 4273baebc2
4 changed files with 67 additions and 32 deletions

View file

@ -5,6 +5,7 @@ from core.services.profiles.profile_connections import enable_profile #, disable
from core.controllers.ProfileController import ProfileController
from core.models.Configuration import Configuration, ConnectionChoice
from core.services.subscriptions.subscriptions_by_protocol import get_profile_subscription, start_new_payment_cycle, wipe_subscription, evaluate_repeat_cycle
from core.services.payment_phase.pre_existing import check_then_save_billing_code
from core.utils.check_if_time_lapsed import check_if_time_lapsed
from core.models.enum_models import PaymentCategory
from core.utils.type_checker import type_checker
@ -223,3 +224,18 @@ def connect_profile(profile_id: int, ui_caller: Callable) -> Result:
def connect_with_billing_code(profile_id: int, billing_code: str) -> Result:
"""Apply a pre-existing billing code to a profile"""
print(f"billing_code is {billing_code}")
paid_result = check_then_save_billing_code(
profile_id=profile_id,
billing_code=billing_code,
connection_observer=connection_observer
)
if not paid_result.valid:
return paid_result
return literally_connect(profile_id=profile_id)

View file

@ -77,6 +77,12 @@ def reset_individual_billing_cycle() -> Result:
# return wiped_result
@type_checker
def connect_with_subscription_already(profile_id: int, billing_code: str, ui_caller: Callable) -> Result:
logger.info(f"Using a pre-existing billing code for profile {str(profile_id)}")
@type_checker
def start_individual_payment(profile_id: int, ui_caller: Callable) -> Result:
logger.info(f"Attempting to start individual billing state for profile {str(profile_id)}")

View file

@ -8,18 +8,20 @@ from PyQt6.QtGui import QIcon, QPixmap
from PyQt6.QtCore import Qt
from PyQt6 import QtCore
from core.models.enum_models import PaymentCategory
# from core.services.payment_phase.ticket_config_tools import do_we_have_billing_id
# core
# from core.models.enum_models import PaymentCategory
from core.services.prepare_tickets.ticket_tracker import delete_ticket_data
from core.models.Result import Result, ResultError
from core.models.Result import Result
# from core.services.payment_phase.ticket_config_tools import do_we_have_billing_id
# gui
from gui.v2.infrastructure.take_plumbing_action import take_action
from gui.v2.ui.pages.Page import Page
from gui.v2.ui.popups.message_box import style_message_box, mark_confirm_button
from gui.v2.actions.menu_tasks import enable_profile
from gui.v2.actions.menu_coordinator import connect_with_billing_code
from gui.v2.actions.payment_actions import start_individual_payment
from gui.v2.actions.ticket_actions import start_ticket, fetch_ticket_invoice
from gui.v2.ui.styles.css.id_page_style import COLUMN_BUTTON_CSS
HOW_MANY_PROFILES_DEFAULT = 6
@ -49,20 +51,30 @@ class IdPage(Page):
pattern = r'^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$'
if re.match(pattern, text):
self.update_status.update_status('Enabling profile in progress...')
profile_data = {
'id': int(self.update_status.current_profile_id),
'billing_code': str(text)
}
menu_page = self.find_menu_page()
if menu_page:
self.profile_enable_worker = enable_profile(
profile_data, menu_page.handle_task_result, allow_uninstalled_tor=True,
)
else:
billing_code = str(text)
if not billing_code:
self.update_status.update_status(
'Incorrect format for the billing code')
# profile id:
profile_id = int(self.update_status.current_profile_id)
menu_page = self.custom_window.navigator.get_cached("menu")
if not menu_page:
return
# menu page recieves result:
take_action(
action=connect_with_billing_code,
ui_caller=menu_page.post_connect,
profile_id=profile_id,
billing_code=billing_code
)
# navigate to the main menu to see/recieve result:
self.custom_window.navigator.navigate("menu")
def find_menu_page(self):
return self.custom_window.navigator.get_cached("menu")
@ -74,18 +86,7 @@ class IdPage(Page):
self.button_go.clicked.connect(self.go_selected)
column_title_style = "color: #00ffff; font-size: 18px; font-weight: bold;"
column_button_style = """
QPushButton {
background-color: #000000;
color: #00ffff;
border: 2px solid #00ffff;
border-radius: 10px;
font-size: 15px;
font-weight: bold;
padding: 10px;
}
QPushButton:hover { background-color: #003333; }
"""
column_button_style = COLUMN_BUTTON_CSS
column_desc_style = "color: #888888; font-size: 12px; font-style: italic;"
self.single_title = QLabel("Single Profile", self)
@ -115,7 +116,7 @@ class IdPage(Page):
self.multiple_button.clicked.connect(self.go_multiple_profiles)
self.multiple_desc = QLabel(
f"Buy a bundle of {HOW_MANY_PROFILES_DEFAULT} tickets at once, which are cryptographically seperated from each other.", self)
f"Buy a bundle of {HOW_MANY_PROFILES_DEFAULT} tickets at once, which are cryptographically separated from each other.", self)
self.multiple_desc.setGeometry(285, 335, 240, 80)
self.multiple_desc.setStyleSheet(column_desc_style)
self.multiple_desc.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
@ -173,9 +174,6 @@ class IdPage(Page):
return
if result.valid:
# billing_data = result.data
# billing_code = billing_data.billing_code
# print(f"billing_code is {billing_code}")
self.custom_window.navigator.navigate("duration_selection")
else:
if result.message:
@ -286,3 +284,4 @@ class IdPage(Page):
def reverse(self):
self.custom_window.navigator.navigate("menu")

View file

@ -0,0 +1,14 @@
COLUMN_BUTTON_CSS = """
QPushButton {
background-color: #000000;
color: #00ffff;
border: 2px solid #00ffff;
border-radius: 10px;
font-size: 15px;
font-weight: bold;
padding: 10px;
}
QPushButton:hover { background-color: #003333; }
"""