Index: WAeUP_SRP/trunk/skins/waeup_aaua/getPaymentsFolderInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_aaua/getPaymentsFolderInfo.py	(revision 5192)
+++ WAeUP_SRP/trunk/skins/waeup_aaua/getPaymentsFolderInfo.py	(revision 5193)
@@ -56,5 +56,5 @@
 # begin customization
 
-if review_state in ('returning',):
+if review_state in ('returning',) and info['next_session'] != session:
     if session in ('06',):
         info['payment_method'] = "online_payment"
Index: WAeUP_SRP/trunk/skins/waeup_aaue/getPaymentsFolderInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_aaue/getPaymentsFolderInfo.py	(revision 5192)
+++ WAeUP_SRP/trunk/skins/waeup_aaue/getPaymentsFolderInfo.py	(revision 5193)
@@ -56,10 +56,20 @@
 # begin customization
 
-if review_state == 'cleared_and_validated':
-    info['payment_method'] = "online_payment"
-#elif review_state == 'cleared_and_validated' and session == '07':
-#    info['payment_method'] = "sc_payment"
-elif review_state == 'returning' and info['next_session'] != session:
-    info['payment_method'] = "online_payment"
+if review_state in ('returning',) and info['next_session'] != session:
+    if session in ('06','07','08'):
+        info['payment_method'] = "online_payment"
+    else:
+        info['payment_method'] = "first_instalment"
+elif review_state in ('cleared_and_validated',):
+    if session in ('06','07','08','09'):
+        info['payment_method'] = "online_payment"
+    else:
+        info['payment_method'] = "first_instalment"
+elif session in ('09','10','11',) and review_state in ('school_fee_paid','courses_registered','courses_validated',):
+    second_instalment_records = aq_payments(Eq('student_id',student_id) & Eq('category','schoolfee2') & Eq('session_id',session) & Eq('status','paid'))
+    if not second_instalment_records:
+        info['payment_method'] = "second_instalment"
+    else:    
+        pass
 info['prod_id'] = '119'
 
@@ -82,4 +92,13 @@
         row['title'] = "Invalid Payment, Naira %s, %s" % (payment.amount,
                                                           payment.date.strftime("%d/%m/%y %H:%M:%S"))
