Index: main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py	(revision 11651)
+++ main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py	(revision 11652)
@@ -84,5 +84,6 @@
                 self.output = ERROR_PART1 + 'Wrong IP address' + ERROR_PART2
                 return
-        if PAYMENT_TYPE not in ('SCHOOL-FEE', 'ACCEPTANCE-FEE', 'APPLICATION-FEE'):
+        if PAYMENT_TYPE not in ('SCHOOL-FEE-RETURNING', 'SCHOOL-FEE-NEW',
+            'ACCEPTANCE-FEE', 'APPLICATION-FEE'):
             self.output = ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2
             return
@@ -105,4 +106,5 @@
             self.output = ERROR_PART1 + 'Invalid PAYEE_ID' + ERROR_PART2
             return
+        student = results[0].student
         amount = results[0].amount_auth
         payment_type = results[0].category
@@ -114,8 +116,14 @@
             self.output = ERROR_PART1 + 'PAYEE_ID already used' + ERROR_PART2
             return
-        if PAYMENT_TYPE == 'SCHOOL-FEE' \
-            and not results[0].p_category.startswith('schoolfee'):
-            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
-            return
+        if PAYMENT_TYPE.startswith('SCHOOL-FEE'):
+            if not results[0].p_category.startswith('schoolfee'):
+                self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
+                return
+            if PAYMENT_TYPE == 'SCHOOL-FEE-RETURNING' and student.state == CLEARED:
+                self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
+                return
+            if PAYMENT_TYPE == 'SCHOOL-FEE-NEW' and student.state != CLEARED:
+                self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
+                return
         if PAYMENT_TYPE == 'ACCEPTANCE-FEE' \
             and not results[0].p_category == 'clearance':
@@ -140,17 +148,4 @@
             return
         self.output = (
-            # Version 1
-            #'FULL_NAME=%s&' +
-            #'FACULTY=%s&' +
-            #'DEPARTMENT=%s&' +
-            #'RETURN_TYPE=%s&' +
-            #'PROGRAMME_TYPE=%s&' +
-            #'PAYMENT_TYPE=%s&' +
-            #'ACADEMIC_SESSION=%s&' +
-            #'MATRIC_NO=%s&' +
-            #'FEE_AMOUNT=%s&' +
-            #'TRANSACTION_STATUS=%s'
-
-            # Version 2
             'PayeeName=%s~' +
             'Faculty=%s~' +
Index: main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py	(revision 11651)
+++ main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py	(revision 11652)
@@ -84,20 +84,7 @@
     def test_webservice(self):
         self.browser.open(
-            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE'
+            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-NEW'
             % self.p_id)
         self.assertEqual(self.browser.contents,
-            # Version 1
-            #'FULL_NAME=Anna Tester&'
-            #'FACULTY=fac1&'
-            #'DEPARTMENT=dep1&'
-            #'RETURN_TYPE=%s&'
-            #'PROGRAMME_TYPE=CERT1&'
-            #'PAYMENT_TYPE=School Fee&'
-            #'ACADEMIC_SESSION=2004/2005&'
-            #'MATRIC_NO=E1000000&'
-            #'FEE_AMOUNT=1234.0&'
-            #'TRANSACTION_STATUS=unpaid'
-
-            # Version 2
             'PayeeName=Anna Tester~'
             'Faculty=fac1~'
@@ -121,5 +108,5 @@
         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')
+            '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(
@@ -141,8 +128,34 @@
         self.student['payments'][self.p_id].p_state = 'paid'
         self.browser.open(
-            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE'
+            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-NEW'
             % self.p_id)
         self.assertEqual(self.browser.contents, ERROR_PART1 + 'PAYEE_ID already used' + ERROR_PART2)
 
+        IWorkflowState(self.student).setState('returning')
+        self.student['payments'][self.p_id].p_state = 'unpaid'
+        self.browser.open(
+            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-NEW'
+            % 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-RETURNING'
+            % self.p_id)
+
+        self.assertEqual(self.browser.contents,
+            'PayeeName=Anna Tester~'
+            'Faculty=fac1~'
+            'Department=dep1~'
+            'Level=100~'
+            'ProgrammeType=CERT1~'
+            'StudyType=ug_ft~'
+            'Session=2004/2005~'
+            'PayeeID=%s~'
+            'Amount=1234.0~'
+            'FeeStatus=unpaid~'
+            'Semester=N/A~'
+            'PaymentType=School Fee~'
+            'MatricNumber=E1000000~'
+            'Email=aa@aa.ng~'
+            'PhoneNumber=1234' % self.p_id)
 
     @external_test
