Index: /WAeUP_SRP/trunk/profiles/default/vocabularies/payment_types.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/vocabularies/payment_types.xml	(revision 5189)
+++ /WAeUP_SRP/trunk/profiles/default/vocabularies/payment_types.xml	(revision 5190)
@@ -10,3 +10,4 @@
     <item key="sc" msgid="">Scratch Card</item>
     <item key="online" msgid="">Online</item>
+    <item key="request" msgid="">Request</item>
 </object>
Index: /WAeUP_SRP/trunk/skins/waeup_aaue/getPaymentsFolderInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaue/getPaymentsFolderInfo.py	(revision 5189)
+++ /WAeUP_SRP/trunk/skins/waeup_aaue/getPaymentsFolderInfo.py	(revision 5190)
@@ -94,6 +94,7 @@
         start_pos = 6
     url = row['url'] = "%s/p%s" % (payments_path,oid[start_pos:])
-    row['is_requeryable'] = "%s_%s" % (payment.category,payment.session_id) not in paid_fees and not payment.resp_desc and payment.type == 'online' or str(member) in ('admin','isouaba')  # customized too
-    row['is_approvable'] = is_so and row['is_requeryable'] and payment.category == 'schoolfee' # does not make sense for maintenance
+    row['is_requeryable'] = "%s_%s" % (payment.category,payment.session_id) not in paid_fees and (not payment.resp_desc or str(member) in ('admin','isouaba')) and payment.type == 'online'   # customized too
+    row['is_requestable'] = "%s_%s" % (payment.category,payment.session_id) not in paid_fees and (not payment.resp_desc or str(member) in ('admin','isouaba')) and payment.type == 'request'  # customized too
+    row['is_approvable'] = is_so and (row['is_requeryable'] or row['is_requestable']) and payment.category == 'schoolfee' # does not make sense for maintenance
     row['resp_desc'] = payment.resp_desc or 'Payment Process Interrupted'
     row['trans_ref'] = payment.order_id
@@ -110,4 +111,15 @@
         href += '&redirectURL=%(callback_url)s' % row
         row['href'] = href
+    elif row['is_requestable']:
+        row['callback_url'] = "%(url)s/interswitch_request_cb" % row
+        #href = '%(query_url)s' % info
+        href = "http://testwebpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx"
+        href += '?redirectURL=%(callback_url)s' % row
+        href += '&productid=53'
+        href += '&merchantref=ignore'
+        href += '&custNumber=%s' % student_id
+        href += '&session=%s' % info['next_session_str']
+        href += '&semester=Semester 1'             
+        row['href'] = href        
     if payment.status == 'paid':
         row['confirmed'] = 'active'
