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 | item_amt = 100 * int(item[1]) |
---|
338 | if self.context.p_category == 'schoolfee_1' and item[0] == 'tuition': |
---|
339 | item_amt /= 2 |
---|
340 | acct_num = '' |
---|
341 | bank_id = '' |
---|
342 | item_name = '' |
---|
343 | # Find appropriate bank |
---|
344 | try: |
---|
345 | bank = BANK_ACCOUNTS[item[0]] |
---|
346 | except: # transfer to faculty account |
---|
347 | if student.faccode in ('FAG', 'FAT', 'FBM', 'FMLS', 'fac1'): |
---|
348 | bank = BANK_ACCOUNTS['fac1'] |
---|
349 | elif student.faccode in ('FCS', 'FED', 'FES', 'FET'): |
---|
350 | bank = BANK_ACCOUNTS['fac2'] |
---|
351 | elif student.faccode in ('FLS', 'FLW', 'FMS', 'FPS', 'FSS'): |
---|
352 | bank = BANK_ACCOUNTS['fac3'] |
---|
353 | acct_num = bank[0] |
---|
354 | bank_id = bank[1] |
---|
355 | item_name = FEE_NAMES[item[0]] |
---|
356 | xmltext += """ |
---|
357 | <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) |
---|
358 | item_id += 1 |
---|
359 | except: |
---|
360 | pass |
---|
361 | xmldict['item_id'] = item_id |
---|
362 | xmltext += """ |
---|
363 | <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" /> |
---|
364 | </item_details> |
---|
365 | </payment_item_detail>""" % xmldict |
---|
366 | # no additional charges, determine faculty bank only |
---|
367 | else: |
---|
368 | if student.is_postgrad: |
---|
369 | bank = BANK_ACCOUNTS['postgrad'] |
---|
370 | elif student.faccode in ('FAG', 'FAT', 'FBM', 'FMLS', 'fac1'): |
---|
371 | bank = BANK_ACCOUNTS['fac1'] |
---|
372 | elif student.faccode in ('FCS', 'FED', 'FES', 'FET'): |
---|
373 | bank = BANK_ACCOUNTS['fac2'] |
---|
374 | elif student.faccode in ('FLS', 'FLW', 'FMS', 'FPS', 'FSS'): |
---|
375 | bank = BANK_ACCOUNTS['fac3'] |
---|
376 | xmldict['institution_acct'] = bank[0] |
---|
377 | xmldict['institution_bank_id'] = bank[1] |
---|
378 | |
---|
379 | |
---|
380 | # Clearance (acceptance) fee |
---|
381 | |
---|
382 | elif category.startswith('clearance'): |
---|
383 | # collect additional fees |
---|
384 | if self.context.p_category == 'clearance_incl': |
---|
385 | xmltext = """<payment_item_detail> |
---|
386 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">""" % xmldict |
---|
387 | item_id = 1 |
---|
388 | for item in ACCEPTANCEFEES[student.certcode].items(): |
---|
389 | try: |
---|
390 | item_amt = 100 * int(item[1]) |
---|
391 | bank = BANK_ACCOUNTS[item[0]] |
---|
392 | acct_num = bank[0] |
---|
393 | bank_id = bank[1] |
---|
394 | item_name = FEE_NAMES[item[0]] |
---|
395 | xmltext += """ |
---|
396 | <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) |
---|
397 | item_id += 1 |
---|
398 | except: |
---|
399 | pass |
---|
400 | xmldict['item_id'] = item_id |
---|
401 | xmltext += """ |
---|
402 | <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" /> |
---|
403 | </item_details> |
---|
404 | </payment_item_detail>""" % xmldict |
---|
405 | # no additional charges, determine faculty bank only |
---|
406 | else: |
---|
407 | if student.is_postgrad: |
---|
408 | bank = BANK_ACCOUNTS['postgrad'] |
---|
409 | else: |
---|
410 | bank = BANK_ACCOUNTS['acceptance'] |
---|
411 | xmldict['institution_acct'] = bank[0] |
---|
412 | xmldict['institution_bank_id'] = bank[1] |
---|
413 | |
---|
414 | # Other fees |
---|
415 | elif category in BANK_ACCOUNTS.keys(): |
---|
416 | bank = BANK_ACCOUNTS[category] |
---|
417 | xmldict['institution_acct'] = bank[0] |
---|
418 | xmldict['institution_bank_id'] = bank[1] |
---|
419 | |
---|
420 | if not xmltext and provider_amt == 0: |
---|
421 | xmltext = """<payment_item_detail> |
---|
422 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
423 | <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" /> |
---|
424 | </item_details> |
---|
425 | </payment_item_detail>""" % xmldict |
---|
426 | elif not xmltext: |
---|
427 | xmltext = """<payment_item_detail> |
---|
428 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
429 | <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" /> |
---|
430 | <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" /> |
---|
431 | </item_details> |
---|
432 | </payment_item_detail>""" % xmldict |
---|
433 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
434 | xmlitems = '' |
---|
435 | xmldoc = minidom.parseString(xmltext) |
---|
436 | itemlist = xmldoc.getElementsByTagName('item_detail') |
---|
437 | for s in itemlist: |
---|
438 | xmlitems += "%s (%s %s, %s (%s)), " % ( |
---|
439 | s.attributes['item_name'].value, |
---|
440 | u'\u20a6', |
---|
441 | int(s.attributes['item_amt'].value)/100, |
---|
442 | s.attributes['acct_num'].value, |
---|
443 | s.attributes['bank_id'].value, |
---|
444 | ) |
---|
445 | self.context.p_split_data = xmlitems |
---|
446 | self.context.provider_amt = provider_amt |
---|
447 | self.amount_auth = int(100 * self.context.amount_auth) |
---|
448 | hashargs = ( |
---|
449 | self.context.p_id + |
---|
450 | PRODUCT_ID + |
---|
451 | self.pay_item_id + |
---|
452 | str(int(self.amount_auth)) + |
---|
453 | self.site_redirect_url + |
---|
454 | MAC) |
---|
455 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
456 | return |
---|
457 | |
---|
458 | |
---|
459 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
460 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
461 | """Request webservice view for the CollegePAY gateway |
---|
462 | """ |
---|
463 | grok.context(ICustomApplicantOnlinePayment) |
---|
464 | gateway_host = HOST |
---|
465 | gateway_url = URL |
---|
466 | https = HTTPS |
---|
467 | mac = MAC |
---|
468 | product_id = PRODUCT_ID |
---|
469 | |
---|
470 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
471 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
472 | """Payment verify view for the CollegePAY gateway |
---|
473 | """ |
---|
474 | grok.context(ICustomApplicantOnlinePayment) |
---|
475 | gateway_host = HOST |
---|
476 | gateway_url = URL |
---|
477 | https = HTTPS |
---|
478 | mac = MAC |
---|
479 | product_id = PRODUCT_ID |
---|
480 | |
---|
481 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
482 | InterswitchPaymentRequestWebservicePageStudent): |
---|
483 | """Request webservice view for the CollegePAY gateway |
---|
484 | """ |
---|
485 | grok.context(ICustomStudentOnlinePayment) |
---|
486 | gateway_host = HOST |
---|
487 | gateway_url = URL |
---|
488 | https = HTTPS |
---|
489 | mac = MAC |
---|
490 | product_id = PRODUCT_ID |
---|
491 | |
---|
492 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
493 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
494 | """Payment verify view for the CollegePAY gateway |
---|
495 | """ |
---|
496 | grok.context(ICustomStudentOnlinePayment) |
---|
497 | gateway_host = HOST |
---|
498 | gateway_url = URL |
---|
499 | https = HTTPS |
---|
500 | mac = MAC |
---|
501 | product_id = PRODUCT_ID |
---|