Index: main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 8592)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 8595)
@@ -21,5 +21,4 @@
 import grok
 from urllib import urlencode
-from time import time
 from datetime import datetime
 from copy import deepcopy
@@ -1049,10 +1048,4 @@
     label = _('Add online payment')
     pnav = 4
-    factory = u'waeup.StudentOnlinePayment'
-
-    def _fillCustomFields(self, payment, pay_details):
-        """No custom fields in the base package
-        """
-        return payment
 
     @action(_('Create ticket'), style='primary')
@@ -1069,37 +1062,9 @@
                 return
         students_utils = getUtility(IStudentsUtils)
-        try:
-            pay_details  = students_utils.getPaymentDetails(
-                p_category,student)
-        except (AttributeError, TypeError):
-            self.flash(
-                _('Study course data are incomplete.'))
+        error, payment = students_utils.setPaymentDetails(p_category, student)
+        if error is not None:
+            self.flash(error)
             self.redirect(self.url(self.context))
             return
-        if pay_details['error']:
-            self.flash(pay_details['error'])
-            self.redirect(self.url(self.context))
-            return
-        p_item = pay_details['p_item']
-        p_session = pay_details['p_session']
-        for key in self.context.keys():
-            ticket = self.context[key]
-            if ticket.p_state == 'paid' and\
-               ticket.p_category == p_category and \
-               ticket.p_item == p_item and \
-               ticket.p_session == p_session:
-                  self.flash(
-                      _('This type of payment has already been made.'))
-                  self.redirect(self.url(self.context))
-                  return
-        payment = createObject(self.factory)
-        self.applyData(payment, **data)
-        timestamp = "%d" % int(time()*1000)
-        payment.p_id = "p%s" % timestamp
-        payment.p_item = p_item
-        payment.p_session = p_session
-        payment.p_level = pay_details['p_level']
-        payment.amount_auth = pay_details['amount']
-        payment = self._fillCustomFields(payment, pay_details)
         self.context[payment.p_id] = payment
         self.flash(_('Payment ticket created.'))
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 8592)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 8595)
@@ -64,7 +64,7 @@
         """
 
-    def getPaymentDetails(category, student):
-        """Get the payment dates of a student for the payment category
-        specified.
+    def setPaymentDetails(category, student):
+        """Create Payment object and set the payment data of a student for
+        the payment category specified.
 
         """
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 8592)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 8595)
@@ -20,7 +20,8 @@
 import grok
 from random import SystemRandom as r
+from time import time
 from datetime import datetime
 from zope.i18n import translate
-from zope.component import getUtility
+from zope.component import getUtility, createObject
 from reportlab.pdfgen import canvas
 from reportlab.lib import colors
@@ -252,45 +253,64 @@
         return
 
-    def getPaymentDetails(self, category, student):
-        """Get the payment data of a student for the payment category
-        specified.
-        """
+    def setPaymentDetails(self, category, student):
+        """Create Payment object and set the payment data of a student for
+        the payment category specified.
+
+        """
+        factory = u'waeup.StudentOnlinePayment'
         details = {}
-        details['p_item'] = u''
-        details['amount'] = 0.0
-        details['error'] = u''
-        details['p_session'] = student['studycourse'].current_session
-        details['p_level'] = student['studycourse'].current_level
-        session = str(details['p_session'])
+        p_item = u''
+        amount = 0.0
+        error = u''
+        p_session = student['studycourse'].current_session
+        p_level = student['studycourse'].current_level
+        session = str(p_session)
         try:
             academic_session = grok.getSite()['configuration'][session]
         except KeyError:
-            details['error'] = _(u'Session configuration object is not available.')
-            return details
+            return _(u'Session configuration object is not available.'), None
         if category == 'schoolfee':
-            details['amount'] = getattr(
-                student['studycourse'].certificate,'school_fee_1')
-            details['p_item'] = student['studycourse'].certificate.code
+            try:
+                amount = getattr(
+                    student['studycourse'].certificate,'school_fee_1')
+                p_item = student['studycourse'].certificate.code
+            except (AttributeError, TypeError):
+                return _('Study course data are incomplete.'), None
             if student.state == RETURNING:
                 # In case of returning school fee payment the payment session
                 # and level contain the values of the session the student
                 # has paid for.
-                details['p_session'], details[
-                    'p_level'] = self.getReturningData(student)
+                p_session, p_level = self.getReturningData(student)
             elif student.is_postgrad and student.state == PAID:
                 # Returning postgraduate students also pay for the next session
                 # but their level always remains the same.
-                details['p_session'] += 1
-                details['amount'] = getattr(
+                p_session += 1
+                amount = getattr(
                     student['studycourse'].certificate,'school_fee_2')
         elif category == 'clearance':
-            details['p_item'] = student['studycourse'].certificate.code
-            details['amount'] = academic_session.clearance_fee
+            p_item = student['studycourse'].certificate.code
+            amount = academic_session.clearance_fee
         elif category == 'bed_allocation':
-            details['p_item'] = self.getAccommodationDetails(student)['bt']
-            details['amount'] = academic_session.booking_fee
-        if details['amount'] in (0.0, None):
-            details['error'] = _(u'Amount could not be determined.')
-        return details
+            p_item = self.getAccommodationDetails(student)['bt']
+            amount = academic_session.booking_fee
+        if amount in (0.0, None):
+            return _(u'Amount could not be determined.'), None
+        for key in student['payments'].keys():
+            ticket = student['payments'][key]
+            if ticket.p_state == 'paid' and\
+               ticket.p_category == category and \
+               ticket.p_item == p_item and \
+               ticket.p_session == p_session:
+                  return _('This type of payment has already been made.'), None
+        payment = createObject(factory)
+        #self.applyData(payment, **data)
+        timestamp = "%d" % int(time()*1000)
+        payment.p_id = "p%s" % timestamp
+        payment.p_category = category
+        payment.p_item = p_item
+        payment.p_session = p_session
+        payment.p_level = p_level
+        payment.amount_auth = amount
+        return None, payment
 
     def getAccommodationDetails(self, student):
