Index: /WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py
===================================================================
--- /WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py	(revision 2644)
+++ /WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py	(revision 2644)
@@ -0,0 +1,116 @@
+## Script (Python) "getPaymentsFolderInfo"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id: getPaymentsFolderInfo.py 2480 2007-10-30 15:23:25Z joachim $
+"""
+Info for the PaymentsFolder
+"""
+
+mtool = context.portal_membership
+if mtool.isAnonymousUser():
+    return None
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+
+
+#import logging
+#logger = logging.getLogger('Skins.getPaymentsFolderInfo')
+def cmp_id(a,b):
+    s1 = "%(id)s" % a
+    s2 = "%(id)s" % b
+    if s1 == s2:
+        return 0
+    if s1 > s2:
+        return 1
+    return -1
+
+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)
+s_brain = context.students_catalog(id = student_id)[0]
+
+payments = []
+#from Products.zdb import set_trace;set_trace()
+
+info = {}
+is_so = info['is_so'] = context.isSectionOfficer()
+is_student = info['is_student'] = context.isStudent()
+info['student_name'] = s_brain.name
+info['query_url'] = "https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx"
+review_state = info['review_state'] = s_brain.review_state
+parttime = s_brain.mode and s_brain.mode.endswith('_pt')
+fulltime = s_brain.mode and s_brain.mode.endswith('_ft')
+
+#if review_state == 'cleared_and_validated' or (parttime and review_state == 'returning'):
+#    online_payment = True
+#elif fulltime and review_state == 'returning':
+#    sc_payment = True
+
+session = s_brain.session
+next_info = context.getNextInfo(s_brain)
+info['next_session'] = next_info['next_session_id']
+info['next_session_str'] = next_info['next_session_str']
+info['payment_method'] = ""
+info['reasons'] = next_info['reasons']
+
+
+
+if review_state in ('cleared_and_validated','returning'):
+    info['payment_method'] = "online_payment"
+
+info['prod_id'] = '61'
+
+info['student_name'] = s_brain.name
+payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
+sos = context.portal_catalog(container_path=payments_path)
+info['is_so'] = is_so
+
+for so in sos:
+    row = {}
+    row['id'] = so.getId
+    row['title'] = so.Title
+    url = row['url'] = "%s/%s" % (payments_path,so.getId)
+    so_doc = context.restrictedTraverse(url,default=None).getContent()
+    row['type'] = so.portal_type
+    review_state = row['review_state'] = so.review_state
+    if so_doc.type_description.startswith('School Fee'):
+        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] in ('cleared_and_validated','returning')
+    else:
+        row['is_approvable'] = is_so and (review_state == "opened")
+    row['is_requeryable'] = False
+    #set_trace()
+    row['resp_desc'] = getattr(so_doc,'resp_desc','no response')
+    row['trans_ref'] = getattr(so_doc,'order_id','')
+    if so_doc.type_description.startswith('School Fee'):
+        if review_state == 'opened' and info['review_state'] == 'cleared_and_validated' and hasattr(so_doc, 'order_id') and not so_doc.resp_code:
+            row['is_requeryable'] = True
+            row['callback_url'] = "%s/payments/%s/interswitch_cb" % (student.absolute_url(),
+                                                            so.getId)
+            href = '%(query_url)s' % info
+            href += '?transRef=%(trans_ref)s' % row
+            href += '&prodID=%(prod_id)s' % info
+            href += '&redirectURL=%(callback_url)s' % row
+            row['href'] = href
+    if (review_state == "closed") and so_doc.resp_code in ('SC','00','AP','IP',):
+        row['confirmed'] = 'active'
+    else:
+        row['confirmed'] = 'unsuccessful'
+    payments.append(row)
+
+payments.sort(cmp_id)
+info['payments'] = payments
+return info
+
Index: /WAeUP_SRP/fceokene/waeup_custom/getSchoolFee.py
===================================================================
--- /WAeUP_SRP/fceokene/waeup_custom/getSchoolFee.py	(revision 2644)
+++ /WAeUP_SRP/fceokene/waeup_custom/getSchoolFee.py	(revision 2644)
@@ -0,0 +1,45 @@
+## Script (Python) "getSchoolFee"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=brain=None
+##title=
+##
+# $Id: getSchoolFee.py 2534 2007-11-05 06:37:12Z henrik $
+"""
+return SchoolFee
+"""
+
+
+ARTS = ('CRS','ISS','HIS','MUS','ECO','GEO','POL','SOS','CCA','ECU','THA','GED','GSE','PES','SPC','ENG ','FRE','ARB','HAU','IGB','YOR','FAA')
+
+# SCS = ('BIO','CHE','HED','MAT','PED','PHY ','CSC','ISC','PHE','AGE','BED','HEC','TED')
+
+d = {}
+if str(brain.level) == '100':
+    if brain.department in ARTS:
+        d['all'] = 11520
+    else:    
+        d['all'] = 11995
+elif str(brain.level) == '200':
+    if brain.department in ARTS:
+        d['all'] = 10520
+    else:    
+        d['all'] = 11045
+elif str(brain.level) == '300':
+    if brain.department in ARTS:
+        d['all'] = 10570
+    else:    
+        d['all'] = 11045  
+else: 
+    d['all'] = 0          
+         
+         
+next_info = context.getNextInfo(brain)
+next_session_str = next_info['next_session_str']
+d['description'] = "School Fee for Session %s" % next_session_str
+                
+return d
+
Index: /WAeUP_SRP/fceokene/waeup_custom/pay_interswitch.py
===================================================================
--- /WAeUP_SRP/fceokene/waeup_custom/pay_interswitch.py	(revision 2644)
+++ /WAeUP_SRP/fceokene/waeup_custom/pay_interswitch.py	(revision 2644)
@@ -0,0 +1,160 @@
+## Script (Python) "pay_online"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id: pay_interswitch.py 2619 2007-11-10 17:39:36Z henrik $
+"""
+pay online
+"""
+from urllib import urlencode
+import logging
+logger = logging.getLogger('Skins.pay_interswitch')
+import DateTime
+
+if context.portal_membership.isAnonymousUser():
+    return None
+
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+request = context.REQUEST
+wftool = context.portal_workflow
+students = context.portal_url.getPortalObject().campus.students
+
+
+student_id = context.getStudentId()
+student = getattr(students,student_id)
+
+sbrain = context.students_catalog(id=student_id)[0]
+#amount,description = context.getSchoolFee(sbrain.faculty,sbrain.session,sbrain.course)
+info = {}
+info['student'] = sbrain
+info['payment_possible'] = False
+info['amount'] = '0'
+info['bank'] = ''
+info['type_description'] = ''
+info['pay_bill_to'] = ''
+fee_dict = context.getSchoolFee(sbrain)
+fulltime = sbrain.mode.endswith('_ft')
+
+# begin customization
+
+if not fee_dict:
+    return context.interswitch_form(info=info)
+amount = info['amount'] = fee_dict['all']
+
+# end customization
+
+
+info['site_id'] = '61'
+info['currency_id'] = '566'
+
+pay_item_id = "6101"
+info['type_code'] = sbrain.course  #type_code is redundant and will be removed soon
+info['bank'] = ''
+info['payment_possible'] = True
+info['type_description'] = fee_dict['description']
+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
+now = DateTime.DateTime()
+info['date'] = now
+timestamp = "%d" % int(now.timeTime()*1000)
+info['order_id'] = "%s%s" % (student_id[1:],timestamp)
+p_id = "p%s" % timestamp
+
+if student_id is None:
+    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+
+if True or context.portal_url().find('uniben-demo.waeup.org') >-1 or\
+   context.portal_url().find('uniben.waeup.org') >-1:
+    info['action'] = "https://webpay.interswitchng.com/paydirect/webpay/pay.aspx"
+else:
+    #pass
+    #return None
+    info['action'] = "%s/payments/%s/simulate_callback" % (student.absolute_url(),p_id)
+
+
+if "payments" not in student.objectIds():
+    student.invokeFactory('PaymentsFolder','payments')
+    payments = getattr(student,'payments')
+    d = {}
+    d['Title'] = 'Payments'
+    payments.getContent().edit(mapping=d)
+    wftool.doActionFor(payments,'open')
+else:
+    payments = getattr(student,'payments')
+if request.has_key('epayment'):
+    return context.interswitch_form(info=info)
+
+
+payments.invokeFactory('Payment', p_id)
+payment = getattr(payments,p_id)
+wftool.doActionFor(payment,'open')
+d = {}
+d.update(info)
+#from Products.zdb import set_trace;set_trace()
+payment.getContent().edit(mapping=d)
+#wftool.doActionFor(payment,'close')
+#wftool.doActionFor(student,'pay_school_fee')
+info['callback_url'] = "%s/payments/%s/interswitch_cb?echo=%s" % (student.absolute_url(),
+                                                                  p_id,
+                                                                  p_id)
+
+logger.info('%(student_id)s initiated online school fee payment with order_id %(order_id)s and callback url %(callback_url)s' % info)
+payment_fields = (('product_id','site_id'),
+                  ('site_redirect_url','callback_url'),
+                  ('Currency','currency_id'),
+                  ('cust_id','student_id'),
+                  ('cust_id_desc','type_description'),
+                  ('cust_name','student_name'),
+                  ('txn_ref','order_id'),
+                  ('Amount','amount'),
+                  )
+args = {}
+for arg,field in payment_fields:
+    args[arg] = info[field]
+itotal = int(amount)*100
+wema_amount = 10000
+provider_amount = 35000
+interswitch_amount = 15000
+#uniben_amount = itotal - wema_amount - provider_amount - interswitch_amount
+uniben_amount = itotal - interswitch_amount
+xmldict = {}
+xmldict['detail_ref'] = args['txn_ref']
+xmldict['department'] = sbrain.department
+xmldict['faculty'] = sbrain.faculty
+#xmldict['wema_amt'] = "%d" % wema_amount
+#xmldict['provider_amt'] = "%d" % provider_amount
+xmldict['uniben_amt'] = "%d" % uniben_amount
+##<item_detail item_id="2" item_name="WEMA" item_amt="%(wema_amt)s" bank_id="16" acct_num="48398023902" />
+##<item_detail item_id="3" item_name="Portal Provider" item_amt="%(provider_amt)s" bank_id="47" acct_num="0980938209483" />
+xmltext = """
+<payment_item_detail>
+<item_details detail_ref="%(detail_ref)s" college="FCEOKENE" department="%(department)s"
+faculty="%(faculty)s">
+<item_detail item_id="1" item_name="FCEOKENE" item_amt="%(uniben_amt)s" bank_id="16" acct_num="384950902390" />
+</item_details>
+</payment_item_detail>
+""" % xmldict
+#total = int(xmldict['uniben_amt'])+int(xmldict['wema_amt'])+int(xmldict['provider_amt'])
+total = int(xmldict['uniben_amt'])
+args['Amount'] = "%d" % (total + 15000)
+args['site_name'] = "fceokene.waeup.org"
+args['cust_name_desc'] = "Student Name"
+args['pay_item_id'] = pay_item_id
+args['pay_item_name'] = "FCEOKENE Tuition Payments"
+args['payment_params'] = 'switch_college_split'
+#args['xml_data'] = xmltext % info
+args['xml_data'] = ''
+info['args'] = args
+return context.goto_interswitch_form(info=info)
