Index: /WAeUP_SRP/trunk/Payment.py
===================================================================
--- /WAeUP_SRP/trunk/Payment.py	(revision 1224)
+++ /WAeUP_SRP/trunk/Payment.py	(revision 1224)
@@ -0,0 +1,67 @@
+#-*- mode: python; mode: fold -*-
+from Globals import InitializeClass
+from AccessControl import ClassSecurityInfo
+
+from Products.CMFCore.utils import UniqueObject, getToolByName
+from Products.CMFCore.permissions import View
+from Products.CMFCore.permissions import ModifyPortalContent
+from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder
+#from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument
+from Products.CPSDocument.CPSDocument import CPSDocument
+from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
+from Products.WAeUP_SRP.WAeUPTables import AccommodationTable
+import Globals
+import DateTime
+import re
+p_home = Globals.package_home(globals())
+i_home = Globals.INSTANCE_HOME
+
+class PaymentsFolder(CPSDocument): ###(
+    """
+    WAeUP PaymentsFolder containing Paymentsmmodation halls
+    """
+    meta_type = 'PaymentsFolder'
+    portal_type = meta_type
+    security = ClassSecurityInfo()
+
+    security.declareProtected(View,"Title")
+    def Title(self):
+        """compose title"""
+        return "Payments Section"
+
+###)
+
+InitializeClass(PaymentsFolder)
+
+def addPaymentsFolder(container, id, REQUEST=None, **kw):
+    """Add a PaymentsFolder."""
+    ob = PaymentsFolder(id, **kw)
+    return CPSBase_adder(container, ob, REQUEST=REQUEST)
+###)
+
+class Payment(CPSDocument): ###(
+    """
+    WAeUP Payment containing Departments
+    """
+    meta_type = 'Payment'
+    portal_type = meta_type
+    security = ClassSecurityInfo()
+
+    security.declareProtected(View,"Title") ###(
+    def Title(self):
+        """compose title"""
+        content = self.getContent()
+        heading = getattr(content,'heading',None)
+        if heading is None:
+            return self.title
+        return heading
+
+###)
+
+InitializeClass(Payment)
+
+def addPayment(container, id, REQUEST=None, **kw):
+    """Add a Payment."""
+    ob = Payment(id, **kw)
+    return CPSBase_adder(container, ob, REQUEST=REQUEST)
+###)
Index: /WAeUP_SRP/trunk/profiles/default/layouts/payment.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/payment.xml	(revision 1224)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/payment.xml	(revision 1224)
@@ -0,0 +1,106 @@
+<?xml version="1.0"?>
+<object name="payment" meta_type="CPS Layout">
+ <property name="layout_create_method"></property>
+ <property name="layout_edit_method"></property>
+ <property name="layout_view_method"></property>
+ <property name="style_prefix">layout_waeup_</property>
+ <property name="flexible_widgets"/>
+ <property name="validate_values_expr"></property>
+ <property name="label"></property>
+ <property name="label_edit"></property>
+ <property name="is_i18n">False</property>
+ <widget name="amount" meta_type="Float Widget">
+  <property name="title">Amount Payed</property>
+  <property name="fields">
+   <element value="amount"/>
+  </property>
+  <property name="label">Amount Payed</property>
+  <property name="label_edit">Amount Payed</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="decimals_number">2</property>
+ </widget>
+ <widget name="date" meta_type="DateTime Widget">
+  <property name="title">Payment Date</property>
+  <property name="fields">
+   <element value="date"/>
+  </property>
+  <property name="label">Payment Date</property>
+  <property name="label_edit">Payment Date</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <widget name="order_id" meta_type="String Widget">
+  <property name="title">Order Id</property>
+  <property name="fields">
+   <element value="order_id"/>
+  </property>
+  <property name="label">Order Id</property>
+  <property name="label_edit">Order Id</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="display_width">20</property>
+ </widget>
+ <widget name="resp_approved_amount" meta_type="String Widget">
+  <property name="title">Approved Amount</property>
+  <property name="fields">
+   <element value="resp_approved_amt"/>
+  </property>
+  <property name="label">Approved Amount</property>
+  <property name="label_edit">Approved Amount</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="display_width">120</property>
+ </widget>
+ <widget name="resp_card_num" meta_type="String Widget">
+  <property name="title">Card Nr Used</property>
+  <property name="fields">
+   <element value="resp_card_num"/>
+  </property>
+  <property name="label">Card Used</property>
+  <property name="label_edit">Card Used</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="display_width">20</property>
+ </widget>
+ <widget name="resp_code" meta_type="String Widget">
+  <property name="title">Response Code</property>
+  <property name="fields">
+   <element value="resp_code"/>
+  </property>
+  <property name="label">Response Code</property>
+  <property name="label_edit">Response Code</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <widget name="resp_desc" meta_type="String Widget"/>
+ <widget name="type_code" meta_type="String Widget">
+  <property name="title">Payment Type Code</property>
+  <property name="fields">
+   <element value="type_code"/>
+  </property>
+  <property name="label">Payment Type Code</property>
+  <property name="label_edit">Payment Type Code</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <widget name="type_description" meta_type="String Widget">
+  <property name="title">Payment Type Description</property>
+  <property name="fields">
+   <element value="type_description"/>
+  </property>
+  <property name="label">Payment Type Description</property>
+  <property name="label_edit">Payment Type Description</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+ </widget>
+ <table/>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/payment.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/payment.xml	(revision 1224)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/payment.xml	(revision 1224)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<object name="payment" meta_type="CPS Schema">
+ <field name="date" meta_type="CPS DateTime Field"/>
+ <field name="type_code" meta_type="CPS String Field"/>
+ <field name="type_description" meta_type="CPS String Field"/>
+ <field name="order_id" meta_type="CPS String Field"/>
+ <field name="transaction_code" meta_type="CPS String Field"/>
+ <field name="pay_type" meta_type="CPS String Field"/>
+ <field name="amount" meta_type="CPS Float Field"/>
+ <field name="amount" meta_type="CPS Float Field"/>
+ <field name="resp_desc" meta_type="CPS String Field"/>
+ <field name="resp_code" meta_type="CPS String Field"/>
+ <field name="resp_card_num" meta_type="CPS String Field"/>
+ <field name="resp_approved_amount" meta_type="CPS String Field"/>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/types.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types.xml	(revision 1223)
+++ /WAeUP_SRP/trunk/profiles/default/types.xml	(revision 1224)
@@ -12,4 +12,6 @@
  <object name="Department" meta_type="CPS Flexible Type Information"/>
  <object name="Faculty" meta_type="CPS Flexible Type Information"/>
