django-payments icon indicating copy to clipboard operation
django-payments copied to clipboard

Replace `get_payment_model` with a parametrized `process_data` view

Open patrys opened this issue 12 years ago • 3 comments

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 avatar Nov 07 '13 18:11 patrys

@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.

patrys avatar Nov 07 '13 18:11 patrys

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

mociepka avatar Nov 08 '13 11:11 mociepka

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

patrys avatar Nov 08 '13 11:11 patrys