Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser.py	(revision 10130)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser.py	(revision 10131)
@@ -22,5 +22,6 @@
 from zope.component import getUtility, queryAdapter
 from kofacustom.nigeria.interswitch.browser import (
-    InterswitchPaymentRequestWebservicePageStudent
+    InterswitchPaymentRequestWebservicePageStudent,
+    InterswitchPaymentRequestWebservicePageApplicant
     )
 from waeup.kofa.browser.layout import KofaPage, UtilityView
@@ -32,5 +33,5 @@
 
 PRODUCT_ID = '3930'
-SITE_NAME = 'kwarapoly-kofa.waeup.org'
+SITE_NAME = 'kwarapoly.waeup.org'
 PROVIDER_ACCT = '1010764827'
 PROVIDER_BANK_ID = '117'
@@ -180,4 +181,90 @@
         return
 
+class InterswitchPageApplicant(KofaPage):
+    """ View which sends a POST request to the Interswitch
+    CollegePAY payment gateway.
+    """
+    grok.context(ICustomApplicantOnlinePayment)
+    grok.require('waeup.payApplicant')
+    grok.template('applicant_goto_interswitch')
+    grok.name('goto_interswitch')
+    label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
+    submit_button = _('Submit')
+    action = POST_ACTION
+    site_name = SITE_NAME
+    currency = CURRENCY
+    pay_item_id = '103'
+    product_id = PRODUCT_ID
+    mac = 'E6BA6CBBA9AF2871EE25C32C8D57C98895B9B001DC5B9CB2C463E2A9BDA44A3F1260C8A364F33789CDF74CB3EE7E6EF5D94F48D3AF7B727E75D97F07618DFA6D'
+
+    def interswitch_img_url(self):
+        return interswitch_img_url(self)
+
+    def update(self):
+        if self.context.p_state != 'unpaid':
+            self.flash(_("Payment ticket can't be re-send to CollegePAY."))
+            self.redirect(self.url(self.context, '@@index'))
+            return
+        if self.context.__parent__.__parent__.expired \
+            and self.context.__parent__.__parent__.strict_deadline:
+            self.flash(_("Payment ticket can't be send to CollegePAY. "
+                         "Application period has expired."))
+            self.redirect(self.url(self.context, '@@index'))
+            return
+        self.applicant = self.context.__parent__
+        self.amount_auth = 100 * self.context.amount_auth
+        xmldict = {}
+        self.category = getUtility(
+            IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category]
+        tz = getUtility(IKofaUtils).tzinfo
+        self.local_date_time = to_timezone(
+            self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z")
+        self.site_redirect_url = self.url(self.context, 'request_webservice')
+        provider_amt = 250.0
+        dalash_amt = 250.0
+        if self.applicant.applicant_id.startswith('hnd'):
+            xmldict['institution_acct'] = '7000016463'
+            xmldict['institution_bank_id'] = '9'
+        elif self.applicant.applicant_id.startswith('nd') \
+            or self.applicant.applicant_id.startswith('prend'):
+            xmldict['institution_acct'] = '2014191363'
+            xmldict['institution_bank_id'] = '8'
+        else:
+            xmldict['institution_acct'] = '00000000000'
+            xmldict['institution_bank_id'] = '00'
+        xmldict['dalash_amt'] = 100 * dalash_amt
+        xmldict['detail_ref'] = self.context.p_id
+        xmldict['provider_amt'] = 100 * provider_amt
+        xmldict['provider_acct'] = PROVIDER_ACCT
+        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
+        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
+        xmldict['institution_amt'] = 100 * (
+            self.context.amount_auth - provider_amt - GATEWAY_AMT - dalash_amt)
+        xmldict['institution_item_name'] = self.context.p_category
+        xmldict['institution_name'] = INSTITUTION_NAME
+
+        hashargs = (
+            self.context.p_id +
+            PRODUCT_ID +
+            self.pay_item_id +
+            str(int(self.amount_auth)) +
+            self.site_redirect_url +
+            self.mac)
+        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
+
+        # Interswitch amount is not part of the xml data
+        xmltext = """<payment_item_detail>
+<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
+<item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
+<item_detail item_id="2" item_name="Dalash" item_amt="%(dalash_amt)d" bank_id="117" acct_num="1013196791" />
+<item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
+</item_details>
+</payment_item_detail>""" % xmldict
+        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
+        self.context.provider_amt = provider_amt
+        self.context.gateway_amt = GATEWAY_AMT
+        self.context.thirdparty_amt = dalash_amt
+        return
+
 class InterswitchPaymentRequestWebservicePageStudent(
     InterswitchPaymentRequestWebservicePageStudent):
@@ -188,2 +275,11 @@
     gateway_host = HOST
     gateway_url = URL
+
+class InterswitchPaymentRequestWebservicePageApplicant(
+    InterswitchPaymentRequestWebservicePageApplicant):
+    """ Request webservice view for the CollegePAY gateway
+    """
+    grok.context(ICustomApplicantOnlinePayment)
+    product_id = PRODUCT_ID
+    gateway_host = HOST
+    gateway_url = URL
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser_templates/applicant_goto_interswitch.pt
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser_templates/applicant_goto_interswitch.pt	(revision 10130)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser_templates/applicant_goto_interswitch.pt	(revision 10131)
@@ -59,4 +59,5 @@
   <input type="hidden" name="currency" tal:attributes="value view/currency" />
   <input type="hidden" name="pay_item_id" tal:attributes="value view/pay_item_id" />
+  <input type="hidden" name="hash" tal:attributes="value view/hashvalue" />
   <input type="hidden" name="site_redirect_url" tal:attributes="value view/site_redirect_url" />
   <input type="hidden" name="site_name" tal:attributes="value view/site_name" />
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/tests.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/tests.py	(revision 10130)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/tests.py	(revision 10131)
@@ -285,2 +285,75 @@
             '52100.0,00,1200.0,300.0,1800.0,,,\n'
             in logcontent)
