Index: main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/browser.py
===================================================================
--- main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/browser.py	(revision 9455)
+++ main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/browser.py	(revision 9613)
@@ -182,9 +182,8 @@
     site_name = SITE_NAME
     currency = CURRENCY
-    pay_item_id = '8302'
+    pay_item_id = ''
     product_id = PRODUCT_ID
 
     def update(self):
-        #if self.context.p_state != 'unpaid':
         if self.context.p_state == 'paid':
             self.flash(_("Payment ticket can't be re-send to CollegePAY."))
@@ -214,28 +213,39 @@
         xmldict['provider_amt'] = 100 * 500
         # Institution data
-        studycourse = student['studycourse']
-        if student.current_mode in ('ug_sw','prence',):
-            xmldict['institution_acct'] = "6216801025"
+        xmldict['fceokene_acct'] = "0000000000000"
+        xmldict['institution_bank_id'] = '0'
+        xmldict['institution_item_name'] = self.category
+        xmldict['institution_name'] = INSTITUTION_NAME
+        if self.context.p_category == 'schoolfee':
+            self.pay_item_id = '8302'
+            studycourse = student['studycourse']
+            if student.current_mode in ('ug_sw','prence',):
+                xmldict['institution_acct'] = "6216801025"
+                xmldict['institution_bank_id'] = '117'
+            elif student.current_mode in ('ug_ft',) and \
+                student['studycourse'].current_verdict == 'O':
+                xmldict['institution_acct'] = "6216801025"
+                xmldict['institution_bank_id'] = '117'
+            elif student.current_mode in ('ug_ft',):
+                xmldict['institution_acct'] = "6216801033"
+                xmldict['institution_bank_id'] = '117'
+            elif student.current_mode in ('pd_ft',):
+                xmldict['institution_acct'] = "6216801025"
+                xmldict['institution_bank_id'] = '117'
+            xmldict['fceokene_split'] = 100 * 1400
+            xmldict['institution_amt'] = 100 * (
+                self.context.amount_auth - 500 - 150 - 1400)
+        elif 'maintenance' in self.context.p_category:
+            self.pay_item_id = '8300'
+            xmldict['institution_amt'] = 100 * (
+                self.context.amount_auth - 150)
+            xmldict['institution_acct'] = "1012044132"
             xmldict['institution_bank_id'] = '117'
-        elif student.current_mode in ('ug_ft',) and \
-            student['studycourse'].current_verdict == 'O':
-            xmldict['institution_acct'] = "6216801025"
-            xmldict['institution_bank_id'] = '117'
-        elif student.current_mode in ('ug_ft',):
-            xmldict['institution_acct'] = "6216801033"
-            xmldict['institution_bank_id'] = '117'
-        elif student.current_mode in ('pd_ft',):
-            xmldict['institution_acct'] = "6216801025"
-            xmldict['institution_bank_id'] = '117'
-        else:
-            xmldict['fceokene_acct'] = "0000000000000"
-            xmldict['institution_bank_id'] = '0'
-        xmldict['fceokene_split'] = 100 * 1400
-        xmldict['institution_amt'] = 100 * (
-            self.context.amount_auth - 500 - 150 - 1400)
-        xmldict['institution_item_name'] = self.context.p_category
-        xmldict['institution_name'] = INSTITUTION_NAME
+            xmldict['institution_amt'] = 100 * (
+                self.context.amount_auth - 150)
         # Interswitch amount is not part of the xml data
-        xmltext = """<payment_item_detail>
+
+        if self.context.p_category == 'schoolfee':
+            xmltext = """<payment_item_detail>
 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
 <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
