source: main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py @ 16982

Last change on this file since 16982 was 16951, checked in by Henrik Bettermann, 2 years ago

Change bank acount.

  • Property svn:keywords set to Id
File size: 38.4 KB
RevLine 
[16942]1# -*- coding: utf-8 -*-
[12730]2## $Id: browser.py 16951 2022-05-10 09:41:17Z henrik $
[11846]3##
4## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
5## This program is free software; you can redistribute it and/or modify
6## it under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 2 of the License, or
8## (at your option) any later version.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with this program; if not, write to the Free Software
17## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18##
19import httplib
20import hashlib
21import grok
[15473]22from xml.dom import minidom
[11846]23from zope.interface import Interface
24from zope.component import queryAdapter
[12975]25from waeup.kofa.interfaces import CLEARED
[11846]26from kofacustom.nigeria.interswitch.browser import (
27    InterswitchPaymentRequestWebservicePageStudent,
28    InterswitchPaymentRequestWebservicePageApplicant,
[13586]29    InterswitchPaymentVerifyWebservicePageApplicant,
30    InterswitchPaymentVerifyWebservicePageStudent,
[11846]31    InterswitchPageStudent, InterswitchPageApplicant,
32    )
33from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment
34from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment
35from waeup.aaue.interfaces import MessageFactory as _
36
[13379]37PRODUCT_ID_PT = '5040'
38PRODUCT_ID_REGULAR = '5845'
[11846]39SITE_NAME = 'aaue.waeup.org'
[15927]40PROVIDER_ACCT = '5100189030'
41PROVIDER_BANK_ID = '307'
[14823]42PROVIDER_ITEM_NAME = 'WAeAC'
[11846]43INSTITUTION_NAME = 'AAU Ekpoma'
44CURRENCY = '566'
[15867]45GATEWAY_AMT = 200.0
[11933]46POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
[11846]47
[11933]48HOST = 'webpay.interswitchng.com'
[13586]49URL = '/paydirect/api/v1/gettransaction.json'
[11916]50HTTPS = True
[13606]51MAC_REGULAR = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023'
52MAC_PT = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
[11846]53
[11917]54httplib.HTTPSConnection.debuglevel = 0
[11846]55
[13379]56
[13414]57def gateway_net_amt(fee):
[13438]58    if fee > GATEWAY_AMT:
[13414]59        return fee - GATEWAY_AMT
[13438]60    return 0.0
[13406]61
[13532]62def contr_agreement_applicant(applicant):
[16779]63    if applicant.__parent__.prefix in (
[15396]64        'fp',
65        'ptee',
66        'dsh',
67        'bridge',
68        'ijmbe',
69        ):
[13532]70        return 'first'
71    return 'second'
72
73def contr_agreement_student(student):
[15382]74    if student.current_mode in (
[15387]75        'found',
76        'bridge',
77        'ug_dsh',
78        'de_dsh',
79        'ug_pt',
80        'de_pt',
[15396]81        'dp_pt',
82        'ijmbe',
83        ):
[13403]84        return 'first'
85    return 'second'
[13379]86
[11846]87class CustomInterswitchPageApplicant(InterswitchPageApplicant):
88    """ View which sends a POST request to the Interswitch
89    CollegePAY payment gateway.
[13379]90
91    So far only PT application has been configured.
[11846]92    """
93    grok.context(ICustomApplicantOnlinePayment)
94    action = POST_ACTION
95    site_name = SITE_NAME
96    currency = CURRENCY
[15135]97    provider_bank_id = PROVIDER_BANK_ID
98    provider_acct = PROVIDER_ACCT
[15224]99    institution_acct = '1010835352'
100    institution_bank_id = '117'
[11846]101
102    def update(self):
103
[12975]104        error = self.init_update()
105        if error:
106            self.flash(error, type='danger')
107            self.redirect(self.url(self.context, '@@index'))
108            return
[15761]109        self.context.r_company = u'interswitch'
[15260]110        provider_amt = 2000.0
[15746]111        fedex_amt = 0.0
[16779]112        if contr_agreement_applicant(self.applicant) == 'first':
[13532]113            self.product_id = PRODUCT_ID_PT
114            self.pay_item_id = '101'
[13606]115            self.mac = MAC_PT
[16681]116            if self.applicant.__parent__.prefix == 'ijmbe':
[16778]117                self.institution_bank_id = '123'
118                self.institution_acct = '1012278272'
[13532]119        else:
120            self.product_id = PRODUCT_ID_REGULAR
121            self.pay_item_id = '109'
[13606]122            self.mac = MAC_REGULAR
[15464]123            if self.applicant.__parent__.prefix in ('utme', 'ude'):
124                provider_amt = 1000.0
[15524]125            elif self.applicant.__parent__.prefix in ('trans', 'cert'):
[15512]126                self.institution_acct = '1010827641'
127                self.institution_bank_id = '117'
[15135]128                self.provider_bank_id = '10'
129                self.provider_acct = '0427773399'
[15512]130                if self.applicant.applicant_id[:5] in ('cert7', 'cert8'):
131                    provider_amt = 0.0
132                if self.applicant.applicant_id[:6] in ('trans5', 'trans6'):
133                    self.institution_acct = '5210006575'
[15520]134                    self.institution_bank_id = '51'
[15837]135                #if self.applicant.applicant_id[:6] in ('trans1', 'trans6'):
136                #    fedex_amt = 10500.0
[15591]137                if self.context.p_category == 'app_balance':
138                    provider_amt = 0.0
[15524]139            elif self.applicant.applicant_id.startswith('bridge'): # easier to test
[15224]140                self.institution_acct = '1014847058'
141                self.institution_bank_id = '7'
[15524]142            elif self.applicant.applicant_id.startswith('dsh'): # easier to test
143                self.institution_acct = '1014847058'
144                self.institution_bank_id = '7'
[15735]145            elif self.applicant.__parent__.prefix in ('ver', 'send'):
146                provider_amt = 0.0
[15952]147            elif self.applicant.__parent__.prefix == 'fedex':
148                provider_amt = 0.0
[16003]149                self.institution_acct = '0001115694'
150                self.institution_bank_id = '10'
[16898]151            elif self.applicant.applicant_id.startswith('pg'):
152                self.institution_acct = '5210006575'
153                self.institution_bank_id = '51'
[16678]154
[11846]155        xmldict = {}
156        xmldict['detail_ref'] = self.context.p_id
157        xmldict['provider_amt'] = 100 * provider_amt
[15135]158        xmldict['provider_acct'] = self.provider_acct
159        xmldict['provider_bank_id'] = self.provider_bank_id
[11846]160        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
[15224]161        xmldict['institution_acct'] = self.institution_acct
162        xmldict['institution_bank_id'] = self.institution_bank_id
[13532]163        xmldict['institution_item_name'] = self.category
[11846]164        xmldict['institution_name'] = INSTITUTION_NAME
[15746]165        xmldict['fedex_amt'] = 100 * fedex_amt
[15224]166        xmldict['institution_amt'] = 100 * (
[15746]167            self.context.amount_auth - provider_amt - fedex_amt - GATEWAY_AMT)
[15512]168
[15224]169        xmltext = """<payment_item_detail>
170<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
171<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" />
172<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
173</item_details>
174</payment_item_detail>""" % xmldict
[14121]175
[15512]176        if provider_amt == 0.0:
177            xmltext = """<payment_item_detail>
178<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
179<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" />
180</item_details>
181</payment_item_detail>""" % xmldict
182
[15746]183        if fedex_amt:
184            xmltext = """<payment_item_detail>
185<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
186<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" />
187<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
[16003]188<item_detail item_id="3" item_name="FedEx" item_amt="%(fedex_amt)d" bank_id="10" acct_num="0001115694" />
[15746]189</item_details>
190</payment_item_detail>""" % xmldict
191
[14121]192        if self.applicant.applicant_id.startswith('pg'):
193            handbook_amount = 2000.0
194            xmldict['handbook_amount'] = 100 * handbook_amount
195            xmldict['institution_amt'] = 100 * (
196                self.context.amount_auth - provider_amt - handbook_amount -GATEWAY_AMT)
197            xmltext = """<payment_item_detail>
[11846]198<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
199<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" />
200<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
[16895]201<item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="51" acct_num="5210006575" />
[11846]202</item_details>
203</payment_item_detail>""" % xmldict
[14121]204
[11846]205        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
206        self.context.provider_amt = provider_amt
207        self.context.gateway_amt = GATEWAY_AMT
[15473]208        xmlitems = ''
209        xmldoc = minidom.parseString(xmltext)
210        itemlist = xmldoc.getElementsByTagName('item_detail')
211        for s in itemlist:
212            xmlitems += "%s: %s, N%s, %s (%s)  " % (
213                s.attributes['item_id'].value,
214                s.attributes['item_name'].value,
215                int(s.attributes['item_amt'].value)/100,
216                s.attributes['acct_num'].value,
217                s.attributes['bank_id'].value,
218                )
219        self.context.p_split_data = xmlitems
[15761]220        self.amount_auth = int(100 * self.context.amount_auth)
[11846]221        hashargs = (
222            self.context.p_id +
[13532]223            self.product_id +
[11846]224            self.pay_item_id +
225            str(int(self.amount_auth)) +
226            self.site_redirect_url +
227            self.mac)
228        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
229
230        return
231
[11868]232class CustomInterswitchPageStudent(InterswitchPageStudent):
233    """ View which sends a POST request to the Interswitch
234    CollegePAY payment gateway.
235    """
236    grok.context(ICustomStudentOnlinePayment)
237    action = POST_ACTION
238    site_name = SITE_NAME
239    currency = CURRENCY
[14248]240    pay_item_id = '000'
[11846]241
[11868]242    def update(self):
[12975]243        error = self.init_update()
244        if error:
245            self.flash(error, type='danger')
246            self.redirect(self.url(self.context, '@@index'))
247            return
[15761]248        self.context.r_company = u'interswitch'
[11868]249        student = self.student
[13408]250        p_session = self.context.p_session
[13400]251        try:
[13408]252            academic_session = grok.getSite()['configuration'][str(p_session)]
[13400]253        except KeyError:
[13407]254            self.flash(_(u'Session configuration object is not available.'),
255                       type='danger')
[13400]256            self.redirect(self.url(self.context, '@@index'))
257            return
[13532]258        if contr_agreement_student(student) == 'first':
[13382]259            self.product_id = PRODUCT_ID_PT
[13606]260            self.mac = MAC_PT
[13382]261        else:
262            self.product_id = PRODUCT_ID_REGULAR
[13606]263            self.mac = MAC_REGULAR
[13382]264
[12975]265        # To guarantee that cleared students pay both acceptance fee
266        # and school fees, the page can only be accessed
267        # for school fee payments if acceptance/clearance fee has
268        # been successfully queried/paid beforehand. This
269        # requirement applies to students in state 'cleared' and
[14380]270        # entry_session greater than 2012 only.
[13400]271        if self.context.p_category.startswith('schoolfee') and \
[12975]272            student.state == CLEARED and \
273            student.entry_session > 2012:
274            acceptance_fee_paid = False
275            for ticket in student['payments'].values():
276                if ticket.p_state == 'paid' and \
[13400]277                    ticket.p_category.startswith('clearance'):
[12975]278                    acceptance_fee_paid = True
279                    break
280            if not acceptance_fee_paid:
281                self.flash(
282                    _('Please pay acceptance fee first.'), type="danger")
283                self.redirect(self.url(self.context, '@@index'))
284                return
285
[11868]286        xmldict = self.xmldict
[12729]287        xmltext = ""
[14945]288        xmldict['institution_acct'] = '1010827641'
289        xmldict['institution_bank_id'] = '117'
[11868]290        xmldict['detail_ref'] = self.context.p_id
291        xmldict['provider_acct'] = PROVIDER_ACCT
292        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
293        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
294        xmldict['institution_item_name'] = self.category
295        xmldict['institution_name'] = INSTITUTION_NAME
[13381]296        provider_amt = 0.0
[16942]297        xmldict['institution_amt'] = 100 * (
298            gateway_net_amt(self.context.amount_auth))
[12729]299
[13400]300        # Schoolfee
301        if self.context.p_category.startswith('schoolfee'):
[13532]302            if contr_agreement_student(student) == 'first':
[13403]303                # First agreement
[15479]304                provider_amt = 1900.0
[15387]305                joint_venture_amt = 0.0
306                aaue_share_amt = 0.0
[13414]307                student_union_due_amt = gateway_net_amt(
308                    academic_session.union_fee)
309                student_welfare_assurance_amt = gateway_net_amt(
310                    academic_session.welfare_fee)
[15180]311                sports_amt = gateway_net_amt(
312                    academic_session.sports_fee)
313                library_amt = gateway_net_amt(
314                    academic_session.library_fee)
[15181]315                library_amt_pg = gateway_net_amt(
[15971]316                    academic_session.library_pg_fee)
[16950]317                lms_sund_amt = gateway_net_amt(
318                    academic_session.lms_sund_fee)
[14980]319                xmldict['student_union_bank_id'] = '31'
320                xmldict['student_union_acct'] = '0051005007'
[15384]321                xmldict['aaue_share_bank_id'] = '117'
322                xmldict['aaue_share_acct'] = '1010827641'
323                xmldict['joint_venture_bank_id'] = '117'
324                xmldict['joint_venture_acct'] = '1010827641'
[15359]325                xmldict['institution_acct'] = '1014847058'
326                xmldict['institution_bank_id'] = '7'
[16681]327                self.pay_item_id = '105'
[13379]328                if student.current_mode == 'found':
329                    self.pay_item_id = '103'
[16681]330                elif student.current_mode == 'ijmbe':
[16691]331                    self.pay_item_id = '103'
[16681]332                    xmldict['institution_bank_id'] = '123'
333                    xmldict['institution_acct'] = '1012278272'
[13400]334            else:
[13403]335                # Second agreement
[15384]336                joint_venture_amt = 1000.0
337                aaue_share_amt = 1500.0
[15479]338                provider_amt = 1500.0
[13414]339                student_union_due_amt = gateway_net_amt(
340                    academic_session.union_fee)
341                student_welfare_assurance_amt = gateway_net_amt(
342                    academic_session.welfare_fee)
[15180]343                sports_amt = gateway_net_amt(
344                    academic_session.sports_fee)
345                library_amt = gateway_net_amt(
346                    academic_session.library_fee)
[15181]347                library_amt_pg = gateway_net_amt(
[15971]348                    academic_session.library_pg_fee)
[16942]349                lms_sund_amt = gateway_net_amt(
350                    academic_session.lms_sund_fee)
[14980]351                xmldict['student_union_bank_id'] = '7'
352                xmldict['student_union_acct'] = '1019763348'
[15384]353                xmldict['aaue_share_bank_id'] = '117'
354                xmldict['aaue_share_acct'] = '1010827641'
355                xmldict['joint_venture_bank_id'] = '117'
356                xmldict['joint_venture_acct'] = '1010827641'
[13644]357                self.pay_item_id = '107'
[13527]358                if student.is_postgrad:
359                    self.pay_item_id = '111'
[15460]360                    xmldict['institution_acct'] = '5210006575'
361                    xmldict['institution_bank_id'] = '51'
[13400]362
363            xmldict['provider_amt'] = 100 * provider_amt
[15384]364            xmldict['joint_venture_amt'] = 100 * joint_venture_amt
365            xmldict['aaue_share_amt'] = 100 * aaue_share_amt
[16943]366            xmldict['lms_sund_amt'] = 100 * lms_sund_amt
[13732]367            if self.context.p_item == 'Balance':
368                xmldict['institution_amt'] = 100 * (
369                    gateway_net_amt(self.context.amount_auth))
[15479]370            elif self.context.p_category == 'schoolfee_2':
371                xmldict['institution_amt'] = 100 * gateway_net_amt(
372                    self.context.amount_auth)
373                xmltext = """<payment_item_detail>
374<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
375<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" />
376</item_details>
377</payment_item_detail>""" % xmldict
[14987]378            elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \
379                and student.current_mode != 'ijmbe':
[13400]380                # Schoolfee including additional fees
[13379]381                xmldict['student_union_due_amt'] = 100 * student_union_due_amt
382                xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
[15192]383
[15976]384                if student.entry_session >= 2018 and student.is_fresh:
[15192]385                    xmldict['sports_amt'] = 100 * sports_amt
386                    if student.is_postgrad:
387                        xmldict['library_amt'] = 100 * library_amt_pg
388                    else:
389                        xmldict['library_amt'] = 100 * library_amt
390                    xmldict['institution_amt'] = 100 * (
391                        gateway_net_amt(self.context.amount_auth)
392                        - provider_amt
[15384]393                        - joint_venture_amt
394                        - aaue_share_amt
[15192]395                        - student_union_due_amt
396                        - student_welfare_assurance_amt
397                        - sports_amt
[16942]398                        - library_amt
399                        - lms_sund_amt)
[15192]400                    xmltext = """<payment_item_detail>
[11868]401<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
402<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" />
[12729]403<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
[15387]404<item_detail item_id="3" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="%(student_union_bank_id)s" acct_num="%(student_union_acct)s" />
405<item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
406<item_detail item_id="5" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" />
407<item_detail item_id="6" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />""" % xmldict
408                    if contr_agreement_student(student) == 'second':
409                        xmltext += """"
410<item_detail item_id="7" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" />
[16942]411<item_detail item_id="8" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" />""" % xmldict
412                    if student.entry_session >= 2021 and student.current_mode == 'ug_ft':
[15387]413                        xmltext += """"
[16944]414<item_detail item_id="9" item_name="LMS plus Sundry Fees" item_amt="%(lms_sund_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />""" % xmldict
[16942]415                    xmltext += """"
[15387]416</item_details>
[15396]417</payment_item_detail>"""
[15192]418                else:
419                    xmldict['institution_amt'] = 100 * (
420                        gateway_net_amt(self.context.amount_auth)
421                        - provider_amt
[15384]422                        - joint_venture_amt
423                        - aaue_share_amt
[15192]424                        - student_union_due_amt
425                        - student_welfare_assurance_amt)
426                    xmltext = """<payment_item_detail>
427<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
428<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" />
429<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
[15387]430<item_detail item_id="3" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="%(student_union_bank_id)s" acct_num="%(student_union_acct)s" />
431<item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />""" % xmldict
432                    if contr_agreement_student(student) == 'second':
433                        xmltext += """"
434<item_detail item_id="5" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" />
435<item_detail item_id="6" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" />
[15192]436</item_details>
437</payment_item_detail>""" % xmldict
[15387]438                    else:
439                        xmltext += """"
440</item_details>
[15396]441</payment_item_detail>"""
[15387]442            elif contr_agreement_student(student) == 'second':
443                # Schoolfee without Student Union Fee ands Student Welfare Assurance
[15384]444                xmldict['institution_amt'] = 100 * (
445                    gateway_net_amt(self.context.amount_auth)
[15387]446                    - provider_amt
447                    - joint_venture_amt
448                    - aaue_share_amt)
[15384]449                xmltext = """<payment_item_detail>
450<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
451<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" />
452<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
[15387]453<item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" />
454<item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" />
[15384]455</item_details>
456</payment_item_detail>""" % xmldict
[13400]457            else:
458                xmldict['institution_amt'] = 100 * (
[13414]459                    gateway_net_amt(self.context.amount_auth)
[15387]460                    - provider_amt)
[13400]461                xmltext = """<payment_item_detail>
462<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
463<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" />
464<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
465</item_details>
466</payment_item_detail>""" % xmldict
467
468
469        # Clearance
470        elif self.context.p_category.startswith('clearance'):
[16283]471            xmldict['institution_acct'] = '1010835352'
[15467]472            provider_amt = 0.0
[13532]473            if contr_agreement_student(student) == 'first':
[13403]474                # First agreement
[16681]475                xmldict['institution_acct'] = '1014847058'
476                xmldict['institution_bank_id'] = '7'
477                self.pay_item_id = '104'
[13379]478                if student.current_mode == 'found':
479                    self.pay_item_id = '102'
[16681]480                elif student.current_mode == 'ijmbe':
[16689]481                    self.pay_item_id = '102'
[16681]482                    xmldict['institution_bank_id'] = '123'
483                    xmldict['institution_acct'] = '1012278272'
[13400]484            else:
[13403]485                # Second agreement
[13400]486                self.pay_item_id = '102'
[13527]487                if student.is_postgrad:
488                    self.pay_item_id = '110'
[15463]489                    xmldict['institution_acct'] = '5210006575'
490                    xmldict['institution_bank_id'] = '51'
[15467]491                # ivama: Acceptance fee split is unique to "ug_ft"
492                # The reason for split is perculiar to them only...
493                # That amount was deducted from UTME application fee because
494                # some regulatory body have pegged the application fee which
495                # didn't affect another programmes.
496                if student.current_mode == 'ug_ft':
497                    provider_amt = 1500.0
498            xmldict['provider_amt'] = 100 * provider_amt
[13410]499            if self.context.p_category.endswith('_incl'):
[13400]500                # Clearance including additional fees
[13414]501                gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee)
502                aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee)
[13379]503                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
[13414]504                xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt
[13379]505                xmldict['institution_amt'] = 100 * (
[13414]506                    gateway_net_amt(self.context.amount_auth)
[13409]507                    - gown_fee_amt
[15190]508                    - aaue_lf_fee_amt
509                    - provider_amt)
[13379]510                xmltext = """<payment_item_detail>
[11868]511<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
512<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" />
[16947]513<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010835352" />
514<item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_lf_fee_amt)d" bank_id="117" acct_num="1010835352" />""" % xmldict
[15467]515                if provider_amt:
[15391]516                    xmltext += """"
[15168]517<item_detail item_id="4" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
[11868]518</item_details>
519</payment_item_detail>""" % xmldict
[15391]520                else:
521                    xmltext += """"
522</item_details>
[15396]523</payment_item_detail>"""
[13400]524
[15375]525            elif student.current_mode == 'bridge':
526                # Clearance without any surcharge
527                xmldict['institution_amt'] = 100 * gateway_net_amt(
528                    self.context.amount_auth)
529                xmltext = """<payment_item_detail>
530<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
531<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" />
532</item_details>
533</payment_item_detail>""" % xmldict
534
[13381]535            else:
[13400]536                # Clearance without additional fees
[13381]537                xmldict['institution_amt'] = 100 * (
[15190]538                    gateway_net_amt(self.context.amount_auth)
539                    - provider_amt)
[15168]540                xmltext = """<payment_item_detail>
541<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
[15396]542<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" />""" % xmldict
[15467]543                if provider_amt:
[15391]544                        xmltext += """"
[15168]545<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
546</item_details>
547</payment_item_detail>""" % xmldict
[15391]548                else:
549                        xmltext += """"
550</item_details>
[15396]551</payment_item_detail>"""
[13379]552
[13403]553        # Union Dues
[13400]554        elif self.context.p_category == 'union':
555            self.pay_item_id = '103'
556            xmldict['institution_amt'] = 100 * (
[13414]557                gateway_net_amt(self.context.amount_auth))
[14980]558            if contr_agreement_student(student) == 'first':
559                # First agreement
560                xmldict['institution_acct'] = '0051005007'
561                xmldict['institution_bank_id'] = '31'
562            else:
563                # Second agreement
564                xmldict['institution_bank_id'] = '7'
565                xmldict['institution_acct'] = '1019763348'
[13379]566
[13403]567        # Lapel/File
[13400]568        elif self.context.p_category == 'lapel':
569            self.pay_item_id = '104'
570            xmldict['institution_amt'] = 100 * (
[13414]571                gateway_net_amt(self.context.amount_auth))
[13381]572
[13403]573        # Welfare Assurance
[13400]574        elif self.context.p_category == 'welfare':
575            self.pay_item_id = '105'
[14979]576            xmldict['institution_acct'] = '1006407792'
577            xmldict['institution_bank_id'] = '123'
[13400]578            xmldict['institution_amt'] = 100 * (
[13414]579                gateway_net_amt(self.context.amount_auth))
[13381]580
[14234]581        # ID Card
582        elif self.context.p_category == 'id_card':
583            self.pay_item_id = '000'
584            xmldict['institution_amt'] = 100 * (
585                gateway_net_amt(self.context.amount_auth))
586
[13400]587        # Matric Gown
588        elif self.context.p_category == 'matric_gown':
589            self.pay_item_id = '106'
590            xmldict['institution_amt'] = 100 * (
[13414]591                gateway_net_amt(self.context.amount_auth))
[13381]592
[13400]593        # Concessional
594        elif self.context.p_category == 'concessional':
595            self.pay_item_id = '107'
596            xmldict['institution_amt'] = 100 * (
[13414]597                gateway_net_amt(self.context.amount_auth))
[13381]598
[13400]599        # Hostel Maintenance
600        elif self.context.p_category == 'hostel_maintenance':
[14223]601            provider_amt = 500.0
[13400]602            self.pay_item_id = '109'
[16661]603            xmldict['institution_acct'] = '1006406795'
604            xmldict['institution_bank_id'] = '123'
[14223]605            xmldict['provider_amt'] = 100 * provider_amt
[13400]606            xmldict['institution_amt'] = 100 * (
[14223]607                gateway_net_amt(self.context.amount_auth) - provider_amt)
[13400]608            xmltext = """<payment_item_detail>
[13383]609<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
610<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" />
[14223]611<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
[13383]612</item_details>
613</payment_item_detail>""" % xmldict
614
[14258]615        # GST Fees
616        elif self.context.p_category.startswith('gst_'):
[14687]617            if contr_agreement_student(student) == 'first':
618                self.pay_item_id = '115'
619            else:
620                self.pay_item_id = '116'
[14979]621            xmldict['institution_acct'] = '1010893123'
622            xmldict['institution_bank_id'] = '117'
[14258]623            xmldict['institution_amt'] = 100 * (
624                gateway_net_amt(self.context.amount_auth))
625
626        # ENT Fees
627        elif self.context.p_category.startswith('ent_'):
[14687]628            if contr_agreement_student(student) == 'first':
629                self.pay_item_id = '114'
630            else:
631                self.pay_item_id = '118'
[14979]632            xmldict['institution_acct'] = '6220029828'
633            xmldict['institution_bank_id'] = '51'
[14258]634            xmldict['institution_amt'] = 100 * (
635                gateway_net_amt(self.context.amount_auth))
636
637        # Faculty and Departmental Dues
638        elif self.context.p_category == 'fac_dep':
[15742]639            xmldict['institution_acct'] = '1016425386'
640            xmldict['institution_bank_id'] = '117'
[14258]641            self.pay_item_id = '117'
642            xmldict['institution_amt'] = 100 * (
643                gateway_net_amt(self.context.amount_auth))
644
[14376]645        # Restitution Fee
646        elif self.context.p_category == 'restitution':
647            self.pay_item_id = '117'
648            xmldict['institution_amt'] = 100 * (
649                gateway_net_amt(self.context.amount_auth))
650
[16021]651        # Faculty Laboratory Due
[16080]652        elif self.context.p_category in ('lab_1', 'lab_2'):
[16021]653            xmldict['institution_acct'] = '1016425386'
654            xmldict['institution_bank_id'] = '117'
655            self.pay_item_id = '117'
656            xmldict['institution_amt'] = 100 * (
657                gateway_net_amt(self.context.amount_auth))
658
[15971]659        # Sports Fee
[15978]660        #elif self.context.p_category == 'sports':
661        #    self.pay_item_id = '105'
662        #    xmldict['institution_amt'] = 100 * (
663        #        gateway_net_amt(self.context.amount_auth))
[15971]664
665        # Library Fee
[15978]666        #elif self.context.p_category == 'library':
667        #    self.pay_item_id = '105'
668        #    xmldict['institution_amt'] = 100 * (
669        #        gateway_net_amt(self.context.amount_auth))
[15971]670
671        # Library PG Fee
[15978]672        #elif self.context.p_category == 'library_pg':
673        #    self.pay_item_id = '105'
674        #    xmldict['institution_amt'] = 100 * (
675        #        gateway_net_amt(self.context.amount_auth))
676
[16940]677        # Exam Fee
678        elif self.context.p_category == 'exam':
[16941]679            self.pay_item_id = '103'
[16951]680            xmldict['institution_acct'] = '1012278272'
681            xmldict['institution_bank_id'] = '123'
[16940]682            xmldict['institution_amt'] = 100 * (
683                gateway_net_amt(self.context.amount_auth))
684
[16942]685        # LMS + Sundry Fees
686        elif self.context.p_category == 'lms_sund':
687            self.pay_item_id = '103'
688            xmldict['institution_amt'] = 100 * (
689                gateway_net_amt(self.context.amount_auth))
690
[15992]691        # Sports & Library Fee    temporarily in 2020
[15978]692        elif self.context.p_category == 'sports_library':
[15976]693            self.pay_item_id = '105'
[15992]694            xmldict['sports_amt'] = 100 * 3000.0
695            xmldict['library_amt'] = 100 * 1000.0
696            xmltext = """<payment_item_detail>
697<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
698<item_detail item_id="1" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" />
699<item_detail item_id="2" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />
700</item_details>
701</payment_item_detail>""" % xmldict
[15971]702
[14676]703        # Late Registration Fee
704        elif self.context.p_category == 'late_registration':
[14686]705            if contr_agreement_student(student) == 'first':
706                self.pay_item_id = '113'
707            else:
708                self.pay_item_id = '123'
[14676]709            xmldict['institution_amt'] = 100 * (
710                gateway_net_amt(self.context.amount_auth))
[15463]711            if student.is_postgrad:
712                xmldict['institution_acct'] = '5210006575'
713                xmldict['institution_bank_id'] = '51'
[14945]714        if not xmltext:
[14676]715            xmltext = """<payment_item_detail>
716<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
717<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" />
718</item_details>
719</payment_item_detail>""" % xmldict
[11868]720        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
721        self.context.provider_amt = provider_amt
[15761]722        self.context.gateway_amt = self.context.amount_auth - gateway_net_amt(
723            self.context.amount_auth)
[15471]724        xmlitems = ''
725        xmldoc = minidom.parseString(xmltext)
726        itemlist = xmldoc.getElementsByTagName('item_detail')
727        for s in itemlist:
[16944]728            xmlitems += "%s: %s, %s %s, %s (%s)  " % (
[15471]729                s.attributes['item_id'].value,
730                s.attributes['item_name'].value,
[16942]731                u'\u20a6',
[15471]732                int(s.attributes['item_amt'].value)/100,
733                s.attributes['acct_num'].value,
734                s.attributes['bank_id'].value,
735                )
736        self.context.p_split_data = xmlitems
[15761]737        self.amount_auth = int(100 * self.context.amount_auth)
[11868]738        hashargs = (
739            self.context.p_id +
[13382]740            self.product_id +
[11868]741            self.pay_item_id +
742            str(int(self.amount_auth)) +
743            self.site_redirect_url +
744            self.mac)
745        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
746        return
747
748
[11846]749class CustomInterswitchPaymentRequestWebservicePageApplicant(
750    InterswitchPaymentRequestWebservicePageApplicant):
[13586]751    """Request webservice view for the CollegePAY gateway
752    """
753    grok.context(ICustomApplicantOnlinePayment)
754    gateway_host = HOST
755    gateway_url = URL
756    https = HTTPS
[13379]757
[13586]758    @property
[13606]759    def mac(self):
760        if contr_agreement_applicant(self.context.__parent__) == 'first':
761            return MAC_PT
762        return MAC_REGULAR
763
764    @property
[13586]765    def product_id(self):
766        if contr_agreement_applicant(self.context.__parent__) == 'first':
767            return PRODUCT_ID_PT
768        return PRODUCT_ID_REGULAR
769
770class CustomInterswitchPaymentVerifyWebservicePageApplicant(
771    InterswitchPaymentVerifyWebservicePageApplicant):
772    """Payment verify view for the CollegePAY gateway
[11846]773    """
774    grok.context(ICustomApplicantOnlinePayment)
775    gateway_host = HOST
[13586]776    gateway_url = URL
[11916]777    https = HTTPS
[11868]778
[13532]779    @property
[13606]780    def mac(self):
781        if contr_agreement_applicant(self.context.__parent__) == 'first':
782            return MAC_PT
783        return MAC_REGULAR
784
785    @property
[13532]786    def product_id(self):
787        if contr_agreement_applicant(self.context.__parent__) == 'first':
788            return PRODUCT_ID_PT
789        return PRODUCT_ID_REGULAR
790
[11868]791class CustomInterswitchPaymentRequestWebservicePageStudent(
792    InterswitchPaymentRequestWebservicePageStudent):
[13586]793    """Request webservice view for the CollegePAY gateway
[11868]794    """
795    grok.context(ICustomStudentOnlinePayment)
796    gateway_host = HOST
[13586]797    gateway_url = URL
[11916]798    https = HTTPS
[13379]799
800    @property
[13606]801    def mac(self):
802        if contr_agreement_student(self.context.student) == 'first':
803            return MAC_PT
804        return MAC_REGULAR
805
806    @property
[13379]807    def product_id(self):
[13532]808        if contr_agreement_student(self.context.student) == 'first':
[13379]809            return PRODUCT_ID_PT
810        return PRODUCT_ID_REGULAR
[13586]811
812class CustomInterswitchPaymentVerifyWebservicePageStudent(
813    InterswitchPaymentVerifyWebservicePageStudent):
814    """Payment verify view for the CollegePAY gateway
815    """
816    grok.context(ICustomStudentOnlinePayment)
817    gateway_host = HOST
818    gateway_url = URL
819    https = HTTPS
820
821    @property
[13606]822    def mac(self):
823        if contr_agreement_student(self.context.student) == 'first':
824            return MAC_PT
825        return MAC_REGULAR
826
827    @property
[13586]828    def product_id(self):
829        if contr_agreement_student(self.context.student) == 'first':
830            return PRODUCT_ID_PT
831        return PRODUCT_ID_REGULAR
Note: See TracBrowser for help on using the repository browser.