Index: /main/waeup.sirp/trunk/src/waeup/sirp/payments/interfaces.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/payments/interfaces.py	(revision 6868)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/payments/interfaces.py	(revision 6869)
@@ -1,4 +1,5 @@
 ##
 ## interfaces.py
+from zope.interface import Attribute, invariant
 from zope import schema
 from waeup.sirp.interfaces import IWAeUPObject
@@ -15,4 +16,5 @@
 
     """
+    p_id = Attribute('Payment identifier.')
 
     p_state = schema.Choice(
@@ -32,20 +34,24 @@
     p_item = schema.TextLine(
         title = u'Payment Item',
-        default = u'Certificate XYZ',
+        default = None,
         required = False,
         )
 
-    date_of_creation = schema.Date(
+    creation_date = schema.Datetime(
         title = u'Ticket Creation Date',
+        readonly = True,
         )
 
-    date_of_payment = schema.Date(
-        title = u'Date of Payment',
+    payment_date = schema.Date(
+        title = u'Payment Date',
+        required = False,
+        readonly = True,
         )
 
     amount_auth = schema.Int(
-        title = u'Amount authorized',
+        title = u'Amount Authorized',
         default = 0,
         required = True,
+        readonly = True,
         )
 
@@ -59,4 +65,5 @@
         default = u'Certificate XYZ',
         required = False,
+        readonly = True,
         )
 
@@ -70,10 +77,12 @@
         default = 0,
         required = False,
+        readonly = True,
         )
 
-    order_id = schema.TextLine(
-        title = u'Order Id',
-        default = None,
-        )
+    #order_id = schema.TextLine(
+    #    title = u'Order Id',
+    #    default = None,
+    #    required = True,
+    #    )
 
     r_amount_approved = schema.Int(
@@ -81,4 +90,5 @@
         default = 0,
         required = False,
+        readonly = True,
         )
 
@@ -86,4 +96,6 @@
         title = u'Response Code',
         default = None,
+        required = False,
+        readonly = True,
         )
 
@@ -91,3 +103,5 @@
         title = u'Response Card Number',
         default = None,
+        required = False,
+        readonly = True,
         )
Index: /main/waeup.sirp/trunk/src/waeup/sirp/payments/payment.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/payments/payment.py	(revision 6868)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/payments/payment.py	(revision 6869)
@@ -18,4 +18,5 @@
 """
 import grok
+from datetime import datetime
 from grok import index
 from zope.component.interfaces import IFactory
@@ -24,4 +25,5 @@
     IPayment, ISCPayment, IOnlinePayment)
 from waeup.sirp.utils.helpers import attrs_to_fields
+from waeup.sirp.payments.vocabularies import payment_states, payment_categories
 
 class Payment(grok.Container):
@@ -34,5 +36,15 @@
     def __init__(self):
         super(Payment, self).__init__()
+        self.creation_date = datetime.now()
+        self.p_id = None
         return
+
+    @property
+    def state(self):
+        return payment_states.getTermByToken(self.p_state).title
+
+    @property
+    def category(self):
+        return payment_categories.getTermByToken(self.p_category).title
 
 class SCPayment(Payment):
@@ -44,4 +56,5 @@
     def __init__(self):
         super(SCPayment, self).__init__()
+        p_id = None
         return
 
@@ -56,4 +69,5 @@
     def __init__(self):
         super(OnlinePayment, self).__init__()
+        p_id = None
         return
 
Index: /main/waeup.sirp/trunk/src/waeup/sirp/payments/vocabularies.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/payments/vocabularies.py	(revision 6868)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/payments/vocabularies.py	(revision 6869)
@@ -4,6 +4,6 @@
 
 payment_states = SimpleWAeUPVocabulary(
-    ('not yet paid','unpaid'),
-    ('paid','paid'),
+    ('Not yet paid','unpaid'),
+    ('Paid','paid'),
     )
 
