From 9d6e21fb4ee22c9f45654d5d393a6a3265a0971e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 7 Apr 2020 02:02:07 +0200 Subject: [PATCH] Move the presets to the [Credit Card] section --- config/template_config.ini | 5 +++-- worker.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config/template_config.ini b/config/template_config.ini index edc234d..2b95dd1 100644 --- a/config/template_config.ini +++ b/config/template_config.ini @@ -53,6 +53,9 @@ credit_card_token = 123456789:YOUR_TOKEN_HERE_ min_amount = 1000 ; Maximum wallet payment accepted (in miniumum currency units, $1.00 = 100 units) max_amount = 10000 +; The preset selections that can be made when adding credit to the wallet with a credit card +; Presets are pipe-separated |, and should never be outside the bounds provided by the min_amount and max_amount options +payment_presets = 10.00 | 25.00 | 50.00 | 100.00 ; Make the user pay a extra fee when adding credit to the wallet with a credit card ; The formula for determining the total cost is: ; cost = added_funds + added_funds * fee_percentage / 100 + fee_fixed @@ -72,8 +75,6 @@ phone_required = yes ; Display the full order information to the customers instead of the shortened version ; The full order information includes the order number and the timestamp of the order placement full_order_info = no -; Payment presets would be suggested to the user as buttons, when making credit card transaction -payment_presets = 10.00,25.00,50.00,100.00 ; Allow balance refill during the order checkout in case of unsufficient balance refill_on_checkout = yes diff --git a/worker.py b/worker.py index bee1423..c4c6496 100644 --- a/worker.py +++ b/worker.py @@ -600,7 +600,7 @@ class ChatWorker(threading.Thread): def __add_credit_cc(self): """Add money to the wallet through a credit card payment.""" # Create a keyboard to be sent later - presets = configloader.config["Appearance"]["payment_presets"].split(',') + presets = list(map(lambda s: s.strip(" "), configloader.config["Credit Card"]["payment_presets"].split('|'))) keyboard = [[telegram.KeyboardButton(str(utils.Price(preset)))] for preset in presets] keyboard.append([telegram.KeyboardButton(strings.menu_cancel)]) # Boolean variable to check if the user has cancelled the action @@ -623,12 +623,14 @@ class ChatWorker(threading.Thread): if value > utils.Price(int(configloader.config["Credit Card"]["max_amount"])): self.bot.send_message(self.chat.id, strings.error_payment_amount_over_max.format( - max_amount=utils.Price(configloader.config["Payments"]["max_amount"]))) + max_amount=utils.Price(configloader.config["Credit Card"]["max_amount"])) + ) continue elif value < utils.Price(int(configloader.config["Credit Card"]["min_amount"])): self.bot.send_message(self.chat.id, strings.error_payment_amount_under_min.format( - min_amount=utils.Price(configloader.config["Payments"]["min_amount"]))) + min_amount=utils.Price(configloader.config["Credit Card"]["min_amount"])) + ) continue break # If the user cancelled the action...