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

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

Change WAEAC bank account.

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