Index: /main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py	(revision 13783)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py	(revision 13784)
@@ -85,26 +85,29 @@
                 self.output = ERROR_PART1 + 'Wrong IP address' + ERROR_PART2
                 return
-        if PAYMENT_TYPE not in (
-            'SCHOOL-FEE-NEW',
-            'SCHOOL-FEE-RETURNING',
-            'SCHOOL-FEE-PLUS-NEW',
-            'SCHOOL-FEE-PLUS-RETURNING',
-            'SCHOOL-FEE-PG-NEW',
-            'SCHOOL-FEE-PG-RETURNING',
-            'SCHOOL-FEE-FIRST-INSTALMENT-PLUS',
-            'SCHOOL-FEE-SECOND-INSTALMENT',
-            'SCHOOL-FEE-BALANCE',
-            'ACCEPTANCE-FEE',
-            'ACCEPTANCE-FEE-PLUS',
-            'ACCEPTANCE-FEE-PG',
-            'APPLICATION-FEE',
-            'LATE-REGISTRATION',
-            'AAU-STUDENT-WELFARE-ASSURANCE',
-            'HOSTEL-ACCOMMODATION-FEE',
-            'AAU-LAPEL-FILE-FEE',
-            'MATRICULATION-GOWN-FEE',
-            'CONCESSIONAL-FEE',
-            'STUDENTS-UNION-DUES',
-            'MEDICAL-STUDENT-ASSURANCE-FEE'):
+        category_mapping = {
+            'SCHOOL-FEE-NEW': ('schoolfee',),
+            'SCHOOL-FEE-RETURNING': ('schoolfee',),
+            'SCHOOL-FEE-PLUS-NEW': ('schoolfee_incl',),
+            'SCHOOL-FEE-PLUS-RETURNING': ('schoolfee_incl',),
+            'SCHOOL-FEE-PG-NEW': ('schoolfee',),
+            'SCHOOL-FEE-PG-RETURNING': ('schoolfee',),
+            'SCHOOL-FEE-FIRST-INSTALMENT-PLUS': ('schoolfee_1',),
+            'SCHOOL-FEE-SECOND-INSTALMENT': ('schoolfee_2',),
+            'SCHOOL-FEE-BALANCE': ('schoolfee','schoolfee_incl',
+                                   'schoolfee_1','schoolfee_2'),
+            'ACCEPTANCE-FEE': ('clearance',),
+            'ACCEPTANCE-FEE-PLUS': ('clearance_incl',),
+            'ACCEPTANCE-FEE-PG': ('clearance',),
+            'APPLICATION-FEE': ('application',),
+            'LATE-REGISTRATION': ('late_registration',),
+            'AAU-STUDENT-WELFARE-ASSURANCE': ('welfare',),
+            'HOSTEL-ACCOMMODATION-FEE': ('hostel_maintenance',),
+            'AAU-LAPEL-FILE-FEE': ('lapel',),
+            'MATRICULATION-GOWN-FEE': ('matric_gown',),
+            'CONCESSIONAL-FEE': ('concessional',),
+            'STUDENTS-UNION-DUES': ('union',),
+            }
+
+        if PAYMENT_TYPE not in category_mapping.keys():
             self.output = ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2
             return
@@ -130,4 +133,5 @@
         amount = results[0].amount_auth
         payment_type = results[0].category
+        p_category = results[0].p_category
         programme_type = results[0].p_item
         if not programme_type:
@@ -136,74 +140,32 @@
             results[0].p_session).title
         status = results[0].p_state
+
         if status == 'paid':
             self.output = ERROR_PART1 + 'PAYEE_ID already used' + ERROR_PART2
             return
