mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-21 21:44:19 +00:00
Offer refill only if the credit_required is between the min_amount and max_amount range
This commit is contained in:
parent
279b8f1539
commit
788163458e
1 changed files with 4 additions and 2 deletions
|
@ -506,12 +506,14 @@ class ChatWorker(threading.Thread):
|
|||
self.session.add(order_item)
|
||||
# Ensure the user has enough credit to make the purchase
|
||||
credit_required = self.__get_cart_value(cart) - self.user.credit
|
||||
# Notify user In case of insufficient credit
|
||||
# Notify user in case of insufficient credit
|
||||
if credit_required > 0:
|
||||
self.bot.send_message(self.chat.id, strings.error_not_enough_credit)
|
||||
# Suggest payment for missing credit value if configuration allows refill
|
||||
if configloader.config["Credit Card"]["credit_card_token"] != "" \
|
||||
and configloader.config["Appearance"]["refill_on_checkout"] == 'yes':
|
||||
and configloader.config["Appearance"]["refill_on_checkout"] == 'yes' \
|
||||
and credit_required <= utils.Price(int(configloader.config["Credit Card"]["max_amount"])) \
|
||||
and credit_required >= utils.Price(int(configloader.config["Credit Card"]["min_amount"])):
|
||||
self.__make_payment(utils.Price(credit_required))
|
||||
# If afer requested payment credit is still insufficient (either payment failure or cancel)
|
||||
if self.user.credit < self.__get_cart_value(cart):
|
||||
|
|
Loading…
Reference in a new issue