+ <object name="PaymentsFolder" meta_type="CPS Flexible Type Information"/>
+ <object name="Payment" meta_type="CPS Flexible Type Information"/>
  <object name="ScratchCardBatch" meta_type="CPS Flexible Type Information"/>
  <object name="ScratchCardBatchesFolder" meta_type="CPS Flexible Type Information"/>
Index: /WAeUP_SRP/trunk/profiles/default/types/Payment.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/Payment.xml	(revision 1224)
+++ /WAeUP_SRP/trunk/profiles/default/types/Payment.xml	(revision 1224)
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<object name="Payment" meta_type="CPS Flexible Type Information"
+   xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title">Payment Data</property>
+ <property name="description"></property>
+ <property name="content_icon"></property>
+ <property name="content_meta_type">Payment</property>
+ <property name="product">WAeUP_SRP</property>
+ <property name="factory">addPayment</property>
+ <property name="immediate_view">waeup_document_view</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <property name="cps_is_searchable">False</property>
+ <property name="cps_proxy_type">folder</property>
+ <property name="cps_display_as_document_in_listing">True</property>
+ <property name="schemas">
+  <element value="payment"/>
+ </property>
+ <property name="layouts">
+  <element value="payment"/>
+ </property>
+ <property name="layout_clusters"/>
+ <property name="flexible_layouts"/>
+ <property name="storage_methods"/>
+ <property name="cps_is_portlet">False</property>
+ <alias from="(Default)" to="student_index"/>
+ <alias from="view" to="student_index"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+    url_expr="string:${object_url}/student_index" visible="True">
+  <permission value="View"/>
+ </action>
+ <action title="action_edit" action_id="edit" category="object"
+    condition_expr="" url_expr="string:${object_url}/waeup_edit_form"
+    visible="False">
+  <permission value="Modify portal content"/>
+ </action>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/types/PaymentsFolder.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/PaymentsFolder.xml	(revision 1224)
+++ /WAeUP_SRP/trunk/profiles/default/types/PaymentsFolder.xml	(revision 1224)
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<object name="PaymentsFolder" meta_type="CPS Flexible Type Information"
+   xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title">WAeUP Payments Folder</property>
+ <property name="description"></property>
+ <property name="content_icon"></property>
+ <property name="content_meta_type">PaymentsFolder</property>
+ <property name="product">WAeUP_SRP</property>
+ <property name="factory">addPaymentsFolder</property>
+ <property name="immediate_view">payments_folder_index</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types">
+  <element value="Payment"/>
+ </property>
+ <property name="allow_discussion">False</property>
+ <property name="cps_is_searchable">True</property>
+ <property name="cps_proxy_type">btreefolder</property>
+ <property name="cps_display_as_document_in_listing">True</property>
+ <property name="schemas">
+  <element value="metadata"/>
+  <element value="common"/>
+ </property>
+ <property name="layouts"/>
+ <property name="layout_clusters"/>
+ <property name="flexible_layouts"/>
+ <property name="storage_methods"/>
+ <property name="cps_is_portlet">False</property>
+ <alias from="(Default)" to="acco_folder_index"/>
+ <alias from="view" to="acco_folder_index"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+    url_expr="string:${object_url}/acco_folder_index" visible="True">
+  <permission value="View"/>
+ </action>
+ <action title="Add Hall" action_id="new_entry" category="object"
+    condition_expr=""
+    url_expr="string:${object_url}/content_create?type_name=AccoHall"
+    visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+ <action title="Update Bed List" action_id="new_bed_list" category="object"
+    condition_expr="" url_expr="string:${object_url}/generateFreeBedsList"
+    visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+ <action title="Delegate" action_id="localroles" category="object"
+    condition_expr="here/isSectionOfficer"
+    url_expr="string:${object_url}/folder_localrole_form" visible="True">
+  <permission value="Modify portal content"/>
+ </action>
+</object>
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/epayment_cb.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/epayment_cb.py	(revision 1224)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/epayment_cb.py	(revision 1224)
@@ -0,0 +1,41 @@
+## Script (Python) "epayment_cb"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+payment callback
+"""
+import logging
+logger = logging.getLogger('EPayment.')
+import DateTime
+
+request = context.REQUEST
+students = context.portal_url.getPortalObject().campus.students
+
+student_id = context.getStudentId()
+if student_id is None:
+    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+
+student = getattr(students,student_id)
+sbrain = context.students_catalog(id=student_id)[0]
+res = context.portal_catalog(portal_type="Certificate",
+                                     id = sbrain.course)
+if not res:
+    return None
+
+resp_codes = (("x_RespDesc","resp_description"),
+              ("x_RespPayRef","resp_pay_reference"),
+              ("x_RespCode","resp_code"),
+              ("x_CardNum","resp_card_num"),
+              ("x_ApprAmt","resp_approved_amount"),
+              )
+pd = []
+for rc,pdk in resp_codes:
+    pd[pdk] = request.get(rc)
+context.getContent().edit(mapping=pdk)
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/pay_online.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/pay_online.py	(revision 1223)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/pay_online.py	(revision 1224)
@@ -15,4 +15,5 @@
 logger = logging.getLogger('EPayment.')
 import DateTime
+import time
 
 request = context.REQUEST
@@ -31,13 +32,31 @@
 sfc = res[0].getObject().getContent().school_fee_code
 info = {}
-info['callback_url'] = "%s/epayment_cb" % student.absolute_url()
-info['payment_type_code'] = sfc
-info['payment_type_description'] = "Schoolfee %s for 2006/2007 Session" % sfc
-info['payment_bill_to'] = sbrain.name
-info['payment_ship_to'] = "University of Benin"
+info['type_code'] = "ART" #sfc
+info['type_description'] = "Schoolfee %s for 2006/2007 Session" % sfc
+info['pay_bill_to'] = sbrain.name
+info['pay_ship_to'] = "University of Benin"
 info['student_id'] = student_id
 info['student_name'] = sbrain.name
 info['student_email'] = sbrain.email
-info['order_id'] = "%s%s" % (student_id[1:],DateTime.DateTime().strftime("%d%m%y%H%M%S"))
+info['pay_date'] = DateTime.DateTime().strftime("%d%m%y%H%M%S")
+order_id = info['order_id'] = "%d" % int(time.time()*1000)
+info['order_id'] = "%s%s" % (student_id[1:],order_id)
 info['amount'] = "75000"
+if "payments" not in student.objectIds():
+    student.invokeFactory('PaymentsFolder','payment')
+    payments = getattr(student,'payments')
+    d = {}
+    d['Title'] = 'Online Payments'
+    payment.getContent().edit(mapping=d)
+else:
+    payments = getattr(student,'payments')
+p_id = "p%s" % order_id
+payments.invokeFactory('Payment', p_id)
+payment = getattr(payments,p_id)
+d = {}
+d.update(info)
+d['Title'] = "%(payment_type_description)s %(pay_date) %(amount)s N" % info
+payment.getContent().edit(mapping=d)
+info['callback_url'] = "%s/payments/%s/epayment_cb" % (student.absolute_url(),p_id)
+logger.info('"%(student_id)s","%(payment_type_description)s", "%(amount)s N"' % info)
 return context.wema_form(info=info)
