mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-21 21:44:19 +00:00
Made a few changes
This commit is contained in:
parent
c9561f0da5
commit
9df1203b3e
1 changed files with 10 additions and 7 deletions
15
worker.py
15
worker.py
|
@ -581,7 +581,8 @@ class ChatWorker(threading.Thread):
|
|||
self.bot.send_message(self.chat.id, strings.conversation_payment_method,
|
||||
reply_markup=telegram.ReplyKeyboardMarkup(keyboard, one_time_keyboard=True))
|
||||
# Wait for a reply from the user
|
||||
selection = self.__wait_for_specific_message([strings.menu_cash, strings.menu_credit_card, strings.menu_cancel], cancellable=True)
|
||||
selection = self.__wait_for_specific_message([strings.menu_cash, strings.menu_credit_card, strings.menu_cancel],
|
||||
cancellable=True)
|
||||
# If the user has selected the Cash option...
|
||||
if selection == strings.menu_cash:
|
||||
# Go to the pay with cash function
|
||||
|
@ -601,7 +602,7 @@ class ChatWorker(threading.Thread):
|
|||
# Create a keyboard to be sent later
|
||||
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)]);
|
||||
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
|
||||
|
@ -643,8 +644,10 @@ class ChatWorker(threading.Thread):
|
|||
# Create the price array
|
||||
prices = [telegram.LabeledPrice(label=strings.payment_invoice_label, amount=int(amount))]
|
||||
# If the user has to pay a fee when using the credit card, add it to the prices list
|
||||
prices.append(telegram.LabeledPrice(label=strings.payment_invoice_fee_label, amount=int(self.__get_total_fee(amount))))
|
||||
|
||||
fee = int(self.__get_total_fee(amount))
|
||||
if fee > 0:
|
||||
prices.append(telegram.LabeledPrice(label=strings.payment_invoice_fee_label,
|
||||
amount=fee))
|
||||
# Create the invoice keyboard
|
||||
inline_keyboard = telegram.InlineKeyboardMarkup([[telegram.InlineKeyboardButton(strings.menu_pay, pay=True)],
|
||||
[telegram.InlineKeyboardButton(strings.menu_cancel,
|
||||
|
@ -662,7 +665,7 @@ class ChatWorker(threading.Thread):
|
|||
need_email=configloader.config["Credit Card"]["email_required"] == "yes",
|
||||
need_phone_number=configloader.config["Credit Card"]["phone_required"] == "yes",
|
||||
reply_markup=inline_keyboard)
|
||||
|
||||
# Wait for the precheckout query
|
||||
precheckoutquery = self.__wait_for_precheckoutquery(cancellable=True)
|
||||
# Check if the user has cancelled the invoice
|
||||
if isinstance(precheckoutquery, CancelSignal):
|
||||
|
@ -674,7 +677,7 @@ class ChatWorker(threading.Thread):
|
|||
successfulpayment = self.__wait_for_successfulpayment()
|
||||
# Create a new database transaction
|
||||
transaction = db.Transaction(user=self.user,
|
||||
value=int(successfulpayment.total_amount - self.__get_total_fee(amount=amount)),
|
||||
value=int(successfulpayment.total_amount) - fee,
|
||||
provider="Credit Card",
|
||||
telegram_charge_id=successfulpayment.telegram_payment_charge_id,
|
||||
provider_charge_id=successfulpayment.provider_payment_charge_id)
|
||||
|
|
Loading…
Reference in a new issue