Index: main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py
===================================================================
--- main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py	(revision 7925)
+++ main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py	(revision 7926)
@@ -26,4 +26,5 @@
 from waeup.kofa.students.browser import write_log_message
 from waeup.kofa.students.viewlets import RequestCallbackActionButton
+from waeup.custom.utils.utils import actions_after_payment
 from waeup.custom.interfaces import MessageFactory as _
 
@@ -171,5 +172,5 @@
         return
 
-class OnlinePaymentCallbackPage(UtilityView, grok.View):
+class InterswitchPaymentCallbackPage(UtilityView, grok.View):
     """ Callback view for the CollegePAY gateway
     """
@@ -192,18 +193,26 @@
         # Should be logged instead of printed
         write_log_message(self,'callback received: %s' % query)
-        if query.get('resp', None) != '00':
+
+        self.context.r_card_num = query.get('cardNum', None)
+        self.context.r_code = query.get('resp', None)
+        self.context.r_pay_reference  = query.get('payRef', None)
+        self.context.r_amount_approved = int(query.get('apprAmt', '0')) / 100
+        self.context.r_desc = query.get('desc', None)
+
+        if self.context.r_code != '00':
             self.flash(_('Unsuccessful callback: ${a}',
                 mapping = {'a': query.get('desc', _('Incomplete query string.'))}))
             write_log_message(self,'unsuccessful callback: %s' % self.context.p_id)
-            self.context.r_card_num = query.get('cardNum', None)
-            self.context.r_code = query.get('resp', None)
-            self.context.p_state = 'failed'
-            return
-
-        if query.get('apprAmt', None) != str(self.context.amount_auth):
+            self.context.p_state = 'failed'
+            return
+
+        total_amount_auth = (
+            self.context.amount_auth
+            + self.context.surcharge_1
+            + self.context.surcharge_2)
+
+        if self.context.r_amount_approved != total_amount_auth:
             self.flash(_('Wrong amount'))
             write_log_message(self,'successful but wrong amount: %s' % self.context.p_id)
-            self.context.r_card_num = query.get('cardNum', None)
-            self.context.r_code = query.get('resp', None)
             self.context.p_state = 'failed'
             return
@@ -217,37 +226,9 @@
 
         write_log_message(self,'valid callback: %s' % self.context.p_id)
-        self.context.r_amount_approved = self.context.amount_auth
-        self.context.r_card_num = query.get('cardNum', None)
-        self.context.r_code = query.get('resp', None)
-        self.context.r_desc = query.get('desc', None)
-        self.context.r_pay_reference  = query.get('payRef', None)
         self.context.p_state = 'paid'
         self.context.payment_date = datetime.now()
 
-        if self.context.p_category == 'clearance':
-            # Create CLR access code
-            pin, error = create_accesscode('CLR',0,student.student_id)
-            if error:
-                self.flash(_('Valid callback received. ${a}',
-                    mapping = {'a':error}))
-                return
-            self.context.ac = pin
-        elif self.context.p_category == 'schoolfee':
-            # Create SFE access code
-            pin, error = create_accesscode('SFE',0,student.student_id)
-            if error:
-                self.flash(_('Valid callback received. ${a}',
-                    mapping = {'a':error}))
-                return
-            self.context.ac = pin
-        elif self.context.p_category == 'bed_allocation':
-            # Create HOS access code
-            pin, error = create_accesscode('HOS',0,student.student_id)
-            if error:
-                self.flash(_('Valid callback received. ${a}',
-                    mapping = {'a':error}))
-                return
-            self.context.ac = pin
-        self.flash(_('Valid callback received.'))
+        actions_after_payment(student, self.context, self)
+
         return
 
@@ -257,5 +238,5 @@
 
 # Alternative solution, replaces OnlinePaymentCallbackPage
-class OnlinePaymentRequestWebservicePage(UtilityView, grok.View):
+class InterswitchPaymentRequestWebservicePage(UtilityView, grok.View):
     """ Request webservice view for the CollegePAY gateway
     """
@@ -279,9 +260,9 @@
         self.context.r_code = wlist[0]
         self.context.r_desc = wlist[1]
-        self.context.r_amount_approved = int(wlist[2])
+        self.context.r_amount_approved = int(wlist[2]) / 100
         self.context.r_card_num = wlist[3]
         self.context.r_pay_reference = wlist[5]
         
