Skip to content
Snippets Groups Projects

Implement payment backends and interaction

Merged Nik | Klampfradler requested to merge payment-backends into master
3 files
+ 3
2
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 51
1
 
from django.apps import apps
 
from aleksis.core.util.apps import AppConfig
from aleksis.core.util.apps import AppConfig
 
from aleksis.core.util.core_helpers import get_site_preferences
class DefaultConfig(AppConfig):
class DefaultConfig(AppConfig):
@@ -10,4 +13,51 @@ class DefaultConfig(AppConfig):
@@ -10,4 +13,51 @@ class DefaultConfig(AppConfig):
"Repository": "https://edugit.org/AlekSIS/onboarding//AlekSIS-App-Tezor",
"Repository": "https://edugit.org/AlekSIS/onboarding//AlekSIS-App-Tezor",
}
}
licence = "EUPL-1.2+"
licence = "EUPL-1.2+"
copyright_info = (([2022], "Dominik George", "dominik.george@teckids.org"),)
copyright_info = (([2022], "Dominik George", "dominik.george@teckids.org"), ([2022], "Tom Teichler", "tom.teichler@teckids.org"),)
 
 
def ready(self):
 
from django.conf import settings # noqa
 
settings.PAYMENT_MODEL = "tezor.Invoice"
 
settings.PAYMENT_VARIANTS = {
 
"dummy": ("payments.dummy.DummyProvider", {})
 
}
 
 
for app_config in apps.app_configs.values():
 
if hasattr(app_config, "get_payment_variants"):
 
variants = app_config.get_payment_variants()
 
for name, config in variants.items():
 
if name not in settings.PAYMENT_VARIANTS:
 
settings.PAYMENT_VARIANTS[name] = config
 
 
def get_payment_variants(self):
 
prefs = get_site_preferences()
 
variants = {}
 
 
if prefs["payments__sofort_api_id"]:
 
variants["sofort"] = ("payments.sofort.SofortProvider", {
 
"id": prefs["payments__sofort_api_id"],
 
"key": prefs["payments__sofort_api_key"],
 
"project_id": prefs["payments__sofort_project_id"],
 
"endpoint": "https://api.sofort.com/api/xml",
 
})
 
 
if prefs["payments__paypal_client_id"]:
 
variants["paypal"] = ("payments.paypal.PaypalProvider", {
 
"client_id": prefs["payments__paypal_client_id"],
 
"secret": prefs["payments__paypal_secret"],
 
"capture": not prefs["payments__paypal_capture"],
 
"endpoint": "https://api.paypal.com",
 
})
 
 
if prefs["payments__pledge_enabled"]:
 
variants["pledge"] = ("djp_sepa.providers.PaymentPledgeProvider", {
 
})
 
 
 
if prefs["payments__sdd_creditor_identifier"]:
 
variants["sdd"] = ("djp_sepa.providers.DirectDebitProvider", {
 
"creditor": prefs["payments__sdd_creditor"],
 
"creditor_identifier": prefs["payments__sdd_creditor_identifier"],
 
})
 
 
return variants
Loading