mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Payment provider fee calculation
This commit is contained in:
@@ -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:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user