From 31fff46f7c4f0916315ac084295ba92b15b8c0a5 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 28 Jun 2022 17:55:02 +0200 Subject: [PATCH] lingo: list all backend but keep custom labels (#66737) --- combo/apps/lingo/models.py | 44 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 7e469d2d..0d36e3dd 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -78,20 +78,36 @@ class UnknownPaymentException(LingoException): EXPIRED = 9999 -SERVICES = [ - (eopayment.DUMMY, _('Dummy (for tests)')), - (eopayment.SYSTEMPAY, 'systempay (Banque Populaire)'), - (eopayment.SIPS, 'SIPS (Atos, France)'), - (eopayment.SIPS2, _('SIPS (Atos, other countries)')), - (eopayment.OGONE, _('Ingenico (formerly Ogone)')), - (eopayment.PAYBOX, 'Paybox'), - (eopayment.PAYZEN, 'PayZen'), - (eopayment.TIPI, 'PayFiP/TIPI Régie'), - (eopayment.PAYFIP_WS, 'PayFiP Régie Web-Service'), - (eopayment.KEYWARE, 'Keyware'), - (eopayment.MOLLIE, 'Mollie'), - (eopayment.SAGA, 'Saga/PayFiP Régie (Futur System)'), -] +def _make_services(): + EOPAYMENT_BACKEND_NAMES = [ + ('DUMMY', _('Dummy (for tests)')), + ('SYSTEMPAY', 'systempay (Banque Populaire)'), + ('SIPS2', _('SIPS (Atos, other countries)')), + ('OGONE', _('Ingenico (formerly Ogone)')), + ('PAYBOX', 'Paybox'), + ('PAYZEN', 'PayZen'), + ('TIPI', 'PayFiP/TIPI Régie'), + ('PAYFIP_WS', 'PayFiP Régie Web-Service'), + ('KEYWARE', 'Keyware'), + ('MOLLIE', 'Mollie'), + ('SAGA', 'Saga/PayFiP Régie (Futur System)'), + ] + kind2name = {} + for key, name in EOPAYMENT_BACKEND_NAMES: + try: + kind = getattr(eopayment, key) + except AttributeError: + continue + kind2name[kind] = name + services = [] + for key, backend in eopayment.get_backends(): + try: + services.append((key, kind2name.get(kind) or backend.description['caption'])) + except (KeyError, AttributeError): + pass + + +SERVICES = _make_services() def eopayment_response_to_extra_info(response, **kwargs): -- 2.35.1