mirror of
https://github.com/pretix/pretix.git
synced 2026-08-27 13:24:41 +00:00
First steps into a payment provider API
This commit is contained in:
@@ -8,3 +8,4 @@ Contents:
|
|||||||
|
|
||||||
plugins
|
plugins
|
||||||
restriction
|
restriction
|
||||||
|
payment
|
||||||
|
|||||||
@@ -57,5 +57,12 @@ example, taken from the time restriction module (see next chapter) as a template
|
|||||||
You have to implement a ``PretixPluginMeta`` class like in the example to make your
|
You have to implement a ``PretixPluginMeta`` class like in the example to make your
|
||||||
plugin available to the users.
|
plugin available to the users.
|
||||||
|
|
||||||
|
Currently, the ``PluginType`` enum has the following values defined:
|
||||||
|
|
||||||
|
* ``RESTRICTION``
|
||||||
|
* ``PAYMENT``
|
||||||
|
|
||||||
|
The next pages provide details on their usage.
|
||||||
|
|
||||||
.. _signal dispatcher: https://docs.djangoproject.com/en/1.7/topics/signals/
|
.. _signal dispatcher: https://docs.djangoproject.com/en/1.7/topics/signals/
|
||||||
.. _namespace packages: http://legacy.python.org/dev/peps/pep-0420/
|
.. _namespace packages: http://legacy.python.org/dev/peps/pep-0420/
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class BasePaymentProvider:
|
||||||
|
"""
|
||||||
|
This is the base class for all payment providers.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_identifier(self) -> str:
|
||||||
|
"""
|
||||||
|
Return a unique identifier for this payment provider
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
@@ -8,6 +8,7 @@ from django.apps import apps
|
|||||||
|
|
||||||
class PluginType(Enum):
|
class PluginType(Enum):
|
||||||
RESTRICTION = 1
|
RESTRICTION = 1
|
||||||
|
PAYMENT = 2
|
||||||
|
|
||||||
|
|
||||||
def get_all_plugins() -> "List[class]":
|
def get_all_plugins() -> "List[class]":
|
||||||
|
|||||||
@@ -51,3 +51,11 @@ return a positive result (see plugin API documentation for details).
|
|||||||
determine_availability = EventPluginSignal(
|
determine_availability = EventPluginSignal(
|
||||||
providing_args=["item", "variations", "context", "cache"]
|
providing_args=["item", "variations", "context", "cache"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
"""
|
||||||
|
This signal is sent out to get all known payment providers. Receivers should return a
|
||||||
|
subclass of pretix.base.payment.BasePaymentProvider
|
||||||
|
"""
|
||||||
|
register_payment_providers = EventPluginSignal(
|
||||||
|
providing_args=[]
|
||||||
|
)
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from pretix.base.plugins import PluginType
|
||||||
|
|
||||||
|
|
||||||
|
class BankTransferApp(AppConfig):
|
||||||
|
name = 'pretix.plugins.banktransfer'
|
||||||
|
verbose_name = _("Bank transfer")
|
||||||
|
|
||||||
|
class PretixPluginMeta:
|
||||||
|
type = PluginType.PAYMENT
|
||||||
|
name = _("Bank transfer")
|
||||||
|
author = _("the pretix team")
|
||||||
|
version = '1.0.0'
|
||||||
|
description = _("This plugin allows you to receive payments " +
|
||||||
|
"via bank transfer ")
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
from . import signals # NOQA
|
||||||
|
|
||||||
|
|
||||||
|
default_app_config = 'pretix.plugins.banktransfer.BankTransferApp'
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
from pretix.base.payment import BasePaymentProvider
|
||||||
|
|
||||||
|
|
||||||
|
class BankTransfer(BasePaymentProvider):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
from pretix.base.signals import register_payment_providers
|
||||||
|
|
||||||
|
from .payment import BankTransfer
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(register_payment_providers)
|
||||||
|
def register_payment_provider(sender, **kwargs):
|
||||||
|
return BankTransfer
|
||||||
@@ -46,6 +46,7 @@ INSTALLED_APPS = (
|
|||||||
'djangoformsetjs',
|
'djangoformsetjs',
|
||||||
'pretix.plugins.testdummy',
|
'pretix.plugins.testdummy',
|
||||||
'pretix.plugins.timerestriction',
|
'pretix.plugins.timerestriction',
|
||||||
|
'pretix.plugins.banktransfer',
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE_CLASSES = (
|
||||||
|
|||||||
Reference in New Issue
Block a user