Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Tezor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Onboarding
AlekSIS-App-Tezor
Commits
8020b76a
Verified
Commit
8020b76a
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Implement configuration of payment backends
parent
6236389a
No related branches found
No related tags found
No related merge requests found
Pipeline
#58802
failed
3 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Stage: docker
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/tezor/apps.py
+39
-0
39 additions, 0 deletions
aleksis/apps/tezor/apps.py
aleksis/apps/tezor/preferences.py
+74
-0
74 additions, 0 deletions
aleksis/apps/tezor/preferences.py
with
113 additions
and
0 deletions
aleksis/apps/tezor/apps.py
+
39
−
0
View file @
8020b76a
from
django.apps
import
apps
from
aleksis.core.util.apps
import
AppConfig
from
aleksis.core.util.core_helpers
import
get_site_preferences
class
DefaultConfig
(
AppConfig
):
...
...
@@ -11,3 +14,39 @@ class DefaultConfig(AppConfig):
}
licence
=
"
EUPL-1.2+
"
copyright_info
=
(([
2022
],
"
Dominik George
"
,
"
dominik.george@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
"
,
})
return
variants
This diff is collapsed.
Click to expand it.
aleksis/apps/tezor/preferences.py
0 → 100644
+
74
−
0
View file @
8020b76a
from
django.utils.translation
import
gettext_lazy
as
_
from
dynamic_preferences.preferences
import
Section
from
dynamic_preferences.types
import
BooleanPreference
,
StringPreference
from
aleksis.core.registries
import
site_preferences_registry
payments
=
Section
(
"
payments
"
,
verbose_name
=
_
(
"
Payments
"
))
@site_preferences_registry.register
class
SofortAPIID
(
StringPreference
):
"""
Sofort payment backend - API ID.
"""
section
=
payments
name
=
"
sofort_api_id
"
verbose_name
=
_
(
"
Sofort / Klarna - API ID
"
)
default
=
""
required
=
False
@site_preferences_registry.register
class
SofortAPIKey
(
StringPreference
):
"""
Sofort payment backend - API key.
"""
section
=
payments
name
=
"
sofort_api_key
"
verbose_name
=
_
(
"
Sofort / Klarna - API Key
"
)
default
=
""
required
=
False
@site_preferences_registry.register
class
SofortProjectID
(
StringPreference
):
"""
Sofort payment backend - project ID.
"""
section
=
payments
name
=
"
sofort_project_id
"
verbose_name
=
_
(
"
Sofort / Klarna - Project ID
"
)
default
=
""
required
=
False
@site_preferences_registry.register
class
PaypalClientID
(
StringPreference
):
"""
PayPal payment backend - client ID.
"""
section
=
payments
name
=
"
paypal_client_id
"
verbose_name
=
_
(
"
PayPal - Client ID
"
)
default
=
""
required
=
False
@site_preferences_registry.register
class
PaypalSecret
(
StringPreference
):
"""
PayPal payment backend - secret.
"""
section
=
payments
name
=
"
paypal_secret
"
verbose_name
=
_
(
"
PayPal - Secret
"
)
default
=
""
required
=
False
@site_preferences_registry.register
class
PaypalCapture
(
BooleanPreference
):
"""
PayPal payment backend - use Authorize & Capture.
"""
section
=
payments
name
=
"
paypal_capture
"
verbose_name
=
_
(
"
PayPal - Use Authorize & Capture
"
)
default
=
False
required
=
False
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment