Index: main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py	(revision 13380)
+++ main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py	(revision 13381)
@@ -118,5 +118,6 @@
     currency = CURRENCY
     pay_item_id = '101'
-    mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
+    #mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
+    mac = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023'
 
     def update(self):
@@ -124,5 +125,5 @@
 
         ######################################
-        error = 'Sorry, Interswitch payments are temporarily disabled.'
+        #error = 'Sorry, Interswitch payments are temporarily disabled.'
         ######################################
 
@@ -163,7 +164,7 @@
         xmldict['institution_item_name'] = self.category
         xmldict['institution_name'] = INSTITUTION_NAME
+        provider_amt = 0.0
 
         # PT
-
         if school(student) == 'pt':
             product_id = PRODUCT_ID_PT
@@ -210,5 +211,4 @@
                 xmldict['institution_acct'] = '1014066976'
                 xmldict['institution_bank_id'] = '117'
-                provider_amt = 0.0
                 gown_fee_amt = 2000.0
                 aaue_fl_fee_amt = 800.0
@@ -227,10 +227,108 @@
 </item_details>
 </payment_item_detail>""" % xmldict
+            else:
+                self.flash('Not applicable', type='danger')
+                self.redirect(self.url(self.context, '@@index'))
+                return
 
         # REGULAR
-
         else:
-            pass
-
+            product_id = PRODUCT_ID_REGULAR
+            if self.context.p_category == 'schoolfee':
+                self.pay_item_id = '101'
+                xmldict['institution_bank_id'] = '117'
+                xmldict['institution_acct'] = '1010827641'
+                provider_amt = 1500.0
+                xmldict['provider_amt'] = 100 * provider_amt
+                aaue_share_amt = 1500.0
+                xmldict['aaue_share_amt'] = 100 * aaue_share_amt
+                joint_venture_amt = 1000.0
+                xmldict['joint_venture_amt'] = 100 * joint_venture_amt
+                xmldict['institution_amt'] = 100 * (
+                    self.context.amount_auth
+                    - provider_amt
+                    - joint_venture_amt
+                    - aaue_share_amt
+                    - GATEWAY_AMT)
+                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_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
+<item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="117" acct_num="1014066969" />
+<item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="11" acct_num="0030656377" />
+</item_details>
+</payment_item_detail>""" % xmldict
+
+            elif self.context.p_category == 'clearance':
+                self.pay_item_id = '102'
+                xmldict['institution_acct'] = '1010827641'
+                xmldict['institution_bank_id'] = '117'
+                xmldict['institution_amt'] = 100 * (
+                    self.context.amount_auth - GATEWAY_AMT)
+                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
+
+            elif self.context.p_category == 'union':
+                self.pay_item_id = '103'
+                xmldict['institution_acct'] = '1006360118'
+                xmldict['institution_bank_id'] = '123'
+                xmldict['institution_amt'] = 100 * (
+                    self.context.amount_auth - GATEWAY_AMT)
+                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
+
+            elif self.context.p_category == 'lapel':
+                self.pay_item_id = '104'
+                xmldict['institution_acct'] = '4010660109'
+                xmldict['institution_bank_id'] = '51'
+                xmldict['institution_amt'] = 100 * (
+                    self.context.amount_auth - GATEWAY_AMT)
+                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
+
+            elif self.context.p_category == 'welfare':
+                self.pay_item_id = '105'
+                xmldict['institution_acct'] = '1006407792'
+                xmldict['institution_bank_id'] = '123'
+                xmldict['institution_amt'] = 100 * (
+                    self.context.amount_auth - GATEWAY_AMT)
+                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
+
+            elif self.context.p_category == 'matric_gown':
+                self.pay_item_id = '106'
+                xmldict['institution_acct'] = '5060023429'
+                xmldict['institution_bank_id'] = '51'
+                xmldict['institution_amt'] = 100 * (
+                    self.context.amount_auth - GATEWAY_AMT)
+                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
+
+            elif self.context.p_category == 'concessional':
+                self.pay_item_id = '107'
+                xmldict['institution_acct'] = '1010835352'
+                xmldict['institution_bank_id'] = '117'
+                xmldict['institution_amt'] = 100 * (
+                    self.context.amount_auth - GATEWAY_AMT)
+                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
Index: main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py	(revision 13380)
+++ main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py	(revision 13381)
@@ -64,12 +64,8 @@
         self.browser.getControl("Save").click()
         self.browser.getControl("Add online").click()
-        self.assertMatches('...ticket created...',
-                           self.browser.contents)
+        self.assertTrue('ticket created' in self.browser.contents)
         #self.browser.getLink(value).click()
-        self.assertMatches('...Amount Authorized...',
-                           self.browser.contents)
-        self.assertMatches(
-            '...<span>1000.0</span>...',
-            self.browser.contents)
+        self.assertTrue('Amount Authorized' in self.browser.contents)
+        self.assertTrue('<span>1000.0</span>' in self.browser.contents)
         self.payment_url = self.browser.url
 
@@ -77,16 +73,15 @@
         # Manager can access InterswitchForm
         self.browser.getLink("CollegePAY", index=0).click()
-        self.assertMatches('...Total Amount Authorized:...',
-                           self.browser.contents)
-        self.assertMatches(
-            '...<input type="hidden" name="amount" value="100000" />...',
-            self.browser.contents)
+        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="100000" />'
+            in self.browser.contents)
         delta = timedelta(days=8)
         self.applicant.values()[0].creation_date -= delta
         self.browser.open(self.payment_url)
         self.browser.getLink("CollegePAY", index=0).click()
-        self.assertMatches(
-            '...This payment ticket is too old. Please create a new ticket...',
-            self.browser.contents)
+        self.assertTrue(
+            'This payment ticket is too old. Please create a new ticket'
+            in self.browser.contents)
 
     @external_test
@@ -94,9 +89,7 @@
 
         self.browser.open(self.payment_url + '/request_webservice')
-        self.assertMatches('...Unsuccessful callback...',
-                          self.browser.contents)
+        self.assertTrue('Unsuccessful callback' in self.browser.contents)
         # The payment is now in state failed
-        self.assertMatches('...<span>Failed</span>...',
-                          self.browser.contents)
+        self.assertTrue('<span>Failed</span>' in self.browser.contents)
 
 class InterswitchTestsStudents(StudentsFullSetup):
@@ -121,14 +114,10 @@
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
-        self.assertMatches('...ticket created...',
-                           self.browser.contents)
-        ctrl = self.browser.getControl(name='val_id')
-        self.value = ctrl.options[0]
-        self.browser.getLink(self.value).click()
-        self.assertMatches('...Amount Authorized...',
-                           self.browser.contents)
-        self.assertMatches(
-            '...<span>51750.0</span>...',
-            self.browser.contents)
+        self.assertTrue('ticket created' in self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        self.value = ctrl.options[0]
+        self.browser.getLink(self.value).click()
+        self.assertTrue('Amount Authorized' in self.browser.contents)
+        self.assertTrue('<span>51750.0</span>' in self.browser.contents)
         self.payment_url = self.browser.url
         self.browser.getLink("CollegePAY", index=0).click()
@@ -140,15 +129,55 @@
         self.student['payments']['xyz'] = acc_payment
         self.browser.getLink("CollegePAY", index=0).click()
-        self.assertMatches('...<input type="hidden" name="pay_item_id" value="105" />...',
+        self.assertTrue('<input type="hidden" name="pay_item_id" value="105" />'
+                        in self.browser.contents)
+        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
+        self.assertEqual(self.student.current_mode, 'ug_pt')
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="5175000" />'
+            in self.browser.contents)
+        self.assertTrue(
+            'item_name="School Fee" item_amt="4600000" bank_id="7" '
+            'acct_num="1014847058"' in self.browser.contents)
+
+    def test_interswitch_form_regular_school_fees(self):
+        self.certificate.study_mode = 'ug_ft'
+        self.student['studycourse'].entry_session = 2013
+        self.student['studycourse'].certificate.school_fee_1 = 51750.0
+        # Manager can access InterswitchForm
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.payments_path)
+        IWorkflowState(self.student).setState('cleared')
+        self.student.nationality = u'NG'
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
+        self.assertTrue('ticket created' in
                            self.browser.contents)