-        if PAYMENT_TYPE.startswith('SCHOOL-FEE') \
-            and not results[0].p_category.startswith('schoolfee'):
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if '-FIRST' in PAYMENT_TYPE and not '_1' in results[0].p_category:
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if '-SECOND' in PAYMENT_TYPE and not '_2' in results[0].p_category:
+        if p_category not in category_mapping[PAYMENT_TYPE]:
             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
             return
         if student and PAYMENT_TYPE.endswith('-RETURNING') \
             and student.state == CLEARED:
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
+            self.output = ERROR_PART1 + 'Not a returning student' + ERROR_PART2
             return
         if student and PAYMENT_TYPE.endswith('-NEW') \
             and student.state != CLEARED:
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
+            self.output = ERROR_PART1 + 'Not a new student' + ERROR_PART2
             return
         if student and '-PG' in PAYMENT_TYPE and not student.is_postgrad:
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
+            self.output = ERROR_PART1 + 'Not a postgrad student' + ERROR_PART2
+            return
+        if student and '-PG' not in PAYMENT_TYPE and student.is_postgrad:
+            self.output = ERROR_PART1 + 'Postgrad student' + ERROR_PART2
             return
         if '-BALANCE' in PAYMENT_TYPE and results[0].p_item != 'Balance':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if '-PLUS' in PAYMENT_TYPE and not 'incl' in results[0].p_category:
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE.startswith('ACCEPTANCE-FEE') \
-            and not results[0].p_category.startswith('clearance'):
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'LATE-ADMISSION-PROCESSING' \
-            and not results[0].p_category == 'late_registration':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'AAU-STUDENT-WELFARE-ASSURANCE' \
-            and not results[0].p_category == 'welfare':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'HOSTEL-ACCOMMODATION-FEE' \
-            and not results[0].p_category == 'hostel_maintenance':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'AAU-LAPEL-FILE-FEE' \
-            and not results[0].p_category == 'lapel':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'MATRICULATION-GOWN-FEE' \
-            and not results[0].p_category == 'matric_gown':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'CONCESSIONAL-FEE' \
-            and not results[0].p_category == 'concessional':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'STUDENTS-UNION-DUES' \
-            and not results[0].p_category == 'union':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'MEDICAL-STUDENT-ASSURANCE-FEE' \
-            and not results[0].p_category == 'medical':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
-        if PAYMENT_TYPE == 'APPLICATION-FEE' \
-            and not results[0].p_category == 'application':
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
+            self.output = ERROR_PART1 + 'Not a balance payment' + ERROR_PART2
+            return
+        if not '-BALANCE' in PAYMENT_TYPE and results[0].p_item == 'Balance':
+            self.output = ERROR_PART1 + 'Balance payment' + ERROR_PART2
+            return
+
         try:
             owner = IPayer(results[0])
Index: /main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py	(revision 13783)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py	(revision 13784)
@@ -72,4 +72,5 @@
         value2 = ctrl.options[1]
         self.p_id = value2
+        self.payment = self.student['payments'][value2]
         self.browser.getLink(value2).click()
         self.assertMatches('...Amount Authorized...',
@@ -94,5 +95,5 @@
     def test_webservice(self):
         self.browser.open(
-            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-NEW'
+            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-PLUS-NEW'
             % self.p_id)
         self.assertEqual(self.browser.contents,
@@ -115,25 +116,32 @@
         self.browser.open('http://localhost/app/feerequest')
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Missing PAYEE_ID' + ERROR_PART2)
+
         self.browser.open('http://localhost/app/feerequest?NONSENSE=nonsense')
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Missing PAYEE_ID' + ERROR_PART2)
+
         self.browser.open(
             'http://localhost/app/feerequest?PAYEE_ID=nonsense&PAYMENT_TYPE=SCHOOL-FEE-NEW')
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYEE_ID' + ERROR_PART2)
+
         self.browser.open(
             'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=NONSENSE'
             % self.p_id)
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2)
+
         self.browser.open(
             'http://localhost/app/feerequest?PAYEE_ID=%s'
             % self.p_id)
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2)
+
         self.browser.open(
             'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=ACCEPTANCE-FEE'
             % self.p_id)
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2)
+
         self.browser.open(
             'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=APPLICATION-FEE'
             % self.p_id)
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2)
+
         self.student['payments'][self.p_id].p_state = 'paid'
         self.browser.open(
@@ -148,8 +156,27 @@
             % self.p_id)
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2)
+
+        self.browser.open(
+            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-BALANCE'
+            % self.p_id)
+        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Not a balance payment' + ERROR_PART2)
+        self.payment.p_item = u'Balance'
+        self.browser.open(
+            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-PLUS-RETURNING'
+            % self.p_id)
+        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Balance payment' + ERROR_PART2)
+        self.payment.p_item = u'CERT1'
+
+        self.payment.p_category = 'schoolfee'
+        self.certificate.study_mode = 'special_pg_ft'
         self.browser.open(
             'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-RETURNING'
             % self.p_id)
-
+        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Postgrad student' + ERROR_PART2)
+
+        self.certificate.study_mode = 'ug_ft'
+        self.browser.open(
+            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-RETURNING'
+            % self.p_id)
         self.assertEqual(self.browser.contents,
             'PayeeName=Anna Tester~'
@@ -164,5 +191,5 @@
             'FeeStatus=unpaid~'
             'Semester=N/A~'
-            'PaymentType=School Fee Plus~'
+            'PaymentType=School Fee~'
             'MatricNumber=E1000000~'
             'Email=aa@aa.ng~'
