2015-05-04 14:19:58 +00:00
|
|
|
import logging
|
2014-09-05 14:27:30 +00:00
|
|
|
from dateutil import relativedelta
|
2015-10-02 11:08:23 +00:00
|
|
|
from functools import lru_cache
|
2014-07-30 12:55:33 +00:00
|
|
|
|
2014-11-24 14:39:41 +00:00
|
|
|
from orchestra import plugins
|
2014-09-16 15:01:02 +00:00
|
|
|
from orchestra.utils.python import import_class
|
|
|
|
|
|
|
|
from .. import settings
|
2014-07-30 12:55:33 +00:00
|
|
|
|
|
|
|
|
2015-05-04 14:19:58 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2014-07-30 12:55:33 +00:00
|
|
|
class PaymentMethod(plugins.Plugin):
|
|
|
|
label_field = 'label'
|
|
|
|
number_field = 'number'
|
|
|
|
process_credit = False
|
2014-09-05 14:27:30 +00:00
|
|
|
due_delta = relativedelta.relativedelta(months=1)
|
2015-03-23 15:36:51 +00:00
|
|
|
plugin_field = 'method'
|
2015-09-29 12:35:22 +00:00
|
|
|
state_help = {}
|
2014-07-30 12:55:33 +00:00
|
|
|
|
2014-09-16 15:01:02 +00:00
|
|
|
@classmethod
|
2015-10-02 11:08:23 +00:00
|
|
|
@lru_cache()
|
2014-09-16 15:01:02 +00:00
|
|
|
def get_plugins(cls):
|
|
|
|
plugins = []
|
|
|
|
for cls in settings.PAYMENTS_ENABLED_METHODS:
|
2015-05-04 14:19:58 +00:00
|
|
|
try:
|
|
|
|
plugins.append(import_class(cls))
|
|
|
|
except ImportError as exc:
|
2015-10-05 13:31:08 +00:00
|
|
|
logger.error('Error loading %s: %s' % (cls, exc))
|
2014-09-16 15:01:02 +00:00
|
|
|
return plugins
|
2014-07-30 12:55:33 +00:00
|
|
|
|
2015-03-11 16:32:33 +00:00
|
|
|
def get_label(self):
|
|
|
|
return self.instance.data[self.label_field]
|
2014-07-30 12:55:33 +00:00
|
|
|
|
2015-03-11 16:32:33 +00:00
|
|
|
def get_number(self):
|
|
|
|
return self.instance.data[self.number_field]
|
2014-09-05 14:27:30 +00:00
|
|
|
|
2015-03-11 16:32:33 +00:00
|
|
|
def get_bill_message(self):
|
2014-09-10 16:53:09 +00:00
|
|
|
return ''
|