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