Index: main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py
===================================================================
--- main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py	(revision 7898)
+++ main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py	(revision 7919)
@@ -107,4 +107,12 @@
             'redirectURL':site_redirect_url}
         return QUERY_URL + '?%s' % urllib.urlencode(args)
+
+# Alternative preferred solution
+class InterswitchRequestWebserviceActionButton(RequestCallbackActionButton):
+    grok.order(4)
+    icon = 'actionicon_call.png'
+    text = _('Request CollegePAY webservice')
+    target = 'request_webservice'
+
 
 class InterswitchPage(KofaPage):
@@ -183,9 +191,9 @@
         query = self.request.form
         # Should be logged instead of printed
-        print query
+        write_log_message(self,'callback received: %s' % query)
         if query.get('resp', None) != '00':
             self.flash(_('Unsuccessful callback: ${a}',
                 mapping = {'a': query.get('desc', _('Incomplete query string.'))}))
-            write_log_message(self,'invalid callback: %s' % self.context.p_id)
+            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)
@@ -195,5 +203,5 @@
         if query.get('apprAmt', None) != str(self.context.amount_auth):
             self.flash(_('Wrong amount'))
-            write_log_message(self,'wrong amount: %s' % self.context.p_id)
+            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)
@@ -247,2 +255,84 @@
         self.redirect(self.url(self.context, '@@index'))
         return
+
+# Alternative solution, replaces OnlinePaymentCallbackPage
+class OnlinePaymentRequestWebservicePage(UtilityView, grok.View):
+    """ Request webservice view for the CollegePAY gateway
+    """
+    grok.context(IStudentOnlinePayment)
+    grok.name('request_webservice')
+    grok.require('waeup.payStudent')
+
+    def update(self):
+        if self.context.p_state == 'paid':
+            self.flash(_('This ticket has already been paid.'))
+            return
+        student = self.context.getStudent()
+        sr = get_SOAP_response(PRODUCT_ID, self.context.p_id)
+        write_log_message(self,'callback received: %s' % sr)
+        wlist = sr.split(':')
+        if len(wlist) != 7:
+            self.flash(_('Invalid callback: ${a}',
+                mapping = {'a': wlist}))
+            write_log_message(self,'invalid callback: %s' % self.context.p_id)
+            return
+        self.context.r_code = wlist[0]
+        self.context.r_desc = wlist[1]
+        self.context.r_amount_approved = int(wlist[2])
+        self.context.r_card_num = wlist[3]
+        self.context.r_pay_reference = wlist[5]
+        
+        if wlist[0] != '00':
+            self.flash(_('Unsuccessful callback: ${a}',
+                mapping = {'a': wlist[1]}))
+            write_log_message(self,'unsuccessful callback: %s' % self.context.p_id)
+            self.context.p_state = 'failed'
+            return
+
+        if wlist[2] != str(self.context.amount_auth):
+            self.flash(_('Wrong amount'))
+            write_log_message(self,'successful callback but wrong amount: %s' % self.context.p_id)
+            self.context.p_state = 'failed'
+            return
+
+        if wlist[5] != self.context.p_id:
+            self.flash(_('Wrong transaction id'))
+            write_log_message(self,'successful callback but wrong transaction id: %s' % self.context.p_id)
+            self.context.p_state = 'failed'
+            return
+
+        write_log_message(self,'successful callback: %s' % self.context.p_id)
+
+        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.'))
+        return
+
+    def render(self):
+        self.redirect(self.url(self.context, '@@index'))
+        return