+    elif payment.type == 'request' and payment.resp_approved_amount:
+        row['title'] = "%s for Session %s, Naira %s, %s" % (vocabularies.payment_categories.get(payment.category),
+                                                            vocabularies.sessions.get(payment.session_id),
+                                                            payment.resp_approved_amount,
+                                                            payment.date.strftime("%d/%m/%y %H:%M:%S"))
+    elif payment.type == 'request':
+        row['title'] = "%s for Session %s, %s" % (vocabularies.payment_categories.get(payment.category),
+                                                            vocabularies.sessions.get(payment.session_id),
+                                                            payment.date.strftime("%d/%m/%y %H:%M:%S"))                                                            
     else:
         row['title'] = "%s for Session %s, Naira %s, %s" % (vocabularies.payment_categories.get(payment.category),
@@ -100,5 +119,8 @@
     row['trans_ref'] = payment.order_id
     if row['is_requeryable']:
-        row['callback_url'] = "%(url)s/interswitch_cb" % row
+        if payment.category == 'schoolfee':
+            row['callback_url'] = "%(url)s/interswitch_cb" % row
+        elif payment.category == 'schoolfee2':
+            row['callback_url'] = "%(url)s/interswitch_cb2" % row             
 #        if payment.category == 'schoolfee':
 #            row['callback_url'] = "%(url)s/interswitch_cb" % row
@@ -112,13 +134,19 @@
         row['href'] = href
     elif row['is_requestable']:
-        row['callback_url'] = "%(url)s/interswitch_request_cb" % row
+        if payment.category == 'schoolfee':
+            row['callback_url'] = "%(url)s/interswitch_request_cb" % row
+        elif payment.category == 'schoolfee2':
+            row['callback_url'] = "%(url)s/interswitch_request_cb2" % row      
         #href = '%(query_url)s' % info
         href = "http://testwebpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx"
         href += '?redirectURL=%(callback_url)s' % row
+        #href += '&productid=%(prod_id)s' % info
         href += '&productid=53'
         href += '&merchantref=ignore'
         href += '&custNumber=%s' % student_id
         href += '&session=%s' % info['next_session_str']
-        href += '&semester=Semester 1'             
+        href += '&semester=Semester 1'
+        if payment.category == 'schoolfee2':    
+            href += '&semester=Semester 2'         
         row['href'] = href        
     if payment.status == 'paid':
Index: WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_cb2.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_cb2.py	(revision 5193)
+++ WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_cb2.py	(revision 5193)
@@ -0,0 +1,117 @@
+## Script (Python) "interswitch_cb"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+payment callback
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+import logging
+logger = logging.getLogger('Skins.interswitch_request_cb2')
+from AccessControl import Unauthorized
+import DateTime
+
+now = DateTime.DateTime()
+
+if context.portal_membership.isAnonymousUser():
+    return None
+
+request = context.REQUEST
+students = context.portal_url.getPortalObject().campus.students
+wftool = context.portal_workflow
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+#student_id = context.getStudentId()
+access_info = context.waeup_tool.getAccessInfo(context)
+student_id = access_info['student_id']
+if not context.isSectionOfficer() and (student_id is None or student_id != member_id):
+    logger.info('%s tried to access payment object of %s' % (member_id,student_id))
+    referer = request.get('HTTP_REFERER','none')
+    logger.info('%s:%s illegal access, referer = %s' % (member_id,student_id,referer))
+    real_ip = request.get('HTTP_X_REAL_IP',"none")
+    logger.info('%s:%s illegal access, real_x_ip = %s' % (member_id,student_id,real_ip))
+    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+
+referer = request.get('HTTP_REFERER','none')
+real_ip = request.get('HTTP_X_REAL_IP',"none")  
+logger.info('%s, callback referer = %s, IP = %s' % (student_id,referer,real_ip))
+
+#if not 'webpay.interswitchng.com' in referer and not 'waeup.org' in referer:
+#    logger.info('%s, wrong callback referer %s, callback rejected, IP = %s' % (student_id,referer,real_ip))
+#    return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url())
+
+student = getattr(students,student_id)
+              
+resp_codes = (
+              #("desc","resp_desc"),
+              #("resp","resp_code"),
+              #("txnRef","pay_reference"),
+              ("pin","resp_pay_reference"),
+              #("retRef","retRef"),
+              #("cardNum","resp_card_num"),
+              ("appamt","resp_approved_amount"),
+              ("msg","msg"),
+              ("session","resp_session"),
+              ("feename","resp_feename"),       
+              ("studentnum","resp_studentnum"),  
+              ("txndate","resp_txndate"),  
+              ("studentname","resp_studentname"), 
+              )              
+              
+pd = {}
+for rc,pdk in resp_codes:
+    pd[pdk] = request.get(rc,'')
+
+## for testing purposes
+#pd['resp_desc'] = 'Simulated Callback'
+#pd['resp_pay_reference'] = 'XXXX'
+#pd['resp_code'] = '00'
+#pd['resp_card_num'] = '0000'
+#pd['resp_approved_amount'] = '4680000'
+
+if pd['resp_approved_amount'] and len(pd['resp_approved_amount']) > 4:
+    pd['resp_approved_amount'] = pd['resp_approved_amount'][:-2]
+    pd['status'] = 'paid'
+    pd['resp_desc'] = pd['resp_feename'] + '|' + pd['resp_studentnum'] + '|' + pd['resp_studentname'] + '|' + pd['resp_txndate'] + '|' + pd['resp_session']
+    pd['resp_code'] = 'RP'
+    pd['date'] = now
+else:
+    pd['resp_approved_amount'] = '0'
+    pd['status'] = 'failed'
+    pd['resp_desc'] = pd['msg']
+    pd['date'] = now
+
+review_state = wftool.getInfoFor(context,'review_state',None)
+if not pd['resp_approved_amount']:
+    logger.info('%s requeried payment %s for %s and got empty response' % (member,context.getId(),student_id))
+    return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url())
+if access_info['is_student'] and review_state == 'closed':
+    wftool.doActionFor(context,'open')
+pay_doc = context.getContent()
+resp = pd['resp_approved_amount'] 
+
+pay_doc.edit(mapping = pd)
+
+if  resp:
+    logger.info('%s received valid callback' % student_id)
+    logger.info('%s paid second instalment' % student_id)
+else:
+    logger.info('%s received unsuccessful callback: %s' % (student_id,pd['resp_desc']))
+
+review_state = wftool.getInfoFor(context,'review_state',None)
+if review_state == 'opened':
+    wftool.doActionFor(context,'close')
+
+return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url())
+
Index: WAeUP_SRP/trunk/skins/waeup_aaue/request_interswitch2.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_aaue/request_interswitch2.py	(revision 5193)
+++ WAeUP_SRP/trunk/skins/waeup_aaue/request_interswitch2.py	(revision 5193)
@@ -0,0 +1,101 @@
+## Script (Python) "pay_online"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+pay online
+"""
+from urllib import urlencode
+import logging
+logger = logging.getLogger('Skins.request_interswitch2')
+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)
+
+student_record = context.students_catalog.getRecordByKey(student_id)
+info = {}
+info['student'] = student_record
+info['payment_possible'] = False
+fee_dict = context.getSchoolFeeForRequest(student_record)
+fulltime = student_record.mode.endswith('_ft')
+
+if not fee_dict:
+    return context.interswitch_form(info=info)
+
+info['payment_possible'] = True
+info['type_description'] = fee_dict['description']
+info['student_id'] = student_id
+info['reg_no'] = student_record.jamb_reg_no
+info['matric_no'] = student_record.matric_no
+info['student_name'] = student_record.name
+info['type'] = 'request'
+info['status'] = 'started'
+info['session_id'] = fee_dict['next_session_id']
+info['session_str'] = fee_dict['next_session_str']
+info['item'] = student_record.course
+info['category'] = 'schoolfee2'
+info['student_email'] = student_record.email
+now = DateTime.DateTime()
+info['date'] = now
+info['pay_ship_to'] = "Ambrose Alli University Ekpoma"
+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())
+
+query_url = "http://testwebpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx"
+
+info['callback_url'] = "%s/payments/%s/interswitch_request_cb2" % (student.absolute_url(),p_id)
+
+request_url = query_url
+request_url += '?redirectURL=%s' % info['callback_url']
+request_url += '&productid=53'
+request_url += '&merchantref=ignore'
+request_url += '&custNumber=%s' % student_id
+request_url += '&session=%s' % info['session_str']
+request_url += '&semester=Semester 2' 
+
+info['request_url'] = request_url
+
+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')
+
+payments.invokeFactory('Payment', p_id)
+payment = getattr(payments,p_id)
+wftool.doActionFor(payment,'open')
+d = {}
+d.update(info)
+payment.getContent().edit(mapping=d)
+
+logger.info('%(student_id)s initiated second school fee payment request with order_id %(order_id)s and request url %(request_url)s' % info)
+
+return context.interswitch_request_form(info=info)
