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

Last change on this file since 17948 was 17948, checked in by Henrik Bettermann, 2 weeks ago

Fx splitting.

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