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