Payment provider fee calculation

This commit is contained in:
Raphael Michel
2015-03-06 15:21:47 +01:00
parent 4390ee0b07
commit eca4964d98
2 changed files with 20 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
from decimal import Decimal
from pretix.base.settings import SettingsSandbox
@@ -13,6 +15,23 @@ class BasePaymentProvider:
def __str__(self):
return self.identifier
@property
def is_enabled(self):
"""
Returns, whether or whether not this payment provider is enabled.
By default, this is determined by the value of a setting.
"""
return self.settings.get('_enabled', as_type=bool)
def calculate_fee(self, price):
"""
Calculate the fee for this payment provider which will be added to
the final price if the price before fees (but after taxes) is 'price'.
"""
fee_abs = self.settings.get('_fee_abs', as_type=Decimal, default=0)
fee_percent = self.settings.get('_fee_percent', as_type=Decimal, default=0)
return price * fee_percent / 100 + fee_abs
@property
def verbose_name(self) -> str:
"""