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
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
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
def get_backend_choices(): choices = [] backends = import_backend_modules() for name, module in backends.items(): choices.append((name, module.BACKEND_NAME)) return choices
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
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 )
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 )