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

Last change on this file since 15735 was 15735, checked in by Henrik Bettermann, 5 years ago

Introduce the "Scanned Document" field on the send2019

WAEAC has no technology fee charge for the applications ver and send.

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