Commits

marconius committed 7ef3275 Draft

woops! forgot to add the new capture view

  • Participants
  • Parent commits 969709c

Comments (0)

Files changed (1)

File satchmo/apps/payment/views/processing.py

+from django.http import HttpResponseRedirect
+from django.utils.translation import ugettext as _
+from django.core.urlresolvers import reverse
+from django.contrib.auth.decorators import permission_required
+from satchmo_store.shop.models import OrderAuthorization
+import logging
+
+from payment.utils import get_processor_by_key
+
+log = logging.getLogger('payment.views')
+
+@permission_required('shop.change_order')
+def capture_authorization(request, auth_id):
+    """
+    A view that captures an authorization and then returns you to the order 
+    change form in the admin site.
+    """
+    auth = OrderAuthorization.objects.get(id = auth_id)
+    processor = get_processor_by_key("PAYMENT_{0}".format(auth.payment))
+    
+    #TODO handle exceptions like authorization failure
+    processor.capture_authorized_payment(auth, order=auth.order, 
+                                         amount=auth.amount)
+    url = reverse("admin:shop_order_change", args=[auth.order.id,])
+    return HttpResponseRedirect(url)