Index: main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6939)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6940)
@@ -48,4 +48,5 @@
 from waeup.sirp.students.utils import getPaymentDetails
 from waeup.sirp.browser.resources import toggleall
+from waeup.sirp.authentication import get_principal_role_manager
 
 # Save function used for save methods in manager pages
@@ -770,9 +771,10 @@
         return
 
+# We don't need the display form page yet
 class PaymentsDisplayFormPage(WAeUPDisplayFormPage):
     """ Page to display the student payments
     """
     grok.context(IStudentPaymentsContainer)
-    grok.name('index')
+    grok.name('view')
     grok.require('waeup.viewStudent')
     form_fields = grok.AutoFields(IStudentPaymentsContainer)
@@ -796,14 +798,20 @@
         return
 
+# This manage form page is for both students and students officers.
 class PaymentsManageFormPage(WAeUPEditFormPage):
     """ Page to manage the student payments
     """
     grok.context(IStudentPaymentsContainer)
-    grok.name('manage')
-    grok.require('waeup.manageStudents')
+    grok.name('index')
+    grok.require('waeup.handleStudent')
     form_fields = grok.AutoFields(IStudentPaymentsContainer)
     grok.template('paymentsmanagepage')
     title = 'Payments'
     pnav = 4
+
+    def unremovable(self, ticket):
+        prm = get_principal_role_manager()
+        roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)]
+        return ('waeup.Student' in roles and ticket.r_code)
 
     def formatDatetime(self,datetimeobj):
@@ -829,5 +837,5 @@
         else:
             self.flash('No payment selected.')
-            self.redirect(self.url(self.context, '@@manage'))
+            self.redirect(self.url(self.context))
             return
         if not isinstance(child_id, list):
@@ -835,13 +843,15 @@
         deleted = []
         for id in child_id:
-            try:
-                del self.context[id]
-                deleted.append(id)
-            except:
-                self.flash('Could not delete %s: %s: %s' % (
-                        id, sys.exc_info()[0], sys.exc_info()[1]))
+            # Students are not allowed to remove payment used tickets
+            if not self.unremovable(self.context[id]):
+                try:
+                    del self.context[id]
+                    deleted.append(id)
+                except:
+                    self.flash('Could not delete %s: %s: %s' % (
+                            id, sys.exc_info()[0], sys.exc_info()[1]))
         if len(deleted):
             self.flash('Successfully removed: %s' % ', '.join(deleted))
-        self.redirect(self.url(self.context, u'@@manage'))
+        self.redirect(self.url(self.context))
         return
 
@@ -850,11 +860,11 @@
         self.redirect(self.url(self.context, '@@addop'))
 
-class OnlinePaymentManageActionButton(ManageActionButton):
-    grok.order(1)
-    grok.context(IStudentPaymentsContainer)
-    grok.view(PaymentsDisplayFormPage)
-    grok.require('waeup.manageStudents')
-    text = 'Manage payments'
-    target = 'manage'
+#class OnlinePaymentManageActionButton(ManageActionButton):
+#    grok.order(1)
+#    grok.context(IStudentPaymentsContainer)
+#    grok.view(PaymentsDisplayFormPage)
+#    grok.require('waeup.manageStudents')
+#    text = 'Manage payments'
+#    target = 'manage'
 
 class OnlinePaymentAddFormPage(WAeUPAddFormPage):
@@ -887,9 +897,9 @@
         if error:
             self.flash(error)
-            self.redirect(self.url(self.context, u'@@manage'))
+            self.redirect(self.url(self.context))
             return
         self.context[payment.p_id] = payment
         self.flash('Payment ticket created.')
-        self.redirect(self.url(self.context, u'@@manage'))
+        self.redirect(self.url(self.context))
         return
 
@@ -935,19 +945,19 @@
             pin, error = create_accesscode('CLR',0,student.student_id)
             if error:
-                self.flash(error)
+                self.flash('Valid callback received. ' + error)
                 return
             self.context.ac = pin
-            return
         elif self.context.p_category == 'schoolfee':
             # Create SFE access code
-            pin, error = create_accesscode('SFE',0)
+            pin, error = create_accesscode('SFE',0,student.student_id)
             if error:
-                self.flash(error)
+                self.flash('Valid callback received. ' + error)
                 return
             self.context.ac = pin
-            return
+        self.flash('Valid callback received.')
+        return
 
     def render(self):
-        self.redirect(self.url(self.context))
+        self.redirect(self.url(self.context, '@@index'))
         return
 
@@ -1335,5 +1345,5 @@
         deleted = []
         for id in child_id:
-            # Student are not allowed to remove core tickets
+            # Students are not allowed to remove core tickets
             if not self.context[id].core_or_elective:
                 try:
Index: main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/paymentsmanagepage.pt
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/paymentsmanagepage.pt	(revision 6939)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/paymentsmanagepage.pt	(revision 6940)
@@ -32,5 +32,6 @@
           <input type="checkbox"
     		 name="val_id"
-    		 tal:attributes="value cl/__name__" />
+    		 tal:attributes="value cl/__name__"
+         tal:condition="python: not view.unremovable(cl)" />
         </td>
         <td> <a tal:attributes="href cl/__name__">
@@ -52,5 +53,2 @@
   </div>
 </form>
-
-
-
Index: main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 6939)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 6940)
@@ -662,5 +662,5 @@
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.payments_student_path)
-        self.browser.getLink("Manage").click()
+        #self.browser.getLink("Manage").click()
         self.browser.getControl("Add online payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
@@ -674,5 +674,5 @@
                            self.browser.contents)
         self.browser.open(self.payments_student_path)
-        self.browser.getLink('Manage').click()
+        #self.browser.getLink('Manage').click()
         self.browser.getControl("Remove selected").click()
         self.assertMatches('...No payment selected...', self.browser.contents)
