jazzband / django-payments

Universal payment handling for Django.
https://django-payments.readthedocs.io
Other
1.01k stars 278 forks source link

Replace `get_payment_model` with a parametrized `process_data` view #24

Open patrys opened 10 years ago

patrys commented 10 years ago

Currently we require an explicit setting pointing to a payment model but there is no technical requirement for that. Instead we could offer a view that accepts the model and let people bind the URLs themselves:

def build_urls(payment_model):
    return patterns(
        '',
        url(
            r'^process/(?P<token>[\w-]+)$',
            process_data, {'model': payment_model},
            name='process_payment'),
        url(r'^static/(?P<variant>[\w-]+)$', static_callback,
            name='static_process_payment'))
urlpatterns = patterns(
    '',
    url('^payment/', include(build_urls(MyPayment))),
    ...)
patrys commented 10 years ago

@mociepka, what do you think? This would allow us to have more than one payment model in the same project and get rid of this awkward API of specifying Python paths in a settings file.

mociepka commented 10 years ago

@patrys now it is more "Django way" like with user. Yours solution looks simpler I don't see any contraindications.

patrys commented 10 years ago

One of the many cases of "Django" versus "pythonic" ;)