Index: /WAeUP_SRP/trunk/skins/waeup_aaue/getSchoolFeeForRequest.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaue/getSchoolFeeForRequest.py	(revision 5190)
+++ /WAeUP_SRP/trunk/skins/waeup_aaue/getSchoolFeeForRequest.py	(revision 5190)
@@ -0,0 +1,25 @@
+## Script (Python) "getSchoolFeeForRequest"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=brain=None
+##title=
+##
+# $Id$
+"""
+return SchoolFee
+"""
+
+d = {}
+
+d['all'] = 0
+
+next_info = context.getNextInfo(brain)
+next_session_str = next_info['next_session_str']
+d['next_session_id'] = next_info['next_session_id']
+d['next_session_str'] = next_info['next_session_str']
+d['description'] = "School Fee for Session %s" % next_session_str
+
+return d
Index: /WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_cb.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_cb.py	(revision 5190)
+++ /WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_cb.py	(revision 5190)
@@ -0,0 +1,149 @@
+## 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_cb')
+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)
+s_brain = context.students_catalog(id=student_id)[0]
+session = s_brain.session
+
+next_info = context.getNextInfo(s_brain)
+next_session_id = next_info['next_session_id']
+next_session_str = next_info['next_session_str']
+next_level_id = next_info['next_level_id']
+next_transition = next_info['next_transition']
+next_verdict = next_info['next_verdict']
+next_previous_verdict = next_info['next_previous_verdict']
+
+if  resp:
+    if pay_doc.category == 'schoolfee':  
+        if context.getStudentReviewState() == "school_fee_paid":
+            logger.info('%s paid school_fee in state school_fee_paid' % (student_id))
+        else:
+            study_course = getattr(student,'study_course')
+            try:
+                wftool.doActionFor(study_course,'open')
+            except:
+                pass
+            verdict = s_brain.verdict
+            if next_previous_verdict == 'N/A':
+                next_previous_verdict = ''
+            study_course.getContent().edit(mapping= {'current_level': next_level_id,
+                                                     'current_session': next_session_id,
+                                                     'current_verdict': next_verdict,
+                                                     'previous_verdict': next_previous_verdict,
+                                                     })
+            if next_transition:
+                wftool.doActionFor(student,next_transition)
+
+
+
+    logger.info('%s received valid callback' % 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/interswitch_request_form.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_form.pt	(revision 5190)
+++ /WAeUP_SRP/trunk/skins/waeup_aaue/interswitch_request_form.pt	(revision 5190)
@@ -0,0 +1,49 @@
+<metal:body use-macro="here/main_template/macros/master">
+  <metal:main fill-slot="main"
+              tal:define="info options/info">
+    <h3>Request Your Payment Data from Interswitch! </h3>
+    <br />
+    <span tal:condition="not: info/payment_possible">
+      No payment information for your course available.
+    </span>
+    <span tal:condition="info/payment_possible">
+
+        <table>
+          <tr>
+            <td width="180px">
+            Payment:</td>
+            <td tal:content="info/type_description"></td>
+          </tr>
+          <tr>
+            <td>
+            Student Id:
+            </td>
+            <td tal:content="info/student_id" />
+          </tr> 
+          <tr>
+            <td>
+            Registration Number:
+            </td>
+            <td tal:content="info/reg_no" />
+          </tr>      
+          <tr>
+            <td>
+            Matriculation Number:
+            </td>
+            <td tal:content="info/matric_no" />
+          </tr>                             
+          <tr>
+            <td>
+            Name:
+            </td>
+            <td tal:content="info/student_name" />
+          </tr>
+        </table>
+        <br />
+        <a tal:attributes="href string: ${info/request_url}"> 
+          <button class="standalone"> Request </button>
+        </a>
+    </span>
+    </metal:main>
+</metal:body>
+
Index: /WAeUP_SRP/trunk/skins/waeup_aaue/payment_receipt.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaue/payment_receipt.pt	(revision 5189)
+++ /WAeUP_SRP/trunk/skins/waeup_aaue/payment_receipt.pt	(revision 5190)
@@ -49,4 +49,86 @@
         </metal:block>
         
+
+        <metal:block tal:condition="info/is_request_pmt">            
+        <h3>Scratch Card Payment Receipt</h3>
+        <br />
+        <table tal:define="student info/student;
+                           pm nocall: info/payment_doc">
+        
+        <tr>
+          <td width="220px">Name:</td> 
+          <td><span tal:content="student/name" /></td>
+        </tr>
+        <tr>
+          <td>Student Id:</td>
+          <td tal:content="student/id" />
+        </tr>        
+        <tr>
+          <td>Registration Number:</td>
+          <td tal:content="student/jamb_reg_no" />
+        </tr> 
+        <tr>
+          <td>Matriculation Number:</td>
+          <td tal:content="student/matric_no" />
+        </tr>                   
+        <tr>
+          <td>Certificate Id:</td>
+          <td tal:content="student/course" />
+        </tr>
+        <tr>
+          <td>Faculty:</td>
+          <td tal:content="student/faculty" />
+        </tr>        
+        <tr>
+          <td>Department:</td>
+          <td tal:content="student/department" />
+        </tr>             
+
+
+        <tr>
+          <td width="220px">Payment Status:</td> 
+          <td><span tal:content="python:context.portal_vocabularies.payment_status.get(pm.status)" /></td>
+        </tr>   
+        <tr>
+          <td width="220px">Access Code:</td> 
+          <td><span tal:content="pm/order_id" /></td>
+        </tr>     
+        <tr>
+          <td width="220px">Payment Type:</td> 
+          
+          <td><span tal:content="python:context.portal_vocabularies.payment_types.get(pm.type)" /></td>
+        </tr>   
+        <tr>
+          <td width="220px">Payment Category:</td> 
+          <td><span tal:content="python:context.portal_vocabularies.payment_categories.get(pm.category)" /></td>
+        </tr>   
+        <tr>
+          <td width="220px">Payment Item:</td> 
+          <td><span tal:content="pm/item" /></td>
+        </tr>       
+        <tr>
+          <td width="220px">Session:</td> 
+          <td><span tal:content="python:context.portal_vocabularies.sessions.get(pm.session_id)" /></td>
+        </tr>                   
+     
+        <tr>        
+          <td width="220px">Date of Request:</td> 
+          <td><span tal:content='python:pm.date.strftime("%d/%m/%y %H:%M:%S")' /></td>
+        </tr>       
+        <tr>
+          <td width="220px">Approved Amount (Naira):</td> 
+          <td><span tal:content="pm/resp_approved_amount" /></td>
+        </tr>   
+        <tr>
+          <td width="220px">Response Code:</td> 
+          <td><span tal:content="pm/resp_code" /></td>
+        </tr>         
+        <tr>
+          <td width="220px">Response Description:</td> 
+          <td><span tal:content="pm/resp_desc" /></td>
+        </tr>              
+        </table>
+        </metal:block>
+
         
         
Index: /WAeUP_SRP/trunk/skins/waeup_aaue/payments_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaue/payments_view.pt	(revision 5189)
+++ /WAeUP_SRP/trunk/skins/waeup_aaue/payments_view.pt	(revision 5190)
@@ -47,5 +47,5 @@
             </td>
             <td>
-              <a tal:condition="row/is_requeryable"
+              <a tal:condition="row/is_requestable"
                  tal:attributes="href row/href;
                  onclick python:'return window.confirm(\'%s\')' %(cpsmcat('Are you sure?'), );"
@@ -68,38 +68,28 @@
         <div>
           <form tal:condition="python: info.get('payment_method') in ('online_payment','both_payments')" 
-                tal:attributes="action string: ${context/absolute_url}/pay_interswitch" method="post" class="group">
+                tal:attributes="action string: ${context/absolute_url}/request_interswitch" method="post" class="group">
             <input type="submit" name="epayment" 
                    class="context" 
                    value="Pay"
-                   tal:attributes="value string:Initiate ${info/next_session_str} School Fee Payment by Cash Card"
+                   tal:attributes="value string:Request ${info/next_session_str} School Fee Payment Data from Interswitch"
                    />
           </form>  
           <form tal:condition="python: info.get('payment_method') in ('first_instalment',)" 
-                tal:attributes="action string: ${context/absolute_url}/pay_interswitch" method="post" class="group">
+                tal:attributes="action string: ${context/absolute_url}/request_interswitch" method="post" class="group">
             <input type="submit" name="epayment" 
                    class="context" 
                    value="Pay"
-                   tal:attributes="value string:Initiate ${info/next_session_str} School Fee Payment by Cash Card (First Instalment)"
+                   tal:attributes="value string:Request ${info/next_session_str} School Fee Payment Data from Interswitch (First Instalment)"
                    />
           </form>  
           <form tal:condition="python: info.get('payment_method') in ('second_instalment',)" 
-                tal:attributes="action string: ${context/absolute_url}/pay_interswitch2" method="post" class="group">
+                tal:attributes="action string: ${context/absolute_url}/request_interswitch2" method="post" class="group">
             <input type="submit" name="epayment" 
                    class="context" 
                    value="Pay"
-                   tal:attributes="value string:Initiate School Fee Payment by Cash Card (Second Instalment)"
+                   tal:attributes="value string:Request School Fee Payment from Interswitch (Second Instalment)"
                    />
           </form>                       
-          <form tal:condition="python: info.get('payment_method') in ('sc_payment','both_payments')" 
-                tal:attributes="action string: ${context/absolute_url}/pay_by_sc" method="post" class="group">
-            <input type="hidden" name="paid_session" 
-                   tal:attributes="value info/next_session"
-                   />
-            <input type="submit" name="epayment" 
-                   class="context" 
-                   value="Pay"
-                   tal:attributes="value string:Initiate ${info/next_session_str} School Fee Payment by Scratch Card"
-                   />
-          </form>    
+
           
           <form tal:condition="info/gown|nothing" 
Index: /WAeUP_SRP/trunk/skins/waeup_aaue/request_interswitch.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaue/request_interswitch.py	(revision 5190)
+++ /WAeUP_SRP/trunk/skins/waeup_aaue/request_interswitch.py	(revision 5190)
@@ -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_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)
+
+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'] = 'schoolfee'
+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_cb" % (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 1' 
+
+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 school fee payment request with order_id %(order_id)s and request url %(request_url)s' % info)
+
+return context.interswitch_request_form(info=info)
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentInfo.py	(revision 5189)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentInfo.py	(revision 5190)
@@ -36,5 +36,6 @@
 payment = context.getContent()
 info['payment_doc'] = payment
-info['is_online_pmt'] = io = payment.resp_code in ('0','00','AP','IP')
+info['is_online_pmt'] = io = payment.resp_code in ('0','00','AP','IP',)
+info['is_request_pmt'] = io = payment.resp_code in ('RP',)
 info['is_scratchcard_pmt'] = isc =  payment.resp_code == 'SC'
 info['is_interrupted'] = ii = payment.resp_code == ''