Index: /main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6868)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6869)
@@ -17,5 +17,6 @@
 """
 import grok
-
+from time import time
+from datetime import date, datetime
 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
 from zope.component import createObject
@@ -30,5 +31,6 @@
 from waeup.sirp.interfaces import IWAeUPObject, IUserAccount
 from waeup.sirp.widgets.datewidget import (
-    FriendlyDateWidget, FriendlyDateDisplayWidget)
+    FriendlyDateWidget, FriendlyDateDisplayWidget,
+    FriendlyDatetimeDisplayWidget)
 from waeup.sirp.students.interfaces import (
     IStudentsContainer, IStudent, IStudentClearance, IStudentPasswordSetting,
@@ -42,4 +44,5 @@
 from waeup.sirp.students.vocabularies import StudyLevelSource
 from waeup.sirp.browser.resources import toggleall
+from waeup.sirp.payments.interfaces import IOnlinePayment
 
 # Save function used for save methods in manager pages
@@ -757,11 +760,129 @@
     grok.require('waeup.viewStudent')
     form_fields = grok.AutoFields(IStudentPaymentsContainer)
-    #grok.template('paymentspage')
+    grok.template('paymentspage')
     title = 'Payments'
     pnav = 4
 
+    def formatDatetime(self,datetimeobj):
+        if isinstance(datetimeobj, datetime):
+            return datetimeobj.strftime("%Y-%m-%d %H:%M:%S")
+        else:
+            return None
+
     @property
     def label(self):
         return '%s: Payments' % self.context.__parent__.fullname
+
+    def update(self):
+        super(PaymentsDisplayFormPage, self).update()
+        datatable.need()
+        return
+
+class PaymentsManageFormPage(WAeUPEditFormPage):
+    """ Page to manage the student payments
+    """
+    grok.context(IStudentPaymentsContainer)
+    grok.name('manage')
+    grok.require('waeup.manageStudents')
+    form_fields = grok.AutoFields(IStudentPaymentsContainer)
+    grok.template('paymentsmanagepage')
+    title = 'Payments'
+    pnav = 4
+
+    def formatDatetime(self,datetimeobj):
+        if isinstance(datetimeobj, datetime):
+            return datetimeobj.strftime("%Y-%m-%d %H:%M:%S")
+        else:
+            return None
+
+    @property
+    def label(self):
+        return '%s: Payments' % self.context.__parent__.fullname
+
+    def update(self):
+        super(PaymentsManageFormPage, self).update()
+        datatable.need()
+        return
+
+    @grok.action('Remove selected tickets')
+    def delPaymentTicket(self, **data):
+        form = self.request.form
+        if form.has_key('val_id'):
+            child_id = form['val_id']
+        else:
+            self.flash('No payment selected.')
+            self.redirect(self.url(self.context, '@@manage'))
+            return
+        if not isinstance(child_id, list):
+            child_id = [child_id]
+        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]))
+        if len(deleted):
+            self.flash('Successfully removed: %s' % ', '.join(deleted))
+        self.redirect(self.url(self.context, u'@@manage'))
+        return
+
+    @grok.action('Add online payment ticket')
+    def addPaymentTicket(self, **data):
+        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 OnlinePaymentAddFormPage(WAeUPAddFormPage):
+    """ Page to add an online payment ticket
+    """
+    grok.context(IStudentPaymentsContainer)
+    grok.name('addop')
+    grok.require('waeup.handleStudent')
+    form_fields = grok.AutoFields(IOnlinePayment).select(
+        'p_category')
+    #grok.template('addpaymentpage')
+    label = 'Add online payment'
+    title = 'Payments'
+    pnav = 4
+
+    @grok.action('Create ticket')
+    def createTicket(self, **data):
+        payment = createObject(u'waeup.OnlinePayment')
+        self.applyData(payment, **data)
+        timestamp = "%d" % int(time()*1000)
+        #order_id = "%s%s" % (student_id[1:],timestamp)
+        payment.p_id = "p%s" % timestamp
+        self.context[payment.p_id] = payment
+        self.flash('Payment ticket created.')
+        self.redirect(self.url(self.context, u'@@manage'))
+        return
+
+class OnlinePaymentDisplayFormPage(WAeUPDisplayFormPage):
+    """ Page to view an online payment ticket
+    """
+    grok.context(IOnlinePayment)
+    grok.name('index')
+    grok.require('waeup.viewStudent')
+    form_fields = grok.AutoFields(IOnlinePayment)
+    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
+    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
+    pnav = 4
+
+    @property
+    def title(self):
+        return 'Online Payment Ticket %s' % self.context.p_id
+
+    @property
+    def label(self):
+        return '%s: Online Payment Ticket %s' % (
+            self.context.__parent__.__parent__.fullname,self.context.p_id)
 
 class AccommodationDisplayFormPage(WAeUPDisplayFormPage):
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 6869)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/paymentsmanagepage.pt	(revision 6869)
@@ -0,0 +1,56 @@
+<h2 i18n:translate=""
+tal:condition="view/label"
+tal:content="view/label">Label</h2>
+
+<div class="form-status"
+    tal:define="status view/status"
+    tal:condition="status">
+    Form Status:
+    <span i18n:translate="" tal:content="view/status">
+      Form status summary
+    </span>
+</div>
+
+<form action="." tal:attributes="action request/URL" method="POST"
+      class="edit-form" enctype="multipart/form-data"> 
+
+  <table class="display dataTableManage">
+    <thead>
+    <tr>
+      <th>&nbsp;</th>
+      <th>Payment Id</th>
+      <th>Creation Date</th>
+      <th>Payment Date</th>
+      <th>Category</th>
+      <th>Item</th>
+      <th>State</th>
+    </tr>
+    </thead>
+    <tbody>
+      <tr tal:repeat="cl context/values">
+         <td>
+          <input type="checkbox"
+    		 name="val_id"
+    		 tal:attributes="value cl/__name__" />
+        </td>
+        <td> <a tal:attributes="href cl/__name__">
+        <span tal:content="cl/p_id">PID</span></a></td>
+        <td tal:content="python: view.formatDatetime(cl.creation_date)">CREATION DATE</td>
+        <td tal:content="python: view.formatDatetime(cl.payment_date)">PAYMENT DATE</td>
+      <td tal:content ="cl/category">CATEGORY</td>
+      <td tal:content ="cl/p_item">ITEM</td>
+      <td tal:content ="cl/state">STATE</td>
+      </tr>
+    </tbody>
+  </table>
+
+  <div class="actionButtons" tal:condition="view/availableActions">
+    <span tal:repeat="action view/actions"
+          tal:omit-tag="">
+      <input tal:replace="structure action/render"/>
+    </span>
+  </div>
+</form>
+
+
+
Index: /main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/paymentspage.pt
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/paymentspage.pt	(revision 6869)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/paymentspage.pt	(revision 6869)
@@ -0,0 +1,28 @@
+<h2 tal:content="view/label">TITLE</h2>
+
+<table class="zebra">
+<thead>
+</thead>
+<table class="display dataTable">
+  <thead>
+    <tr>
+      <th>Payment Id</th>
+      <th>Creation Date</th>
+      <th>Payment Date</th>
+      <th>Category</th>
+      <th>Item</th>
+      <th>State</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr tal:repeat="value context/values">
+      <td> <a tal:attributes="href value/__name__">
+      <span tal:content="value/p_id">PID</span></a></td>
+      <td tal:content="python: view.formatDatetime(value.creation_date)">CREATION DATE</td>
+      <td tal:content="python: view.formatDatetime(value.payment_date)">PAYMENT DATE</td>
+      <td tal:content ="value/category">CATEGORY</td>
+      <td tal:content ="value/p_item">ITEM</td>
+      <td tal:content ="value/state">STATE</td>
+    </tr>
+  </tbody>
+</table>
