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

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

Exclude WAeAC charges/fee from app_balance payments.

  • Property svn:keywords set to Id
File size: 33.6 KB
RevLine 
[12730]1## $Id: browser.py 15591 2019-09-18 10:16:12Z 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'
[11846]137        xmldict = {}
138        xmldict['detail_ref'] = self.context.p_id
139        xmldict['provider_amt'] = 100 * provider_amt
[15135]140        xmldict['provider_acct'] = self.provider_acct
141        xmldict['provider_bank_id'] = self.provider_bank_id
[11846]142        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
[15224]143        xmldict['institution_acct'] = self.institution_acct
144        xmldict['institution_bank_id'] = self.institution_bank_id
[13532]145        xmldict['institution_item_name'] = self.category
[11846]146        xmldict['institution_name'] = INSTITUTION_NAME
[15224]147        xmldict['institution_amt'] = 100 * (
148            self.context.amount_auth - provider_amt - GATEWAY_AMT)
[15512]149
[15224]150        xmltext = """<payment_item_detail>
151<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
152<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" />
153<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" />
154</item_details>
155</payment_item_detail>""" % xmldict
[14121]156
[15512]157        if provider_amt == 0.0:
158            xmltext = """<payment_item_detail>
159<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
160<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" />
161</item_details>
162</payment_item_detail>""" % xmldict
163
[14121]164        if self.applicant.applicant_id.startswith('pg'):
165            handbook_amount = 2000.0
166            xmldict['handbook_amount'] = 100 * handbook_amount
167            xmldict['institution_amt'] = 100 * (
168                self.context.amount_auth - provider_amt - handbook_amount -GATEWAY_AMT)
169            xmltext = """<payment_item_detail>
[11846]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" />
[14945]173<item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1010827641" />
[11846]174</item_details>
175</payment_item_detail>""" % xmldict
[14121]176
[11846]177        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
178        self.context.provider_amt = provider_amt
179        self.context.gateway_amt = GATEWAY_AMT
[15473]180        xmlitems = ''
181        xmldoc = minidom.parseString(xmltext)
182        itemlist = xmldoc.getElementsByTagName('item_detail')
183        for s in itemlist:
184            xmlitems += "%s: %s, N%s, %s (%s)  " % (
185                s.attributes['item_id'].value,
186                s.attributes['item_name'].value,
187                int(s.attributes['item_amt'].value)/100,
188                s.attributes['acct_num'].value,
189                s.attributes['bank_id'].value,
190                )
191        self.context.p_split_data = xmlitems
[11846]192        hashargs = (
193            self.context.p_id +
[13532]194            self.product_id +
[11846]195            self.pay_item_id +
196            str(int(self.amount_auth)) +
197            self.site_redirect_url +
198            self.mac)
199        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
200
201        return
202
[11868]203class CustomInterswitchPageStudent(InterswitchPageStudent):
204    """ View which sends a POST request to the Interswitch
205    CollegePAY payment gateway.
206    """
207    grok.context(ICustomStudentOnlinePayment)
208    action = POST_ACTION
209    site_name = SITE_NAME
210    currency = CURRENCY
[14248]211    pay_item_id = '000'
[11846]212
[11868]213    def update(self):
[12975]214        error = self.init_update()
[13376]215
[12975]216        if error:
217            self.flash(error, type='danger')
218            self.redirect(self.url(self.context, '@@index'))
219            return
[13400]220
[11868]221        student = self.student
[13408]222        p_session = self.context.p_session
[13400]223        try:
[13408]224            academic_session = grok.getSite()['configuration'][str(p_session)]
[13400]225        except KeyError:
[13407]226            self.flash(_(u'Session configuration object is not available.'),
227                       type='danger')
[13400]228            self.redirect(self.url(self.context, '@@index'))
229            return
[13532]230        if contr_agreement_student(student) == 'first':
[13382]231            self.product_id = PRODUCT_ID_PT
[13606]232            self.mac = MAC_PT
[13382]233        else:
234            self.product_id = PRODUCT_ID_REGULAR
[13606]235            self.mac = MAC_REGULAR
[13382]236
[12975]237        # To guarantee that cleared students pay both acceptance fee
238        # and school fees, the page can only be accessed
239        # for school fee payments if acceptance/clearance fee has
240        # been successfully queried/paid beforehand. This
241        # requirement applies to students in state 'cleared' and
[14380]242        # entry_session greater than 2012 only.
[13400]243        if self.context.p_category.startswith('schoolfee') and \
[12975]244            student.state == CLEARED and \
245            student.entry_session > 2012:
246            acceptance_fee_paid = False
247            for ticket in student['payments'].values():
248                if ticket.p_state == 'paid' and \
[13400]249                    ticket.p_category.startswith('clearance'):
[12975]250                    acceptance_fee_paid = True
251                    break
252            if not acceptance_fee_paid:
253                self.flash(
254                    _('Please pay acceptance fee first.'), type="danger")
255                self.redirect(self.url(self.context, '@@index'))
256                return
257
[11868]258        xmldict = self.xmldict
[12729]259        xmltext = ""
[14945]260        xmldict['institution_acct'] = '1010827641'
261        xmldict['institution_bank_id'] = '117'
[11868]262        xmldict['detail_ref'] = self.context.p_id
263        xmldict['provider_acct'] = PROVIDER_ACCT
264        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
265        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
266        xmldict['institution_item_name'] = self.category
267        xmldict['institution_name'] = INSTITUTION_NAME
[13381]268        provider_amt = 0.0
[12729]269
[13400]270        # Schoolfee
271        if self.context.p_category.startswith('schoolfee'):
[13532]272            if contr_agreement_student(student) == 'first':
[13403]273                # First agreement
[15479]274                provider_amt = 1900.0
[15387]275                joint_venture_amt = 0.0
276                aaue_share_amt = 0.0
[13414]277                student_union_due_amt = gateway_net_amt(
278                    academic_session.union_fee)
279                student_welfare_assurance_amt = gateway_net_amt(
280                    academic_session.welfare_fee)
[15180]281                sports_amt = gateway_net_amt(
282                    academic_session.sports_fee)
283                library_amt = gateway_net_amt(
284                    academic_session.library_fee)
[15181]285                library_amt_pg = gateway_net_amt(
286                    academic_session.library_fee_pg)
[14980]287                xmldict['student_union_bank_id'] = '31'
288                xmldict['student_union_acct'] = '0051005007'
[15384]289                xmldict['aaue_share_bank_id'] = '117'
290                xmldict['aaue_share_acct'] = '1010827641'
291                xmldict['joint_venture_bank_id'] = '117'
292                xmldict['joint_venture_acct'] = '1010827641'
[15359]293                xmldict['institution_acct'] = '1014847058'
294                xmldict['institution_bank_id'] = '7'
[13379]295                if student.current_mode == 'found':
296                    self.pay_item_id = '103'
297                else:
298                    self.pay_item_id = '105'
[13400]299            else:
[13403]300                # Second agreement
[15384]301                joint_venture_amt = 1000.0
302                aaue_share_amt = 1500.0
[15479]303                provider_amt = 1500.0
[13414]304                student_union_due_amt = gateway_net_amt(
305                    academic_session.union_fee)
306                student_welfare_assurance_amt = gateway_net_amt(
307                    academic_session.welfare_fee)
[15180]308                sports_amt = gateway_net_amt(
309                    academic_session.sports_fee)
310                library_amt = gateway_net_amt(
311                    academic_session.library_fee)
[15181]312                library_amt_pg = gateway_net_amt(
313                    academic_session.library_fee_pg)
[14980]314                xmldict['student_union_bank_id'] = '7'
315                xmldict['student_union_acct'] = '1019763348'
[15384]316                xmldict['aaue_share_bank_id'] = '117'
317                xmldict['aaue_share_acct'] = '1010827641'
318                xmldict['joint_venture_bank_id'] = '117'
319                xmldict['joint_venture_acct'] = '1010827641'
[13644]320                self.pay_item_id = '107'
[13527]321                if student.is_postgrad:
322                    self.pay_item_id = '111'
[15460]323                    xmldict['institution_acct'] = '5210006575'
324                    xmldict['institution_bank_id'] = '51'
[14469]325                if student.current_mode == 'ijmbe':
[14523]326                    self.pay_item_id = '119'
[14469]327                    xmldict['joint_venture_bank_id'] = '117'
[14945]328                    xmldict['joint_venture_acct'] = '1010827641'
[13400]329
330            xmldict['provider_amt'] = 100 * provider_amt
[15384]331            xmldict['joint_venture_amt'] = 100 * joint_venture_amt
332            xmldict['aaue_share_amt'] = 100 * aaue_share_amt
[13732]333            if self.context.p_item == 'Balance':
334                xmldict['institution_amt'] = 100 * (
335                    gateway_net_amt(self.context.amount_auth))
[15479]336
337
338            elif self.context.p_category == 'schoolfee_2':
339                xmldict['institution_amt'] = 100 * gateway_net_amt(
340                    self.context.amount_auth)
341                xmltext = """<payment_item_detail>
342<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
343<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" />
344</item_details>
345</payment_item_detail>""" % xmldict
[14987]346            elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \
347                and student.current_mode != 'ijmbe':
[13400]348                # Schoolfee including additional fees
[13379]349                xmldict['student_union_due_amt'] = 100 * student_union_due_amt
350                xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
[15192]351
352                if student.entry_session == 2018 and student.is_fresh:
353                    xmldict['sports_amt'] = 100 * sports_amt
354                    if student.is_postgrad:
355                        xmldict['library_amt'] = 100 * library_amt_pg
356                    else:
357                        xmldict['library_amt'] = 100 * library_amt
358                    xmldict['institution_amt'] = 100 * (
359                        gateway_net_amt(self.context.amount_auth)
360                        - provider_amt
[15384]361                        - joint_venture_amt
362                        - aaue_share_amt
[15192]363                        - student_union_due_amt
364                        - student_welfare_assurance_amt
365                        - sports_amt
366                        - library_amt)
367                    xmltext = """<payment_item_detail>
[11868]368<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
369<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]370<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]371<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" />
372<item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
373<item_detail item_id="5" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" />
374<item_detail item_id="6" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />""" % xmldict
375                    if contr_agreement_student(student) == 'second':
376                        xmltext += """"
377<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" />
378<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]379</item_details>
380</payment_item_detail>""" % xmldict
[15387]381                    else:
382                        xmltext += """"
383</item_details>
[15396]384</payment_item_detail>"""
[15192]385                else:
386                    xmldict['institution_amt'] = 100 * (
387                        gateway_net_amt(self.context.amount_auth)
388                        - provider_amt
[15384]389                        - joint_venture_amt
390                        - aaue_share_amt
[15192]391                        - student_union_due_amt
392                        - student_welfare_assurance_amt)
393                    xmltext = """<payment_item_detail>
394<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
395<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" />
396<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]397<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" />
398<item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />""" % xmldict
399                    if contr_agreement_student(student) == 'second':
400                        xmltext += """"
401<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" />
402<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]403</item_details>
404</payment_item_detail>""" % xmldict
[15387]405                    else:
406                        xmltext += """"
407</item_details>
[15396]408</payment_item_detail>"""
[15387]409            elif contr_agreement_student(student) == 'second':
410                # Schoolfee without Student Union Fee ands Student Welfare Assurance
[15384]411                xmldict['institution_amt'] = 100 * (
412                    gateway_net_amt(self.context.amount_auth)
[15387]413                    - provider_amt
414                    - joint_venture_amt
415                    - aaue_share_amt)
[15384]416                xmltext = """<payment_item_detail>
417<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
418<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" />
419<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]420<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" />
421<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]422</item_details>
423</payment_item_detail>""" % xmldict
[13400]424            else:
425                xmldict['institution_amt'] = 100 * (
[13414]426                    gateway_net_amt(self.context.amount_auth)
[15387]427                    - provider_amt)
[13400]428                xmltext = """<payment_item_detail>
429<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
430<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" />
431<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" />
432</item_details>
433</payment_item_detail>""" % xmldict
434
435
436        # Clearance
437        elif self.context.p_category.startswith('clearance'):
[15467]438            provider_amt = 0.0
[13532]439            if contr_agreement_student(student) == 'first':
[13403]440                # First agreement
[13379]441                if student.current_mode == 'found':
442                    self.pay_item_id = '102'
443                else:
444                    self.pay_item_id = '104'
[15359]445                xmldict['institution_acct'] = '1014847058'
446                xmldict['institution_bank_id'] = '7'
[13400]447            else:
[13403]448                # Second agreement
[13400]449                self.pay_item_id = '102'
[13527]450                if student.is_postgrad:
451                    self.pay_item_id = '110'
[15463]452                    xmldict['institution_acct'] = '5210006575'
453                    xmldict['institution_bank_id'] = '51'
[14469]454                if student.current_mode == 'ijmbe':
[14523]455                    self.pay_item_id = '120'
[15467]456                # ivama: Acceptance fee split is unique to "ug_ft"
457                # The reason for split is perculiar to them only...
458                # That amount was deducted from UTME application fee because
459                # some regulatory body have pegged the application fee which
460                # didn't affect another programmes.
461                if student.current_mode == 'ug_ft':
462                    provider_amt = 1500.0
463            xmldict['provider_amt'] = 100 * provider_amt
[13410]464            if self.context.p_category.endswith('_incl'):
[13400]465                # Clearance including additional fees
[13414]466                gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee)
467                aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee)
[13379]468                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
[13414]469                xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt
[13379]470                xmldict['institution_amt'] = 100 * (
[13414]471                    gateway_net_amt(self.context.amount_auth)
[13409]472                    - gown_fee_amt
[15190]473                    - aaue_lf_fee_amt
474                    - provider_amt)
[13379]475                xmltext = """<payment_item_detail>
[11868]476<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
477<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]478<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" />
[15391]479<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]480                if provider_amt:
[15391]481                    xmltext += """"
[15168]482<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]483</item_details>
484</payment_item_detail>""" % xmldict
[15391]485                else:
486                    xmltext += """"
487</item_details>
[15396]488</payment_item_detail>"""
[13400]489
[15375]490            elif student.current_mode == 'bridge':
491                # Clearance without any surcharge
492                xmldict['institution_amt'] = 100 * gateway_net_amt(
493                    self.context.amount_auth)
494                xmltext = """<payment_item_detail>
495<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
496<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" />
497</item_details>
498</payment_item_detail>""" % xmldict
499
[13381]500            else:
[13400]501                # Clearance without additional fees
[13381]502                xmldict['institution_amt'] = 100 * (
[15190]503                    gateway_net_amt(self.context.amount_auth)
504                    - provider_amt)
[15168]505                xmltext = """<payment_item_detail>
506<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
[15396]507<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]508                if provider_amt:
[15391]509                        xmltext += """"
[15168]510<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" />
511</item_details>
512</payment_item_detail>""" % xmldict
[15391]513                else:
514                        xmltext += """"
515</item_details>
[15396]516</payment_item_detail>"""
[13379]517
[13403]518        # Union Dues
[13400]519        elif self.context.p_category == 'union':
520            self.pay_item_id = '103'
521            xmldict['institution_amt'] = 100 * (
[13414]522                gateway_net_amt(self.context.amount_auth))
[14980]523            if contr_agreement_student(student) == 'first':
524                # First agreement
525                xmldict['institution_acct'] = '0051005007'
526                xmldict['institution_bank_id'] = '31'
527            else:
528                # Second agreement
529                xmldict['institution_bank_id'] = '7'
530                xmldict['institution_acct'] = '1019763348'
[13379]531
[13403]532        # Lapel/File
[13400]533        elif self.context.p_category == 'lapel':
534            self.pay_item_id = '104'
535            xmldict['institution_amt'] = 100 * (
[13414]536                gateway_net_amt(self.context.amount_auth))
[13381]537
[13403]538        # Welfare Assurance
[13400]539        elif self.context.p_category == 'welfare':
540            self.pay_item_id = '105'
[14979]541            xmldict['institution_acct'] = '1006407792'
542            xmldict['institution_bank_id'] = '123'
[13400]543            xmldict['institution_amt'] = 100 * (
[13414]544                gateway_net_amt(self.context.amount_auth))
[13381]545
[14234]546        # ID Card
547        elif self.context.p_category == 'id_card':
548            self.pay_item_id = '000'
549            xmldict['institution_amt'] = 100 * (
550                gateway_net_amt(self.context.amount_auth))
551
[13400]552        # Matric Gown
553        elif self.context.p_category == 'matric_gown':
554            self.pay_item_id = '106'
555            xmldict['institution_amt'] = 100 * (
[13414]556                gateway_net_amt(self.context.amount_auth))
[13381]557
[13400]558        # Concessional
559        elif self.context.p_category == 'concessional':
560            self.pay_item_id = '107'
561            xmldict['institution_amt'] = 100 * (
[13414]562                gateway_net_amt(self.context.amount_auth))
[13381]563
[13400]564        # Hostel Maintenance
565        elif self.context.p_category == 'hostel_maintenance':
[14223]566            provider_amt = 500.0
[13400]567            self.pay_item_id = '109'
[14223]568            xmldict['provider_amt'] = 100 * provider_amt
[13400]569            xmldict['institution_amt'] = 100 * (
[14223]570                gateway_net_amt(self.context.amount_auth) - provider_amt)
[13400]571            xmltext = """<payment_item_detail>
[13383]572<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
573<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]574<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]575</item_details>
576</payment_item_detail>""" % xmldict
577
[14258]578        # GST Fees
579        elif self.context.p_category.startswith('gst_'):
[14687]580            if contr_agreement_student(student) == 'first':
581                self.pay_item_id = '115'
582            else:
583                self.pay_item_id = '116'
[14979]584            xmldict['institution_acct'] = '1010893123'
585            xmldict['institution_bank_id'] = '117'
[14258]586            xmldict['institution_amt'] = 100 * (
587                gateway_net_amt(self.context.amount_auth))
588
589        # ENT Fees
590        elif self.context.p_category.startswith('ent_'):
[14687]591            if contr_agreement_student(student) == 'first':
592                self.pay_item_id = '114'
593            else:
594                self.pay_item_id = '118'
[14979]595            xmldict['institution_acct'] = '6220029828'
596            xmldict['institution_bank_id'] = '51'
[14258]597            xmldict['institution_amt'] = 100 * (
598                gateway_net_amt(self.context.amount_auth))
599
600        # Faculty and Departmental Dues
601        elif self.context.p_category == 'fac_dep':
602            self.pay_item_id = '117'
603            xmldict['institution_amt'] = 100 * (
604                gateway_net_amt(self.context.amount_auth))
605
[14376]606        # Restitution Fee
607        elif self.context.p_category == 'restitution':
608            self.pay_item_id = '117'
609            xmldict['institution_amt'] = 100 * (
610                gateway_net_amt(self.context.amount_auth))
611
[14676]612        # Late Registration Fee
613        elif self.context.p_category == 'late_registration':
[14686]614            if contr_agreement_student(student) == 'first':
615                self.pay_item_id = '113'
616            else:
617                self.pay_item_id = '123'
[14676]618            xmldict['institution_amt'] = 100 * (
619                gateway_net_amt(self.context.amount_auth))
[15463]620            if student.is_postgrad:
621                xmldict['institution_acct'] = '5210006575'
622                xmldict['institution_bank_id'] = '51'
[14945]623        if not xmltext:
[14676]624            xmltext = """<payment_item_detail>
625<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
626<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" />
627</item_details>
628</payment_item_detail>""" % xmldict
[11868]629        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
630        self.context.provider_amt = provider_amt
[13437]631        self.context.gateway_amt = self.amount_auth - gateway_net_amt(
632            self.amount_auth)
[15471]633        xmlitems = ''
634        xmldoc = minidom.parseString(xmltext)
635        itemlist = xmldoc.getElementsByTagName('item_detail')
636        for s in itemlist:
637            xmlitems += "%s: %s, N%s, %s (%s)  " % (
638                s.attributes['item_id'].value,
639                s.attributes['item_name'].value,
640                int(s.attributes['item_amt'].value)/100,
641                s.attributes['acct_num'].value,
642                s.attributes['bank_id'].value,
643                )
644        self.context.p_split_data = xmlitems
[11868]645        hashargs = (
646            self.context.p_id +
[13382]647            self.product_id +
[11868]648            self.pay_item_id +
649            str(int(self.amount_auth)) +
650            self.site_redirect_url +
651            self.mac)
652        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
653        return
654
655
[11846]656class CustomInterswitchPaymentRequestWebservicePageApplicant(
657    InterswitchPaymentRequestWebservicePageApplicant):
[13586]658    """Request webservice view for the CollegePAY gateway
659    """
660    grok.context(ICustomApplicantOnlinePayment)
661    gateway_host = HOST
662    gateway_url = URL
663    https = HTTPS
[13379]664
[13586]665    @property
[13606]666    def mac(self):
667        if contr_agreement_applicant(self.context.__parent__) == 'first':
668            return MAC_PT
669        return MAC_REGULAR
670
671    @property
[13586]672    def product_id(self):
673        if contr_agreement_applicant(self.context.__parent__) == 'first':
674            return PRODUCT_ID_PT
675        return PRODUCT_ID_REGULAR
676
677class CustomInterswitchPaymentVerifyWebservicePageApplicant(
678    InterswitchPaymentVerifyWebservicePageApplicant):
679    """Payment verify view for the CollegePAY gateway
[11846]680    """
681    grok.context(ICustomApplicantOnlinePayment)
682    gateway_host = HOST
[13586]683    gateway_url = URL
[11916]684    https = HTTPS
[11868]685
[13532]686    @property
[13606]687    def mac(self):
688        if contr_agreement_applicant(self.context.__parent__) == 'first':
689            return MAC_PT
690        return MAC_REGULAR
691
692    @property
[13532]693    def product_id(self):
694        if contr_agreement_applicant(self.context.__parent__) == 'first':
695            return PRODUCT_ID_PT
696        return PRODUCT_ID_REGULAR
697
[11868]698class CustomInterswitchPaymentRequestWebservicePageStudent(
699    InterswitchPaymentRequestWebservicePageStudent):
[13586]700    """Request webservice view for the CollegePAY gateway
[11868]701    """
702    grok.context(ICustomStudentOnlinePayment)
703    gateway_host = HOST
[13586]704    gateway_url = URL
[11916]705    https = HTTPS
[13379]706
707    @property
[13606]708    def mac(self):
709        if contr_agreement_student(self.context.student) == 'first':
710            return MAC_PT
711        return MAC_REGULAR
712
713    @property
[13379]714    def product_id(self):
[13532]715        if contr_agreement_student(self.context.student) == 'first':
[13379]716            return PRODUCT_ID_PT
717        return PRODUCT_ID_REGULAR
[13586]718
719class CustomInterswitchPaymentVerifyWebservicePageStudent(
720    InterswitchPaymentVerifyWebservicePageStudent):
721    """Payment verify view for the CollegePAY gateway
722    """
723    grok.context(ICustomStudentOnlinePayment)
724    gateway_host = HOST
725    gateway_url = URL
726    https = HTTPS
727
728    @property
[13606]729    def mac(self):
730        if contr_agreement_student(self.context.student) == 'first':
731            return MAC_PT
732        return MAC_REGULAR
733
734    @property
[13586]735    def product_id(self):
736        if contr_agreement_student(self.context.student) == 'first':
737            return PRODUCT_ID_PT
738        return PRODUCT_ID_REGULAR
Note: See TracBrowser for help on using the repository browser.