Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

# -*- coding: utf-8 -*- 

from django.conf.urls.defaults import patterns, url 

from django.http import HttpResponseRedirect 

from django.utils.translation import ugettext_lazy as _ 

from shop.util.decorators import on_method, shop_login_required, order_required 

 

 

class PayOnDeliveryBackend(object): 

 

    backend_name = "Pay On Delivery" 

    backend_verbose_name = _("Pay On Delivery") 

    url_namespace = "pay-on-delivery" 

 

    def __init__(self, shop): 

        self.shop = shop 

        # This is the shop reference, it allows this backend to interact with 

        # it in a tidy way (look ma', no imports!) 

 

    @on_method(shop_login_required) 

    @on_method(order_required) 

    def simple_view(self, request): 

        """ 

        This simple view does nothing but record the "payment" as being 

        complete since we trust the delivery guy to collect money, and redirect 

        to the success page. This is the most simple case. 

        """ 

        # Get the order object 

        the_order = self.shop.get_order(request) 

        # Let's mark this as being complete for the full sum in our database 

        # Set it as paid (it needs to be paid to the delivery guy, we assume 

        # he does his job properly) 

        self.shop.confirm_payment( 

            the_order, self.shop.get_order_total(the_order), "None", 

            self.backend_name) 

        return HttpResponseRedirect(self.shop.get_finished_url()) 

 

    def get_urls(self): 

        urlpatterns = patterns('', 

            url(r'^$', self.simple_view, name='pay-on-delivery'), 

        ) 

        return urlpatterns