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

Last change on this file since 18200 was 18200, checked in by Henrik Bettermann, 13 months ago

Skip correctly.

  • Property svn:executable set to *
File size: 27.0 KB
RevLine 
[17431]1    # -*- coding: utf-8 -*-
2## $Id: browser.py 17429 2023-06-05 04:34:30Z henrik $
3##
4## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
5## This program is free software; you can redistribute it and/or modify
6## it under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 2 of the License, or
8## (at your option) any later version.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty ofself.context.amount_auth
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with this program; if not, write to the Free Software
17## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18##
19import httplib
20import hashlib
21import grok
22import os
23import csv
24from xml.dom import minidom
25from zope.interface import Interface
26from zope.component import queryAdapter
27from waeup.kofa.interfaces import CLEARED
28from kofacustom.nigeria.interswitch.browser import (
29    InterswitchPaymentRequestWebservicePageStudent,
30    InterswitchPaymentRequestWebservicePageApplicant,
31    InterswitchPaymentVerifyWebservicePageApplicant,
32    InterswitchPaymentVerifyWebservicePageStudent,
33    InterswitchPageStudent, InterswitchPageApplicant,
34    module_activated,
35    )
36from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment
37from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment
[17447]38from waeup.aaue.students.utils import SFEECHANGES
[17431]39from waeup.aaue.interfaces import MessageFactory as _
40
41PRODUCT_ID = '5845'
42SITE_NAME = 'aaue.waeup.org'
43PROVIDER_ACCT = '0200244434'
44PROVIDER_BANK_ID = '11'
[17441]45PROVIDER_ITEM_NAME = 'WAeAC Portal Fee'
[17431]46INSTITUTION_NAME = 'AAU Ekpoma'
47CURRENCY = '566'
[18087]48GATEWAY_AMT = 300.0
[17431]49POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
50
51HOST = 'webpay.interswitchng.com'
52URL = '/paydirect/api/v1/gettransaction.json'
53HTTPS = True
54MAC = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023'
55
56httplib.HTTPSConnection.debuglevel = 0
57
58BANK_ACCOUNTS = {
[17656]59    'edohis':    ('2043582455', '8'),
[17514]60    'union':     ('1019763348', '7'),
[17515]61    'union_pt':  ('0051005007', '31'),
[17514]62    'sport':     ('1021941220', '7'),
[18196]63    #'access':    ('1012688013', '123'),
[17514]64    'notebook':  ('4011210501', '51'),
65    'accredit':  ('5060023412', '51'),
66    'library':   ('2000122995', '8'),
67    'fac1':      ('1022438743', '7'),
68    'fac2':      ('2000249757', '8'),
69    'fac3':      ('1012678566', '123'),
70    'matricgown':('2000249757', '8'),
71    'lapel':     ('2000249757', '8'),
72    'lmsplus':   ('5060023429', '51'),
[17456]73
[17657]74    'acceptance': ('2043582644', '8'),
[18195]75    'parttime': ('1014847058', '7'),
[17468]76
[17582]77    'ijmb':   ('1012278272', '123'),
[17699]78    'exam':   ('1012278272', '123'),
[17582]79
[17699]80
[17456]81    'hostel_maintenance': ('1006406795', '123'),
[18045]82    'hostel_balance':     ('1006406795', '123'),
[18033]83    'bed_allocation':     ('1012327077', '123'),
[17456]84    'late_registration':  ('5210006575', '51'),
85    'ent_combined':       ('6220029828', '51'),
86    'ent_registration_0': ('6220029828', '51'),
87    'ent_registration_1': ('6220029828', '51'),
88    'ent_registration_2': ('6220029828', '51'),
89    'ent_text_book_0':    ('6220029828', '51'),
90    'ent_text_book_1':    ('6220029828', '51'),
91    'ent_text_book_2':    ('6220029828', '51'),
92    'gst_registration_1': ('1010893123', '117'),
93    'gst_registration_2': ('1010893123', '117'),
94    'gst_text_book_0':    ('1010893123', '117'),
95    'gst_text_book_1':    ('1010893123', '117'),
96    'gst_text_book_2':    ('1010893123', '117'),
97    'gst_text_book_3':    ('1010893123', '117'),
[17468]98
99    'postgrad': ('1010827641', '117'),
[17431]100    }
101
[17437]102FEE_NAMES = {
103    'edohis':     'Edo State Health Insurance Scheme',
104    'union':      'Student Union Dues',
[17515]105    'union_pt':   'Student Union Dues Part-Time',
[17437]106    'sport':      'Sport Development Fee',
[18196]107    'access':     'University Student Identity Card Levy',
[17437]108    'notebook':   'Branded Notebook',
[17490]109    'accredit':   'Accreditation Fee',
[17437]110    'library':    'Library Development Fee',
111    'tuition':    'Tuition',
112    'acceptance': 'Acceptance Fee',
113    'matricgown': 'Matriculation Gown Fee',
[17439]114    'lapel':      'File/Lapel Fee',
[17495]115    'lmsplus':    'LMS Plus Fee',
[17437]116    'nuga':       'NUGA Fee',
117    }
118
[17431]119
[17447]120SCHOOLFEES = dict()
[17444]121
[17447]122for year in SFEECHANGES:
123    schoolfees_path = os.path.join(
124        os.path.dirname(__file__), '../students/schoolfees_%s.csv' %year)
125    reader = csv.DictReader(open(schoolfees_path, 'rb'))
126    SCHOOLFEES[year] = {item['code']:item for item in reader}
[17445]127
[17431]128acceptancefees_path = os.path.join(
129    os.path.dirname(__file__), '../students/acceptancefees.csv')
130reader = csv.DictReader(open(acceptancefees_path, 'rb'))
131ACCEPTANCEFEES = {item['code']:item for item in reader}
132
133class CustomInterswitchPageApplicant(InterswitchPageApplicant):
134    """ View which sends a POST request to the Interswitch
135    CollegePAY payment gateway.
136
137    So far only PT application has been configured.
138    """
139    grok.context(ICustomApplicantOnlinePayment)
140    action = POST_ACTION
141    site_name = SITE_NAME
142    currency = CURRENCY
143    provider_bank_id = PROVIDER_BANK_ID
144    provider_acct = PROVIDER_ACCT
145    pay_item_id = '101'
[17433]146    product_id = PRODUCT_ID
[17431]147
148    def update(self):
149        if not module_activated(
150            self.context.__parent__.__parent__.year, self.context):
151            self.flash(_('Forbidden'), type='danger')
152            self.redirect(self.url(self.context, '@@index'))
153            return
154        error = self.init_update()
155        if error:
156            self.flash(error, type='danger')
157            self.redirect(self.url(self.context, '@@index'))
158            return
159        # Already now it becomes an Interswitch payment. We set the net amount
160        # and add the gateway amount.
161        if not self.context.r_company:
162            self.context.net_amt = self.context.amount_auth
163            self.context.amount_auth += GATEWAY_AMT
164            self.context.gateway_amt = GATEWAY_AMT
165            self.context.r_company = u'interswitch'
166        xmldict = {}
[17477]167        provider_amt = 2000.0
[17719]168        xmldict['institution_acct'] = '2043582644'
169        xmldict['institution_bank_id'] = '8'
170        if self.applicant.__parent__.code in ('ver2019', 'send2019', 'res2024'):
171            provider_amt = 3000.0
172            xmldict['institution_acct'] = '2043583005'
173            xmldict['institution_bank_id'] = '8'
[17477]174        elif self.applicant.__parent__.code.startswith('cert'):
175            provider_amt = 3000.0
176        elif self.applicant.__parent__.code.startswith('trans'):
177            provider_amt = 3000.0
[17468]178        if self.applicant.applicant_id.startswith('dsh'):
[17781]179            xmldict['institution_acct'] = '2043582644'
[17779]180            xmldict['institution_bank_id'] = '8'
[17657]181        elif self.applicant.applicant_id.startswith('ijmbe'):
[17901]182            xmldict['institution_acct'] = '2043582644'
[17873]183            xmldict['institution_bank_id'] = '8'
[17657]184        elif 'alumni' in self.application_url():
185            xmldict['institution_acct'] = '2043583005'
[17431]186        xmldict['detail_ref'] = self.context.p_id
187        xmldict['provider_amt'] = 100 * provider_amt
188        xmldict['provider_acct'] = PROVIDER_ACCT
189        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
[17490]190        if 'alumni' in self.application_url():
191            xmldict['provider_acct'] = '0427773399'
192            xmldict['provider_bank_id'] = '10'
[17431]193        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
194        xmldict['institution_item_name'] = self.context.category
195        xmldict['institution_name'] = INSTITUTION_NAME
196        xmldict['institution_amt'] = 100 * self.context.net_amt
197        if not self.context.provider_amt:
198            self.context.provider_amt = provider_amt
199            self.context.amount_auth += provider_amt
[17469]200        if provider_amt:
201            xmltext = """<payment_item_detail>
[17431]202<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
203<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" />
204<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" />
205</item_details>
206</payment_item_detail>""" % xmldict
[17469]207        else:
208            xmltext = """<payment_item_detail>
209<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
210<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" />
211</item_details>
212</payment_item_detail>""" % xmldict
[17485]213
214        # Overwrite above configuration
215        if self.applicant.__parent__.code in ('cert1', 'cert2', 'cert6', 'cert9'):
216            xmldict['institution_amt'] = 100 * self.context.net_amt - 100000
217            xmltext = """<payment_item_detail>
218<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
219<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" />
220<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" />
221<item_detail item_id="3" item_name="Ambrose Alli Foundation" item_amt="100000" bank_id="117" acct_num="1015567975" />
222</item_details>
223</payment_item_detail>""" % xmldict
224
[18172]225        # Overwrite above configuration
226        if self.applicant.__parent__.code.startswith('pg'):
227            xmldict['institution_amt'] = 100 * self.context.net_amt - 200000
228            xmldict['institution_acct'] = '2043582644'
229            xmldict['institution_bank_id'] = '8'
230            xmltext = """<payment_item_detail>
231<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
232<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" />
233<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" />
234<item_detail item_id="3" item_name="AAU Postgraduate School" item_amt="200000" bank_id="117" acct_num="1014270207" />
235</item_details>
236</payment_item_detail>""" % xmldict
237
[17431]238        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
239        xmlitems = ''
240        xmldoc = minidom.parseString(xmltext)
241        itemlist = xmldoc.getElementsByTagName('item_detail')
242        for s in itemlist:
[17442]243            xmlitems += "%s (%s %s, %s (%s)),  " % (
[17431]244                s.attributes['item_name'].value,
[17442]245                u'\u20a6',
[17431]246                int(s.attributes['item_amt'].value)/100,
247                s.attributes['acct_num'].value,
248                s.attributes['bank_id'].value,
249                )
250        self.context.p_split_data = xmlitems
251        self.amount_auth = int(100 * self.context.amount_auth)
252        hashargs = (
253            self.context.p_id +
254            PRODUCT_ID +
255            self.pay_item_id +
256            str(int(self.amount_auth)) +
257            self.site_redirect_url +
258            MAC)
259        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
260        return
261
262class CustomInterswitchPageStudent(InterswitchPageStudent):
263    """ View which sends a POST request to the Interswitch
264    CollegePAY payment gateway.
265    """
266    grok.context(ICustomStudentOnlinePayment)
267    action = POST_ACTION
268    site_name = SITE_NAME
269    currency = CURRENCY
270    pay_item_id = '101'
[17433]271    product_id = PRODUCT_ID
[17431]272
273    def update(self):
274        if not module_activated(
275            self.context.student.current_session, self.context):
276            self.flash(_('Forbidden'), type='danger')
277            self.redirect(self.url(self.context, '@@index'))
278            return
279        error = self.init_update()
280        if error:
281            self.flash(error, type='danger')
282            self.redirect(self.url(self.context, '@@index'))
283            return
[17434]284        student = self.student
[17431]285        category = self.context.p_category
[17434]286        # To guarantee that cleared students pay both acceptance fee
287        # and school fees, the page can only be accessed
288        # for school fee payments if acceptance/clearance fee has
289        # been successfully queried/paid beforehand. This
290        # requirement applies to students in state 'cleared' and
291        # entry_session greater than 2012 only.
292        if self.context.p_category.startswith('schoolfee') and \
293            student.state == CLEARED and \
294            student.entry_session > 2012:
295            acceptance_fee_paid = False
296            for ticket in student['payments'].values():
297                if ticket.p_state == 'paid' and \
298                    ticket.p_category.startswith('clearance'):
299                    acceptance_fee_paid = True
300                    break
301            if not acceptance_fee_paid:
302                self.flash(
303                    _('Please pay acceptance fee first.'), type="danger")
304                self.redirect(self.url(self.context, '@@index'))
305                return
[17431]306        # Already now it becomes an Interswitch payment. We set the net amount
307        # and add the gateway amount.
308        if not self.context.r_company:
309            self.context.net_amt = self.context.amount_auth
310            self.context.amount_auth += GATEWAY_AMT
311            self.context.gateway_amt = GATEWAY_AMT
312            self.context.r_company = u'interswitch'
313        xmldict = self.xmldict
314        # Provider data
315        xmldict['detail_ref'] = self.context.p_id
316        xmldict['provider_acct'] = PROVIDER_ACCT
317        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
318        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
319        # Institution data
320        xmldict['institution_acct'] = '00000000'
321        xmldict['institution_bank_id'] = '00'
322        provider_amt = 0.0
323        if category.startswith('clearance'):
324            provider_amt = 1500.0
325        elif category.startswith('hostel_maintenance'):
326            provider_amt = 1000.0
327        elif category in ('schoolfee', 'schoolfee_1', 'schoolfee_incl'):
328            provider_amt = 2500.0
329        xmldict['provider_amt'] = 100 * provider_amt
330        xmldict['institution_item_name'] = self.context.category
331        xmldict['institution_name'] = INSTITUTION_NAME
332        xmldict['institution_amt'] = 100 * self.context.net_amt
333        if not self.context.provider_amt:
334            self.context.provider_amt = provider_amt
335            self.context.amount_auth += provider_amt
336        xmltext = ''
337
338        # School fee
339        if category.startswith('schoolfee'):
340            # collect additional fees
341            if self.context.p_category in ('schoolfee_1', 'schoolfee_incl'):
342                xmltext = """<payment_item_detail>
343<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">""" % xmldict
344                item_id = 1
[17446]345
346                if student.entry_session < 2013:
[17447]347                    sorted_items = SCHOOLFEES[12][student.certcode].items()
[17446]348                elif student.entry_session < 2014:
[17447]349                    sorted_items = SCHOOLFEES[13][student.certcode].items()
[17455]350                elif student.entry_session < 2015:
[17447]351                    sorted_items = SCHOOLFEES[14][student.certcode].items()
[17446]352                elif student.entry_session < 2020:
[17455]353                    sorted_items = SCHOOLFEES[15][student.certcode].items()
[17445]354                elif student.entry_session < 2021:
[17447]355                    sorted_items = SCHOOLFEES[20][student.certcode].items()
[17445]356                elif student.entry_session < 2022:
[17447]357                    sorted_items = SCHOOLFEES[21][student.certcode].items()
[17580]358                elif student.entry_session < 2023:
359                    sorted_items = SCHOOLFEES[22][student.certcode].items()
[17948]360                elif student.entry_session < 2024:
361                    sorted_items = SCHOOLFEES[23][student.certcode].items()
[18138]362                elif student.entry_session < 2025:
363                    sorted_items = SCHOOLFEES[24][student.certcode].items()
[17444]364                else:
[18138]365                    sorted_items = SCHOOLFEES[25][student.certcode].items()
[17529]366                # Move tuition. We expect that tuition is the fourth element
[17523]367                sorted_items.insert(0, sorted_items.pop(3))
[17439]368                for item in sorted_items:
[17431]369                    try:
[18196]370                        if  item[1].startswith('100_'):
371                            if student.state == CLEARED:
372                                # first year payment only
373                                item_amt = int(item[1].split('_')[1])
374                            else:
[18200]375                                continue
[17494]376                        else:
[17529]377                            item_amt = int(item[1])
[17431]378                        if self.context.p_category == 'schoolfee_1' and item[0] == 'tuition':
379                            item_amt /= 2
[17529]380                        # Add non-indigenous fee and session specific penalty fees
381                        try:
382                            academic_session = grok.getSite()['configuration'][str(self.context.p_session)]
383                        except KeyError:
384                            self.flash(
385                                _('Session configuration object is missing.'), type="danger")
386                            self.redirect(self.url(self.context, '@@index'))
387                            return
388                        if student.is_postgrad and item[0] == 'tuition':
389                            item_amt += academic_session.penalty_pg
390                            if student.lga and not student.lga.startswith('edo') \
391                                and student.entry_session < 2022:
392                                item_amt += 20000.0
[17948]393                        elif item[0] == 'tuition':
[17529]394                            item_amt += academic_session.penalty_ug
395                        item_amt *= 100
[17431]396                        acct_num = ''
397                        bank_id = ''
398                        item_name = ''
399                        # Find appropriate bank
[17694]400                        bank = None
[17431]401                        try:
402                            bank = BANK_ACCOUNTS[item[0]]
403                        except: # transfer to faculty account
[17516]404                            if student.is_postgrad:
405                                bank = BANK_ACCOUNTS['postgrad']
[17518]406                            elif student.current_mode in (
[17702]407                                'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh', 'dp_ft'):
[17523]408                                bank = BANK_ACCOUNTS['parttime']
[17516]409                            elif student.faccode in ('FAG', 'FAT', 'FBM', 'FMLS', 'fac1'):
[17431]410                                bank = BANK_ACCOUNTS['fac1']
411                            elif student.faccode in ('FCS', 'FED', 'FES', 'FET'):
412                                bank = BANK_ACCOUNTS['fac2']
413                            elif student.faccode in ('FLS', 'FLW', 'FMS', 'FPS', 'FSS'):
414                                bank = BANK_ACCOUNTS['fac3']
[17582]415                            elif student.faccode in ('FP',):
416                                bank = BANK_ACCOUNTS['ijmb']
[17694]417                        if not bank:
418                            self.flash(
[17695]419                                'Bank account not set (%s).' % item[0], type="danger")
[17694]420                            self.redirect(self.url(self.context, '@@index'))
421                            return
[17431]422                        acct_num = bank[0]
423                        bank_id = bank[1]
[17437]424                        item_name = FEE_NAMES[item[0]]
[17431]425                        xmltext += """
426<item_detail item_id="%s" item_name="%s" item_amt="%d" bank_id="%s" acct_num="%s" />""" % (item_id, item_name, item_amt, bank_id, acct_num)
427                        item_id += 1
428                    except:
429                        pass
430                xmldict['item_id'] = item_id
431                xmltext += """
432<item_detail item_id="%(item_id)d" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
433</item_details>
434</payment_item_detail>""" % xmldict
435            # no additional charges, determine faculty bank only
436            else:
[17694]437                bank = None
[17468]438                if student.is_postgrad:
439                    bank = BANK_ACCOUNTS['postgrad']
[17643]440                elif student.current_mode in (
[17702]441                    'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh', 'dp_ft'):
[17643]442                    bank = BANK_ACCOUNTS['parttime']
[17468]443                elif student.faccode in ('FAG', 'FAT', 'FBM', 'FMLS', 'fac1'):
[17431]444                    bank = BANK_ACCOUNTS['fac1']
445                elif student.faccode in ('FCS', 'FED', 'FES', 'FET'):
446                    bank = BANK_ACCOUNTS['fac2']
447                elif student.faccode in ('FLS', 'FLW', 'FMS', 'FPS', 'FSS'):
448                    bank = BANK_ACCOUNTS['fac3']
[17583]449                elif student.faccode in ('FP',):
450                    bank = BANK_ACCOUNTS['ijmb']
[17694]451                if not bank:
452                    self.flash('Bank account not set.', type="danger")
453                    self.redirect(self.url(self.context, '@@index'))
454                    return
[17431]455                xmldict['institution_acct'] = bank[0]
456                xmldict['institution_bank_id'] = bank[1]
457
458        # Clearance (acceptance) fee
459
[17456]460        elif category.startswith('clearance'):
[17431]461            # collect additional fees
462            if self.context.p_category == 'clearance_incl':
463                xmltext = """<payment_item_detail>
464<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">""" % xmldict
465                item_id = 1
466                for item in ACCEPTANCEFEES[student.certcode].items():
467                    try:
468                        item_amt = 100 * int(item[1])
469                        bank = BANK_ACCOUNTS[item[0]]
470                        acct_num = bank[0]
471                        bank_id = bank[1]
[17437]472                        item_name = FEE_NAMES[item[0]]
[17431]473                        xmltext += """
474<item_detail item_id="%s" item_name="%s" item_amt="%d" bank_id="%s" acct_num="%s" />""" % (item_id, item_name, item_amt, bank_id, acct_num)
475                        item_id += 1
476                    except:
477                        pass
478                xmldict['item_id'] = item_id
479                xmltext += """
480<item_detail item_id="%(item_id)d" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
481</item_details>
482</payment_item_detail>""" % xmldict
483            # no additional charges, determine faculty bank only
484            else:
[17468]485                if student.is_postgrad:
486                    bank = BANK_ACCOUNTS['postgrad']
487                else:
488                    bank = BANK_ACCOUNTS['acceptance']
[17431]489                xmldict['institution_acct'] = bank[0]
490                xmldict['institution_bank_id'] = bank[1]
491
[17491]492        # Hostel Maintenance
493
494        elif category == 'hostel_maintenance':
495            xmldict['institution_amt'] = 100 * self.context.net_amt - 1000000
496            bank = BANK_ACCOUNTS[category]
497            xmldict['institution_acct'] = bank[0]
498            xmldict['institution_bank_id'] = bank[1]
499            xmltext = """<payment_item_detail>
500<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
501<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" />
502<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" />
503<item_detail item_id="3" item_name="Hostel Consumable Fee" item_amt="1000000" bank_id="123" acct_num="1012332141" />
504</item_details>
505</payment_item_detail>""" % xmldict
506
[17431]507        # Other fees
[17491]508
[17456]509        elif category in BANK_ACCOUNTS.keys():
510            bank = BANK_ACCOUNTS[category]
511            xmldict['institution_acct'] = bank[0]
512            xmldict['institution_bank_id'] = bank[1]
[17431]513
514        if not xmltext and provider_amt == 0:
515            xmltext = """<payment_item_detail>
516<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
517<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" />
518</item_details>
519</payment_item_detail>""" % xmldict
520        elif not xmltext:
521            xmltext = """<payment_item_detail>
522<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
523<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" />
524<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" />
525</item_details>
526</payment_item_detail>""" % xmldict
527        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
528        xmlitems = ''
529        xmldoc = minidom.parseString(xmltext)
530        itemlist = xmldoc.getElementsByTagName('item_detail')
531        for s in itemlist:
[17442]532            xmlitems += "%s (%s %s, %s (%s)),  " % (
[17431]533                s.attributes['item_name'].value,
534                u'\u20a6',
535                int(s.attributes['item_amt'].value)/100,
536                s.attributes['acct_num'].value,
537                s.attributes['bank_id'].value,
538                )
539        self.context.p_split_data = xmlitems
540        self.context.provider_amt = provider_amt
541        self.amount_auth = int(100 * self.context.amount_auth)
542        hashargs = (
543            self.context.p_id +
544            PRODUCT_ID +
545            self.pay_item_id +
546            str(int(self.amount_auth)) +
547            self.site_redirect_url +
548            MAC)
549        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
550        return
551
552
553class CustomInterswitchPaymentRequestWebservicePageApplicant(
554    InterswitchPaymentRequestWebservicePageApplicant):
555    """Request webservice view for the CollegePAY gateway
556    """
557    grok.context(ICustomApplicantOnlinePayment)
558    gateway_host = HOST
559    gateway_url = URL
560    https = HTTPS
[17480]561    mac = MAC
562    product_id = PRODUCT_ID
[17431]563
564class CustomInterswitchPaymentVerifyWebservicePageApplicant(
565    InterswitchPaymentVerifyWebservicePageApplicant):
566    """Payment verify view for the CollegePAY gateway
567    """
568    grok.context(ICustomApplicantOnlinePayment)
569    gateway_host = HOST
570    gateway_url = URL
571    https = HTTPS
572    mac = MAC
573    product_id = PRODUCT_ID
574
575class CustomInterswitchPaymentRequestWebservicePageStudent(
576    InterswitchPaymentRequestWebservicePageStudent):
577    """Request webservice view for the CollegePAY gateway
578    """
579    grok.context(ICustomStudentOnlinePayment)
580    gateway_host = HOST
581    gateway_url = URL
582    https = HTTPS
583    mac = MAC
584    product_id = PRODUCT_ID
585
586class CustomInterswitchPaymentVerifyWebservicePageStudent(
587    InterswitchPaymentVerifyWebservicePageStudent):
588    """Payment verify view for the CollegePAY gateway
589    """
590    grok.context(ICustomStudentOnlinePayment)
591    gateway_host = HOST
592    gateway_url = URL
593    https = HTTPS
594    mac = MAC
595    product_id = PRODUCT_ID
Note: See TracBrowser for help on using the repository browser.