From 5be2f9e76282c133c02ee0d1d7085e1fa3f3bbcf Mon Sep 17 00:00:00 2001 From: Pavlo Zhuk Date: Sat, 4 Apr 2020 20:53:10 +0300 Subject: [PATCH] add configurable payment presets --- config/template_config.ini | 3 +++ worker.py | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/template_config.ini b/config/template_config.ini index cbe2381..149eca7 100644 --- a/config/template_config.ini +++ b/config/template_config.ini @@ -72,6 +72,9 @@ 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 + # Exception reporting settings [Error Reporting] diff --git a/worker.py b/worker.py index bc2fc85..c2716ea 100644 --- a/worker.py +++ b/worker.py @@ -593,11 +593,9 @@ 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 - keyboard = [[telegram.KeyboardButton(str(utils.Price("10.00")))], - [telegram.KeyboardButton(str(utils.Price("25.00")))], - [telegram.KeyboardButton(str(utils.Price("50.00")))], - [telegram.KeyboardButton(str(utils.Price("100.00")))], - [telegram.KeyboardButton(strings.menu_cancel)]] + presets = configloader.config["Appearance"]["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 cancelled = False # Loop used to continue asking if there's an error during the input @@ -630,7 +628,7 @@ class ChatWorker(threading.Thread): else: # Exit the function return - # Issue the invoice + # Issue the payment invoice self.__make_payment(amount=value) def __make_payment(self, amount):