-        self.assertMatches('...Total Amount Authorized:...',
+        ctrl = self.browser.getControl(name='val_id')
+        self.value = ctrl.options[0]
+        self.browser.getLink(self.value).click()
+        self.assertTrue('Amount Authorized' in
                            self.browser.contents)
-        self.assertEqual(self.student.current_mode, 'ug_pt')
-        self.assertMatches(
-            '...<input type="hidden" name="amount" value="5175000" />...',
-            self.browser.contents)
-        self.assertMatches(
-            '...item_name="School Fee" item_amt="4600000" bank_id="7" acct_num="1014847058"...',
-            self.browser.contents)
+        self.assertTrue('<span>51750.0</span>' in self.browser.contents)
+        self.payment_url = self.browser.url
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue(
+            'Please pay acceptance fee first' in self.browser.contents)
+        acc_payment = createObject('waeup.StudentOnlinePayment')
+        acc_payment.p_state = 'paid'
+        acc_payment.p_category = 'clearance'
+        self.student['payments']['xyz'] = acc_payment
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue('<input type="hidden" name="pay_item_id" value="101" />'
+                        in self.browser.contents)
+        self.assertTrue('Total Amount Authorized:'
+                        in self.browser.contents)
+        self.assertEqual(self.student.current_mode, 'ug_ft')
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="5175000" />'
+            in self.browser.contents)
+        self.assertTrue(
+            'item_name="School Fee" item_amt="4750000" bank_id="117" '
+            'acct_num="1010827641"' in self.browser.contents)
 
 
@@ -164,26 +193,85 @@
         self.browser.getControl(name="form.p_category").value = ['clearance']
         self.browser.getControl("Create ticket").click()
-        self.assertMatches('...ticket created...',
+        self.assertTrue('ticket created' in  self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        self.value = ctrl.options[0]
+        self.browser.getLink(self.value).click()
+        self.assertTrue('Amount Authorized' in self.browser.contents)
+        self.assertTrue('<span>43050.0</span>' in  self.browser.contents)
+        self.payment_url = self.browser.url
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />' in
                            self.browser.contents)
-        ctrl = self.browser.getControl(name='val_id')
-        self.value = ctrl.options[0]
-        self.browser.getLink(self.value).click()
-        self.assertMatches('...Amount Authorized...',
-                           self.browser.contents)
-        self.assertMatches(
-            '...<span>43050.0</span>...',
-            self.browser.contents)
-        self.payment_url = self.browser.url
-        self.browser.getLink("CollegePAY", index=0).click()
-        self.assertMatches('...<input type="hidden" name="pay_item_id" value="104" />...',
-                           self.browser.contents)
-        self.assertMatches('...Total Amount Authorized:...',
-                           self.browser.contents)
-        self.assertMatches(
-            '...<input type="hidden" name="amount" value="5175000" />...',
-            self.browser.contents)
-        self.assertMatches(
-            '...item_name="Acceptance Fee" item_amt="4280000" bank_id="117" acct_num="1014066976"...',
-            self.browser.contents)
+        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="4305000" />'
+            in self.browser.contents)
+        self.assertTrue(
+            'item_name="Acceptance Fee" item_amt="4000000" bank_id="117" '
+            'acct_num="1014066976"' in self.browser.contents)
+
+    def test_interswitch_form_regular_acceptance_fees(self):
+        self.certificate.study_mode = 'ug_ft'
+        self.app['configuration']['2004'].clearance_fee = 43050.0
+        # Manager can access InterswitchForm
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.payments_path)
+        IWorkflowState(self.student).setState('admitted')
+        self.student.nationality = u'NG'
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['clearance']
+        self.browser.getControl("Create ticket").click()
+        self.assertTrue('ticket created' in self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        self.value = ctrl.options[0]
+        self.browser.getLink(self.value).click()
+        self.assertTrue('Amount Authorized' in self.browser.contents)
+        self.assertTrue('<span>43050.0</span>' in self.browser.contents)
+        self.payment_url = self.browser.url
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue('<input type="hidden" name="pay_item_id" value="102" />'
+                        in self.browser.contents)
+        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="4305000" />'
+            in self.browser.contents)
+        self.assertTrue(
+            'item_name="Acceptance Fee" item_amt="4280000" bank_id="117" '
+            'acct_num="1010827641"' in self.browser.contents)
+
+    def test_interswitch_form_welfare_fees(self):
+        self.certificate.study_mode = 'ug_pt'
+        self.app['configuration']['2004'].welfare_fee = 1567.0
+        # Manager can access InterswitchForm
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.payments_path)
+        IWorkflowState(self.student).setState('admitted')
+        self.student.nationality = u'NG'
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['welfare']
+        self.browser.getControl("Create ticket").click()
+        self.assertTrue('ticket created' in  self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        self.value = ctrl.options[0]
+        self.browser.getLink(self.value).click()
+        self.assertTrue('Amount Authorized' in self.browser.contents)
+        self.assertTrue(
+            '<span>1567.0</span>' in self.browser.contents)
+        self.payment_url = self.browser.url
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue('<div class="alert alert-danger">Not applicable</div>'
+                        in self.browser.contents)
+        self.certificate.study_mode = 'ug_ft'
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue('<input type="hidden" name="pay_item_id" value="105" />'
+                           in self.browser.contents)
+        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="156700" />'
+            in self.browser.contents)
+        self.assertTrue(
+            'item_name="AAU Student Welfare Assurance Fee" item_amt="131700" '
+            'bank_id="123" acct_num="1006407792"'
+            in self.browser.contents)
 
     def test_interswitch_form_ticket_expired(self):