@@ -244,4 +254,12 @@
 </item_details>
 </payment_item_detail>""" % xmldict
+
+        elif 'maintenance' in self.context.p_category:
+            xmltext = """<payment_item_detail>
+<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
+<item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
+</item_details>
+</payment_item_detail>""" % xmldict
+
         self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
         return
@@ -321,5 +339,6 @@
         student.writeLogMessage(self, log)
         if not success:
-            self.flash(msg)
+            msg = self.request['QUERY_STRING'].replace('%20',' ')
+            self.flash(_('Response from Interswitch: ') + msg)
             return
         success, msg, log = self.context.doAfterStudentPayment()
Index: main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/tests.py
===================================================================
--- main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/tests.py	(revision 9455)
+++ main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/tests.py	(revision 9613)
@@ -50,4 +50,5 @@
         IWorkflowState(self.student).setState('cleared')
         self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
         self.assertMatches('...ticket created...',
@@ -77,20 +78,71 @@
     def test_interswitch_form(self):
 
+        # Manager can access InterswitchForm for the created school fee ticket
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertMatches('...Total Amount Authorized:...',
+                           self.browser.contents)
+        self.assertMatches(
+            '...<input type="hidden" name="amount" value="1249500.0" />...',
+            self.browser.contents)
+        self.assertMatches(
+            '...item_name="School Fee" item_amt="1044500" bank_id="117" acct_num="6216801033"...',
+            self.browser.contents)
+        self.assertMatches(
+            '...item_name="FCEOkene Split" item_amt="140000" bank_id="117" acct_num="6216801058"...',
+            self.browser.contents)
+        self.assertMatches(
+            '...item_name="BT Education" item_amt="50000" bank_id="31" acct_num="0026781725"...',
+            self.browser.contents)
+
+        # Let's do the same for maintenance fee payment
+
+        self.browser.open(self.payments_path)
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(
+            name="form.p_category").value = ['hostel_maintenance']
+        self.browser.getControl("Create ticket").click()
+        self.assertMatches('...You have not yet booked accommodation...',
+                           self.browser.contents)
+        # Students have to book bed first
+        self.browser.open(self.acco_path)
+        IWorkflowState(self.student).setState('admitted')
+        self.browser.getLink("Book accommodation").click()
+        self.assertFalse('Activation Code:' in self.browser.contents)
+        self.browser.getControl("Create bed ticket").click()
+        # Bed is randomly selected but, since there is only
+        # one bed for this student, we know that ...
+        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
+                           self.browser.contents)
+        self.assertMatches('...ticket created...',
+                           self.browser.contents)
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(
+            name="form.p_category").value = ['hostel_maintenance']
+        self.browser.getControl("Create ticket").click()
+        self.assertMatches('...ticket created...',
+                           self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        value = ctrl.options[1]
+        self.browser.getLink(value).click()
+        self.assertMatches('...Amount Authorized...',
+                           self.browser.contents)
+        self.assertMatches(
+            '...<span>4000.0</span>...',
+            self.browser.contents)
+        self.payment_url = self.browser.url
         # Manager can access InterswitchForm
         self.browser.getLink("CollegePAY", index=0).click()
+        # The total amount to be processed by Interswitch
+        # has been reduced by the Interswitch fee of 150 Nairas
         self.assertMatches('...Total Amount Authorized:...',
                            self.browser.contents)
         self.assertMatches(
-            '...<input type="hidden" name="amount" value="1249500.0" />...',
-            self.browser.contents)
-        self.assertMatches(
-            '...item_name="schoolfee" item_amt="1044500" bank_id="117" acct_num="6216801033"...',
-            self.browser.contents)
-        self.assertMatches(
-            '...item_name="FCEOkene Split" item_amt="140000" bank_id="117" acct_num="6216801058"...',
-            self.browser.contents)
-        self.assertMatches(
-            '...item_name="BT Education" item_amt="50000" bank_id="31" acct_num="0026781725"...',
-            self.browser.contents)
+            '...<input type="hidden" name="amount" value="400000.0" />...',
+            self.browser.contents)
+        self.assertMatches(
+            '...item_name="Hostel Maintenance Fee" item_amt="385000" bank_id="117" acct_num="1012044132"...',
+            self.browser.contents)
+        # BT does nor charge a fee for maintenance fee
+        self.assertFalse("BT Education" in self.browser.contents)
 
 #    @external_test