+
+
+class InterswitchTestsApplicants(ApplicantsFullSetup):
+    """Tests for the Interswitch payment gateway.
+    """
+
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(InterswitchTestsApplicants, self).setUp()
+        # Create at least one Kwarapoly faculty
+        self.app['faculties']['CPGS'] = Faculty(code='CPGS')
+        self.app['faculties']['CPGS']['dep1'] = Department(code='dep1')
+        self.certificate2 = createObject('waeup.Certificate')
+        self.certificate2.code = u'CERT2'
+        self.certificate2.application_category = 'nd'
+        self.certificate2.study_mode = 'nd_ft'
+        self.certificate2.start_level = 100
+        self.certificate2.end_level = 300
+        self.app['faculties']['CPGS']['dep1'].certificates.addCertificate(
+            self.certificate2)
+        self.applicantscontainer.application_category = 'nd'
+        self.applicant.applicant_id = u'nd_anything'
+        
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.manage_path)
+        #IWorkflowState(self.student).setState('started')
+        super(InterswitchTestsApplicants, self).fill_correct_values()
+        self.browser.getControl(name="form.course1").value = ['CERT2']
+        self.applicantscontainer.application_fee = 3333.0
+        self.browser.getControl(name="form.nationality").value = ['NG']
+        self.browser.getControl(name="transition").value = ['start']
+        self.browser.getControl("Save").click()
+        self.browser.getControl("Add online").click()
+        self.assertMatches('...ticket created...',
+                           self.browser.contents)
+        #ctrl = self.browser.getControl(name='val_id')
+        #value = ctrl.options[0]
+        #self.browser.getLink(value).click()
+        self.assertMatches('...Amount Authorized...',
+                           self.browser.contents)
+        self.assertMatches(
+            '...<span>3333.0</span>...',
+            self.browser.contents)
+        self.payment_url = self.browser.url
+
+
+    def test_interswitch_form(self):
+
+        # Manager can access InterswitchForm
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertMatches('...Total Amount Authorized:...',
+                           self.browser.contents)
+        self.assertTrue(
+            '<input type="hidden" name="amount" value="333300.0" />'
+            in self.browser.contents)
+        self.assertTrue(
+            '<item_detail item_id="1" item_name="application" '
+            'item_amt="253300" bank_id="8" acct_num="2014191363" />'
+            in self.browser.contents)
+
+        # hnd fee goes to another account
+        self.applicant.applicant_id = u'hnd_anything'
+        self.browser.open(self.manage_path)
+        ctrl = self.browser.getControl(name='val_id')
+        value = ctrl.options[0]
+        self.browser.getLink(value).click()
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue(
+            '<item_detail item_id="1" item_name="application" '
+            'item_amt="253300" bank_id="9" acct_num="7000016463" />'
+            in self.browser.contents)
+