-        if wlist[0] != '00':
+        if self.context.r_code != '00':
             self.flash(_('Unsuccessful callback: ${a}',
                 mapping = {'a': wlist[1]}))
@@ -290,5 +271,10 @@
             return
 
-        if wlist[2] != str(self.context.amount_auth):
+        total_amount_auth = (
+            self.context.amount_auth
+            + self.context.surcharge_1
+            + self.context.surcharge_2)
+
+        if self.context.r_amount_approved != total_amount_auth:
             self.flash(_('Wrong amount'))
             write_log_message(self,'successful callback but wrong amount: %s' % self.context.p_id)
@@ -296,5 +282,5 @@
             return
 
-        if wlist[5] != self.context.p_id:
+        if wlist[4] != self.context.p_id:
             self.flash(_('Wrong transaction id'))
             write_log_message(self,'successful callback but wrong transaction id: %s' % self.context.p_id)
@@ -307,29 +293,6 @@
         self.context.payment_date = datetime.now()
 
-        if self.context.p_category == 'clearance':
-            # Create CLR access code
-            pin, error = create_accesscode('CLR',0,student.student_id)
-            if error:
-                self.flash(_('Valid callback received. ${a}',
-                    mapping = {'a':error}))
-                return
-            self.context.ac = pin
-        elif self.context.p_category == 'schoolfee':
-            # Create SFE access code
-            pin, error = create_accesscode('SFE',0,student.student_id)
-            if error:
-                self.flash(_('Valid callback received. ${a}',
-                    mapping = {'a':error}))
-                return
-            self.context.ac = pin
-        elif self.context.p_category == 'bed_allocation':
-            # Create HOS access code
-            pin, error = create_accesscode('HOS',0,student.student_id)
-            if error:
-                self.flash(_('Valid callback received. ${a}',
-                    mapping = {'a':error}))
-                return
-            self.context.ac = pin
-        self.flash(_('Valid callback received.'))
+        actions_after_payment(student, self.context, self)
+
         return
 
Index: main/waeup.custom/trunk/src/waeup/custom/interswitch/tests.py
===================================================================
--- main/waeup.custom/trunk/src/waeup/custom/interswitch/tests.py	(revision 7925)
+++ main/waeup.custom/trunk/src/waeup/custom/interswitch/tests.py	(revision 7926)
@@ -73,8 +73,8 @@
         self.assertMatches('...Failed...',
                            self.browser.contents)
-        self.browser.open(self.callback_url(payment_url, '00', '300'))
+        self.browser.open(self.callback_url(payment_url, '00', '300000'))
         self.assertMatches('...Wrong amount...',
                           self.browser.contents)
-        self.browser.open(self.callback_url(payment_url, '00', '40000'))
+        self.browser.open(self.callback_url(payment_url, '00', '4000000'))
         self.assertMatches('...Valid callback received...',
                           self.browser.contents)
Index: main/waeup.custom/trunk/src/waeup/custom/utils/utils.py
===================================================================
--- main/waeup.custom/trunk/src/waeup/custom/utils/utils.py	(revision 7925)
+++ main/waeup.custom/trunk/src/waeup/custom/utils/utils.py	(revision 7926)
@@ -20,4 +20,34 @@
 import os
 from waeup.kofa.utils.utils import KofaUtils
+from waeup.kofa.accesscodes import create_accesscode
+from waeup.custom.interfaces import MessageFactory as _
+
+def actions_after_payment(student, payment, view):
+    if payment.p_category == 'clearance':
+        # Create CLR access code
+        pin, error = create_accesscode('CLR',0,student.student_id)
+        if error:
+            view.flash(_('Valid callback received. ${a}',
+                mapping = {'a':error}))
+            return
+        payment.ac = pin
+    elif payment.p_category == 'schoolfee':
+        # Create SFE access code
+        pin, error = create_accesscode('SFE',0,student.student_id)
+        if error:
+            view.flash(_('Valid callback received. ${a}',
+                mapping = {'a':error}))
+            return
+        payment.ac = pin
+    elif payment.p_category == 'bed_allocation':
+        # Create HOS access code
+        pin, error = create_accesscode('HOS',0,student.student_id)
+        if error:
+            view.flash(_('Valid callback received. ${a}',
+                mapping = {'a':error}))
+            return
+        payment.ac = pin
+    view.flash(_('Valid callback received.'))
+    return
 
 
