Exemplo n.º 1
0
def register_to_payment(order_class, **kwargs):
    """
    A function for registering unaware order class to ``getpaid``. This will
    generate a ``Payment`` model class that will store payments with
    ForeignKey to original order class

    This also will build a model class for every enabled backend.
    """
    global Payment
    global Order
    class Payment(PaymentFactory.construct(order=order_class, **kwargs)):
        objects = PaymentManager()
        class Meta:
            ordering = ('-created_on',)
            verbose_name = _("Payment")
            verbose_name_plural = _("Payments")

    Order = order_class

    # Now build models for backends

    backend_models_modules = import_backend_modules('models')
    for backend_name, models in backend_models_modules.items():
        app_cache.register_models(backend_name, *models.build_models(Payment))
    return Payment
Exemplo n.º 2
0
def register_to_payment(order_class, **kwargs):
    """
    A function for registering unaware order class to ``getpaid``. This will
    generate a ``Payment`` model class that will store payments with
    ForeignKey to original order class

    This also will build a model class for every enabled backend.
    """
    global Payment
    global Order

    class Payment(PaymentFactory.construct(order=order_class, **kwargs)):
        objects = PaymentManager()

        class Meta:
            ordering = ('-created_on', )
            verbose_name = _("Payment")
            verbose_name_plural = _("Payments")

    Order = order_class

    # Now build models for backends

    backend_models_modules = import_backend_modules('models')
    for backend_name, models in backend_models_modules.items():
        app_cache.register_models(backend_name, *models.build_models(Payment))
    return Payment
Exemplo n.º 3
0
def build_payment_model(order_class, **kwargs):
	global Payment
	global Order
	class Payment(PaymentFactory.construct(order=order_class, **kwargs)):
		pass
	Order = order_class
	bknd_models_modules = import_backend_modules('models')
	for bknd_name, models in bknd_models_modules.items():
		app_cache.register_models(bknd_name, *models.build_models(Payment))
	return Payment
Exemplo n.º 4
0
def build_payment_model(order_class, **kwargs):
    global Payment
    global Order

    class Payment(PaymentFactory.construct(order=order_class, **kwargs)):
        pass

    Order = order_class
    bknd_models_modules = import_backend_modules('models')
    for bknd_name, models in bknd_models_modules.items():
        app_cache.register_models(bknd_name, *models.build_models(Payment))
    return Payment
Exemplo n.º 5
0
def get_backend_choices():
    choices = []
    backends = import_backend_modules()
    for name, module in backends.items():
        choices.append((name, module.BACKEND_NAME))
    return choices
Exemplo n.º 6
0
order_to_payment_query.__doc__ = """
Sent to ask for filling Payment object with order data:
	order:			order instance
	payment:		Payment instance
It needs to be answered only if you don't create Payment by yourself and let
Mamona do it (e.g. by using mamona.views.process_order).
It must fill mandatory Payment fields: order and amount.
"""

########NEW FILE########
__FILENAME__ = urls
from django.conf.urls.defaults import *
from utils import import_backend_modules

includes_list = []
for bknd_name, urls in import_backend_modules('urls').items():
    includes_list.append(url(r'^%s/' % bknd_name, include(urls)))

urlpatterns = patterns(
    'mamona',
    url('^order/$', 'views.process_order', name='mamona-process-order'),
    url('^payment/(?P<payment_id>[0-9]+)$',
        'views.process_payment',
        name='mamona-process-payment'),
    url('^confirm/(?P<payment_id>[0-9]+)$',
        'views.confirm_payment',
        name='mamona-confirm-payment'), *includes_list)

########NEW FILE########
__FILENAME__ = utils
from django.conf import settings
Exemplo n.º 7
0
from django.conf.urls.defaults import *
from utils import import_backend_modules

includes_list = []
for bknd_name, urls in import_backend_modules('urls').items():
	includes_list.append(url(r'^%s/' % bknd_name, include(urls)))

urlpatterns = patterns('mamona',
		url('^order/$', 'views.process_order', name='mamona-process-order'),
		url('^payment/(?P<payment_id>[0-9]+)$', 'views.process_payment', name='mamona-process-payment'),
		url('^confirm/(?P<payment_id>[0-9]+)$', 'views.confirm_payment', name='mamona-confirm-payment'),
		*includes_list
		)
Exemplo n.º 8
0
def get_backend_choices():
	choices = []
	backends = import_backend_modules()
	for name, module in backends.items():
		choices.append((name, module.BACKEND_NAME))
	return choices
Exemplo n.º 9
0
from django.conf.urls import *
from utils import import_backend_modules

includes_list = []
for bknd_name, urls in import_backend_modules("urls").items():
    includes_list.append(url(r"^%s/" % bknd_name, include(urls)))

urlpatterns = patterns(
    "mamona",
    url("^order/$", "views.process_order", name="mamona-process-order"),
    url(
        "^payment/(?P<payment_id>[0-9]+)/(?P<order_class>[^/]+)/$",
        "views.process_payment",
        name="mamona-process-payment",
    ),
    url(
        "^confirm/(?P<payment_id>[0-9]+)/(?P<order_class>[^/]+)/$",
        "views.confirm_payment",
        name="mamona-confirm-payment",
    ),
    *includes_list
)