Skip to content

Commit

Permalink
🔧 #107: Support tips (even if not recommended)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffo99 committed May 13, 2021
1 parent 94f8b91 commit 2262dbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions config/template_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ 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]
# Suggested tip amounts in minimum currency units
# Maximum 4 values; if the array is empty, the feature is disabled
# Enabling this feature is not recommended, as it may be confusing for the users
# tip_presets = [100, 250, 500, 1000] # €1.00 €2.50 €5.00 €10.00
tip_presets = []
# Maximum tip amount in minimum currency units
# max_tip_amount = 1000
max_tip_amount = 0
# 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
Expand Down
7 changes: 5 additions & 2 deletions worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,10 @@ def __make_payment(self, amount):
need_name=self.cfg["Payments"]["CreditCard"]["name_required"],
need_email=self.cfg["Payments"]["CreditCard"]["email_required"],
need_phone_number=self.cfg["Payments"]["CreditCard"]["phone_required"],
reply_markup=inline_keyboard)
reply_markup=inline_keyboard,
max_tip_amount=self.cfg["Payments"]["CreditCard"]["max_tip_amount"],
suggested_tip_amounts=self.cfg["Payments"]["CreditCard"]["tip_presets"],
)
# Wait for the precheckout query
precheckoutquery = self.__wait_for_precheckoutquery(cancellable=True)
# Check if the user has cancelled the invoice
Expand All @@ -859,7 +862,7 @@ def __make_payment(self, amount):
successfulpayment = self.__wait_for_successfulpayment(cancellable=False)
# Create a new database transaction
transaction = db.Transaction(user=self.user,
value=int(successfulpayment.total_amount) - fee,
value=int(amount),
provider="Credit Card",
telegram_charge_id=successfulpayment.telegram_payment_charge_id,
provider_charge_id=successfulpayment.provider_payment_charge_id)
Expand Down

0 comments on commit 2262dbb

Please sign in to comment.