@@ -199,25 +287,23 @@
         self.browser.open(self.payments_path + '/xyz')
         self.browser.getLink("CollegePAY", index=0).click()
-        self.assertMatches('...<input type="hidden" name="pay_item_id" value="104" />...',
-                           self.browser.contents)
-        self.assertMatches('...Total Amount Authorized:...',
-                           self.browser.contents)
+        self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />'
+                        in self.browser.contents)
+        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
         self.assertEqual(self.student.current_mode, 'ug_pt')
-        self.assertMatches(
-            '...<input type="hidden" name="amount" value="87600" />...',
-            self.browser.contents)
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="87600" />'
+            in self.browser.contents)
         delta = timedelta(days=8)
         acc_payment.creation_date -= delta
         self.browser.open(self.payments_path + '/xyz')
         self.browser.getLink("CollegePAY", index=0).click()
-        self.assertMatches(
-            '...This payment ticket is too old. Please create a new ticket...',
-            self.browser.contents)
+        self.assertTrue(
+            'This payment ticket is too old. Please create a new ticket'
+            in self.browser.contents)
         delta = timedelta(days=2)
         acc_payment.creation_date += delta
         self.browser.open(self.payments_path + '/xyz')
         self.browser.getLink("CollegePAY", index=0).click()
-        self.assertMatches('...Total Amount Authorized:...',
-                           self.browser.contents)
+        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
 
     @external_test
@@ -230,6 +316,5 @@
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
-        self.assertMatches('...ticket created...',
-                           self.browser.contents)
+        self.assertTrue('ticket created' in self.browser.contents)
         ctrl = self.browser.getControl(name='val_id')
         self.value = ctrl.options[0]
@@ -241,9 +326,7 @@
         # Now we can call the webservice
         self.browser.open(self.payment_url + '/request_webservice')
-        self.assertMatches('...Unsuccessful callback...',
-                          self.browser.contents)
+        self.assertTrue('Unsuccessful callback' in self.browser.contents)
         # The payment is now in state failed ...
-        self.assertMatches('...<span>Failed</span>...',
-                          self.browser.contents)
+        self.assertTrue('<span>Failed</span>' in self.browser.contents)
         # ... and the catalog has been updated
         cat = getUtility(ICatalog, name='payments_catalog')
@@ -261,18 +344,16 @@
         payment.p_id = 'p3547789850240'
         self.browser.open(self.payment_url + '/request_webservice')
-        self.assertMatches('...Callback amount does not match...',
+        self.assertTrue('Callback amount does not match' in
                           self.browser.contents)
         # The payment is now in state failed ...
-        self.assertMatches('...<span>Failed</span>...',
-                          self.browser.contents)
+        self.assertTrue('<span>Failed</span>' in self.browser.contents)
         # Let's replace the amount autorized with the amount of the
         # live system payment
         payment.amount_auth = payment.r_amount_approved
         self.browser.open(self.payment_url + '/request_webservice')
-        self.assertMatches('...Successful payment...',
+        self.assertTrue('Successful payment' in
                           self.browser.contents)
         # The payment is now in state paid ...
-        self.assertMatches('...<span>Paid</span>...',
-                          self.browser.contents)
+        self.assertTrue('<span>Paid</span>' in self.browser.contents)
         # ... and the catalog has been updated
         cat = getUtility(ICatalog, name='payments_catalog')
