Index: /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/payments.py
===================================================================
--- /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/payments.py	(revision 14339)
+++ /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/payments.py	(revision 14340)
@@ -47,4 +47,57 @@
         return self.__parent__.__parent__
 
+    def redeemTicket(self):
+        """Either create an appropriate access code or trigger an action
+        directly.
+        """
+        student = self.student
+        if self.p_category == 'clearance':
+            # Create CLR access code
+            pin, error = create_accesscode(
+                'CLR',0,self.amount_auth,student.student_id)
+            if error:
+                return error
+            self.ac = pin
+        elif self.p_category.startswith('schoolfee'):
+            # Bypass activation code creation if next session
+            # can be started directly.
+            if student['studycourse'].next_session_allowed:
+                try:
+                    if student.state == CLEARED:
+                        IWorkflowInfo(student).fireTransition(
+                            'pay_first_school_fee')
+                        return None
+                    elif student.state == RETURNING:
+                        IWorkflowInfo(student).fireTransition(
+                            'pay_school_fee')
+                        return None
+                    elif student.state == PAID:
+                        IWorkflowInfo(student).fireTransition(
+                            'pay_pg_fee')
+                        return None
+                except ConstraintNotSatisfied:
+                    pass
+            # Create SFE access code
+            pin, error = create_accesscode(
+                'SFE',0,self.amount_auth,student.student_id)
+            if error:
+                return error
+            self.ac = pin
+        elif self.p_category == 'bed_allocation':
+            # Create HOS access code
+            pin, error = create_accesscode(
+                'HOS',0,self.amount_auth,student.student_id)
+            if error:
+                return error
+            self.ac = pin
+        elif self.p_category == 'transcript':
+            # Create TSC access code
+            pin, error = create_accesscode(
+                'TSC',0,self.amount_auth,student.student_id)
+            if error:
+                return error
+            self.ac = pin
+        return None
+
 CustomStudentOnlinePayment = attrs_to_fields(
     CustomStudentOnlinePayment, omit=['display_item'])
