1 | ## $Id: browser.py 16661 2021-10-04 08:57:09Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann |
---|
4 | ## This program is free software; you can redistribute it and/or modify |
---|
5 | ## it under the terms of the GNU General Public License as published by |
---|
6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
7 | ## (at your option) any later version. |
---|
8 | ## |
---|
9 | ## This program is distributed in the hope that it will be useful, |
---|
10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | ## GNU General Public License for more details. |
---|
13 | ## |
---|
14 | ## You should have received a copy of the GNU General Public License |
---|
15 | ## along with this program; if not, write to the Free Software |
---|
16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | ## |
---|
18 | import httplib |
---|
19 | import hashlib |
---|
20 | import grok |
---|
21 | from xml.dom import minidom |
---|
22 | from zope.interface import Interface |
---|
23 | from zope.component import queryAdapter |
---|
24 | from waeup.kofa.interfaces import CLEARED |
---|
25 | from kofacustom.nigeria.interswitch.browser import ( |
---|
26 | InterswitchPaymentRequestWebservicePageStudent, |
---|
27 | InterswitchPaymentRequestWebservicePageApplicant, |
---|
28 | InterswitchPaymentVerifyWebservicePageApplicant, |
---|
29 | InterswitchPaymentVerifyWebservicePageStudent, |
---|
30 | InterswitchPageStudent, InterswitchPageApplicant, |
---|
31 | ) |
---|
32 | from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment |
---|
33 | from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
34 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
35 | |
---|
36 | PRODUCT_ID_PT = '5040' |
---|
37 | PRODUCT_ID_REGULAR = '5845' |
---|
38 | SITE_NAME = 'aaue.waeup.org' |
---|
39 | PROVIDER_ACCT = '5100189030' |
---|
40 | PROVIDER_BANK_ID = '307' |
---|
41 | PROVIDER_ITEM_NAME = 'WAeAC' |
---|
42 | INSTITUTION_NAME = 'AAU Ekpoma' |
---|
43 | CURRENCY = '566' |
---|
44 | GATEWAY_AMT = 200.0 |
---|
45 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' |
---|
46 | |
---|
47 | HOST = 'webpay.interswitchng.com' |
---|
48 | URL = '/paydirect/api/v1/gettransaction.json' |
---|
49 | HTTPS = True |
---|
50 | MAC_REGULAR = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023' |
---|
51 | MAC_PT = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3' |
---|
52 | |
---|
53 | httplib.HTTPSConnection.debuglevel = 0 |
---|
54 | |
---|
55 | |
---|
56 | def gateway_net_amt(fee): |
---|
57 | if fee > GATEWAY_AMT: |
---|
58 | return fee - GATEWAY_AMT |
---|
59 | return 0.0 |
---|
60 | |
---|
61 | def contr_agreement_applicant(applicant): |
---|
62 | if applicant.__parent__ in ( |
---|
63 | 'fp', |
---|
64 | 'ptee', |
---|
65 | 'dsh', |
---|
66 | 'bridge', |
---|
67 | 'ijmbe', |
---|
68 | ): |
---|
69 | return 'first' |
---|
70 | return 'second' |
---|
71 | |
---|
72 | def contr_agreement_student(student): |
---|
73 | if student.current_mode in ( |
---|
74 | 'found', |
---|
75 | 'bridge', |
---|
76 | 'ug_dsh', |
---|
77 | 'de_dsh', |
---|
78 | 'ug_pt', |
---|
79 | 'de_pt', |
---|
80 | 'dp_pt', |
---|
81 | 'ijmbe', |
---|
82 | ): |
---|
83 | return 'first' |
---|
84 | return 'second' |
---|
85 | |
---|
86 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
87 | """ View which sends a POST request to the Interswitch |
---|
88 | CollegePAY payment gateway. |
---|
89 | |
---|
90 | So far only PT application has been configured. |
---|
91 | """ |
---|
92 | grok.context(ICustomApplicantOnlinePayment) |
---|
93 | action = POST_ACTION |
---|
94 | site_name = SITE_NAME |
---|
95 | currency = CURRENCY |
---|
96 | provider_bank_id = PROVIDER_BANK_ID |
---|
97 | provider_acct = PROVIDER_ACCT |
---|
98 | institution_acct = '1010835352' |
---|
99 | institution_bank_id = '117' |
---|
100 | |
---|
101 | def update(self): |
---|
102 | |
---|
103 | error = self.init_update() |
---|
104 | if error: |
---|
105 | self.flash(error, type='danger') |
---|
106 | self.redirect(self.url(self.context, '@@index')) |
---|
107 | return |
---|
108 | self.context.r_company = u'interswitch' |
---|
109 | provider_amt = 2000.0 |
---|
110 | fedex_amt = 0.0 |
---|
111 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
112 | self.product_id = PRODUCT_ID_PT |
---|
113 | self.pay_item_id = '101' |
---|
114 | self.mac = MAC_PT |
---|
115 | else: |
---|
116 | self.product_id = PRODUCT_ID_REGULAR |
---|
117 | self.pay_item_id = '109' |
---|
118 | self.mac = MAC_REGULAR |
---|
119 | if self.applicant.__parent__.prefix in ('utme', 'ude'): |
---|
120 | provider_amt = 1000.0 |
---|
121 | elif self.applicant.__parent__.prefix in ('trans', 'cert'): |
---|
122 | self.institution_acct = '1010827641' |
---|
123 | self.institution_bank_id = '117' |
---|
124 | self.provider_bank_id = '10' |
---|
125 | self.provider_acct = '0427773399' |
---|
126 | if self.applicant.applicant_id[:5] in ('cert7', 'cert8'): |
---|
127 | provider_amt = 0.0 |
---|
128 | if self.applicant.applicant_id[:6] in ('trans5', 'trans6'): |
---|
129 | self.institution_acct = '5210006575' |
---|
130 | self.institution_bank_id = '51' |
---|
131 | #if self.applicant.applicant_id[:6] in ('trans1', 'trans6'): |
---|
132 | # fedex_amt = 10500.0 |
---|
133 | if self.context.p_category == 'app_balance': |
---|
134 | provider_amt = 0.0 |
---|
135 | elif self.applicant.applicant_id.startswith('bridge'): # easier to test |
---|
136 | self.institution_acct = '1014847058' |
---|
137 | self.institution_bank_id = '7' |
---|
138 | elif self.applicant.applicant_id.startswith('dsh'): # easier to test |
---|
139 | self.institution_acct = '1014847058' |
---|
140 | self.institution_bank_id = '7' |
---|
141 | elif self.applicant.__parent__.prefix in ('ver', 'send'): |
---|
142 | provider_amt = 0.0 |
---|
143 | elif self.applicant.__parent__.prefix == 'fedex': |
---|
144 | provider_amt = 0.0 |
---|
145 | self.institution_acct = '0001115694' |
---|
146 | self.institution_bank_id = '10' |
---|
147 | xmldict = {} |
---|
148 | xmldict['detail_ref'] = self.context.p_id |
---|
149 | xmldict['provider_amt'] = 100 * provider_amt |
---|
150 | xmldict['provider_acct'] = self.provider_acct |
---|
151 | xmldict['provider_bank_id'] = self.provider_bank_id |
---|
152 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
153 | xmldict['institution_acct'] = self.institution_acct |
---|
154 | xmldict['institution_bank_id'] = self.institution_bank_id |
---|
155 | xmldict['institution_item_name'] = self.category |
---|
156 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
157 | xmldict['fedex_amt'] = 100 * fedex_amt |
---|
158 | xmldict['institution_amt'] = 100 * ( |
---|
159 | self.context.amount_auth - provider_amt - fedex_amt - GATEWAY_AMT) |
---|
160 | |
---|
161 | xmltext = """<payment_item_detail> |
---|
162 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
163 | <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" /> |
---|
164 | <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" /> |
---|
165 | </item_details> |
---|
166 | </payment_item_detail>""" % xmldict |
---|
167 | |
---|
168 | if provider_amt == 0.0: |
---|
169 | xmltext = """<payment_item_detail> |
---|
170 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
171 | <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" /> |
---|
172 | </item_details> |
---|
173 | </payment_item_detail>""" % xmldict |
---|
174 | |
---|
175 | if fedex_amt: |
---|
176 | xmltext = """<payment_item_detail> |
---|
177 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
178 | <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" /> |
---|
179 | <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" /> |
---|
180 | <item_detail item_id="3" item_name="FedEx" item_amt="%(fedex_amt)d" bank_id="10" acct_num="0001115694" /> |
---|
181 | </item_details> |
---|
182 | </payment_item_detail>""" % xmldict |
---|
183 | |
---|
184 | if self.applicant.applicant_id.startswith('pg'): |
---|
185 | handbook_amount = 2000.0 |
---|
186 | xmldict['handbook_amount'] = 100 * handbook_amount |
---|
187 | xmldict['institution_amt'] = 100 * ( |
---|
188 | self.context.amount_auth - provider_amt - handbook_amount -GATEWAY_AMT) |
---|
189 | xmltext = """<payment_item_detail> |
---|
190 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
191 | <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" /> |
---|
192 | <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" /> |
---|
193 | <item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1010827641" /> |
---|
194 | </item_details> |
---|
195 | </payment_item_detail>""" % xmldict |
---|
196 | |
---|
197 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
198 | self.context.provider_amt = provider_amt |
---|
199 | self.context.gateway_amt = GATEWAY_AMT |
---|
200 | xmlitems = '' |
---|
201 | xmldoc = minidom.parseString(xmltext) |
---|
202 | itemlist = xmldoc.getElementsByTagName('item_detail') |
---|
203 | for s in itemlist: |
---|
204 | xmlitems += "%s: %s, N%s, %s (%s) " % ( |
---|
205 | s.attributes['item_id'].value, |
---|
206 | s.attributes['item_name'].value, |
---|
207 | int(s.attributes['item_amt'].value)/100, |
---|
208 | s.attributes['acct_num'].value, |
---|
209 | s.attributes['bank_id'].value, |
---|
210 | ) |
---|
211 | self.context.p_split_data = xmlitems |
---|
212 | self.amount_auth = int(100 * self.context.amount_auth) |
---|
213 | hashargs = ( |
---|
214 | self.context.p_id + |
---|
215 | self.product_id + |
---|
216 | self.pay_item_id + |
---|
217 | str(int(self.amount_auth)) + |
---|
218 | self.site_redirect_url + |
---|
219 | self.mac) |
---|
220 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
221 | |
---|
222 | return |
---|
223 | |
---|
224 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
225 | """ View which sends a POST request to the Interswitch |
---|
226 | CollegePAY payment gateway. |
---|
227 | """ |
---|
228 | grok.context(ICustomStudentOnlinePayment) |
---|
229 | action = POST_ACTION |
---|
230 | site_name = SITE_NAME |
---|
231 | currency = CURRENCY |
---|
232 | pay_item_id = '000' |
---|
233 | |
---|
234 | def update(self): |
---|
235 | error = self.init_update() |
---|
236 | if error: |
---|
237 | self.flash(error, type='danger') |
---|
238 | self.redirect(self.url(self.context, '@@index')) |
---|
239 | return |
---|
240 | self.context.r_company = u'interswitch' |
---|
241 | student = self.student |
---|
242 | p_session = self.context.p_session |
---|
243 | try: |
---|
244 | academic_session = grok.getSite()['configuration'][str(p_session)] |
---|
245 | except KeyError: |
---|
246 | self.flash(_(u'Session configuration object is not available.'), |
---|
247 | type='danger') |
---|
248 | self.redirect(self.url(self.context, '@@index')) |
---|
249 | return |
---|
250 | if contr_agreement_student(student) == 'first': |
---|
251 | self.product_id = PRODUCT_ID_PT |
---|
252 | self.mac = MAC_PT |
---|
253 | else: |
---|
254 | self.product_id = PRODUCT_ID_REGULAR |
---|
255 | self.mac = MAC_REGULAR |
---|
256 | |
---|
257 | # To guarantee that cleared students pay both acceptance fee |
---|
258 | # and school fees, the page can only be accessed |
---|
259 | # for school fee payments if acceptance/clearance fee has |
---|
260 | # been successfully queried/paid beforehand. This |
---|
261 | # requirement applies to students in state 'cleared' and |
---|
262 | # entry_session greater than 2012 only. |
---|
263 | if self.context.p_category.startswith('schoolfee') and \ |
---|
264 | student.state == CLEARED and \ |
---|
265 | student.entry_session > 2012: |
---|
266 | acceptance_fee_paid = False |
---|
267 | for ticket in student['payments'].values(): |
---|
268 | if ticket.p_state == 'paid' and \ |
---|
269 | ticket.p_category.startswith('clearance'): |
---|
270 | acceptance_fee_paid = True |
---|
271 | break |
---|
272 | if not acceptance_fee_paid: |
---|
273 | self.flash( |
---|
274 | _('Please pay acceptance fee first.'), type="danger") |
---|
275 | self.redirect(self.url(self.context, '@@index')) |
---|
276 | return |
---|
277 | |
---|
278 | xmldict = self.xmldict |
---|
279 | xmltext = "" |
---|
280 | xmldict['institution_acct'] = '1010827641' |
---|
281 | xmldict['institution_bank_id'] = '117' |
---|
282 | xmldict['detail_ref'] = self.context.p_id |
---|
283 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
284 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
285 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
286 | xmldict['institution_item_name'] = self.category |
---|
287 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
288 | provider_amt = 0.0 |
---|
289 | |
---|
290 | # Schoolfee |
---|
291 | if self.context.p_category.startswith('schoolfee'): |
---|
292 | if contr_agreement_student(student) == 'first': |
---|
293 | # First agreement |
---|
294 | provider_amt = 1900.0 |
---|
295 | joint_venture_amt = 0.0 |
---|
296 | aaue_share_amt = 0.0 |
---|
297 | student_union_due_amt = gateway_net_amt( |
---|
298 | academic_session.union_fee) |
---|
299 | student_welfare_assurance_amt = gateway_net_amt( |
---|
300 | academic_session.welfare_fee) |
---|
301 | sports_amt = gateway_net_amt( |
---|
302 | academic_session.sports_fee) |
---|
303 | library_amt = gateway_net_amt( |
---|
304 | academic_session.library_fee) |
---|
305 | library_amt_pg = gateway_net_amt( |
---|
306 | academic_session.library_pg_fee) |
---|
307 | xmldict['student_union_bank_id'] = '31' |
---|
308 | xmldict['student_union_acct'] = '0051005007' |
---|
309 | xmldict['aaue_share_bank_id'] = '117' |
---|
310 | xmldict['aaue_share_acct'] = '1010827641' |
---|
311 | xmldict['joint_venture_bank_id'] = '117' |
---|
312 | xmldict['joint_venture_acct'] = '1010827641' |
---|
313 | xmldict['institution_acct'] = '1014847058' |
---|
314 | xmldict['institution_bank_id'] = '7' |
---|
315 | if student.current_mode == 'found': |
---|
316 | self.pay_item_id = '103' |
---|
317 | else: |
---|
318 | self.pay_item_id = '105' |
---|
319 | else: |
---|
320 | # Second agreement |
---|
321 | joint_venture_amt = 1000.0 |
---|
322 | aaue_share_amt = 1500.0 |
---|
323 | provider_amt = 1500.0 |
---|
324 | student_union_due_amt = gateway_net_amt( |
---|
325 | academic_session.union_fee) |
---|
326 | student_welfare_assurance_amt = gateway_net_amt( |
---|
327 | academic_session.welfare_fee) |
---|
328 | sports_amt = gateway_net_amt( |
---|
329 | academic_session.sports_fee) |
---|
330 | library_amt = gateway_net_amt( |
---|
331 | academic_session.library_fee) |
---|
332 | library_amt_pg = gateway_net_amt( |
---|
333 | academic_session.library_pg_fee) |
---|
334 | xmldict['student_union_bank_id'] = '7' |
---|
335 | xmldict['student_union_acct'] = '1019763348' |
---|
336 | xmldict['aaue_share_bank_id'] = '117' |
---|
337 | xmldict['aaue_share_acct'] = '1010827641' |
---|
338 | xmldict['joint_venture_bank_id'] = '117' |
---|
339 | xmldict['joint_venture_acct'] = '1010827641' |
---|
340 | self.pay_item_id = '107' |
---|
341 | if student.is_postgrad: |
---|
342 | self.pay_item_id = '111' |
---|
343 | xmldict['institution_acct'] = '5210006575' |
---|
344 | xmldict['institution_bank_id'] = '51' |
---|
345 | if student.current_mode == 'ijmbe': |
---|
346 | self.pay_item_id = '119' |
---|
347 | xmldict['institution_bank_id'] = '123' |
---|
348 | xmldict['institution_acct'] = '1012278272' |
---|
349 | |
---|
350 | xmldict['provider_amt'] = 100 * provider_amt |
---|
351 | xmldict['joint_venture_amt'] = 100 * joint_venture_amt |
---|
352 | xmldict['aaue_share_amt'] = 100 * aaue_share_amt |
---|
353 | if self.context.p_item == 'Balance': |
---|
354 | xmldict['institution_amt'] = 100 * ( |
---|
355 | gateway_net_amt(self.context.amount_auth)) |
---|
356 | elif self.context.p_category == 'schoolfee_2': |
---|
357 | xmldict['institution_amt'] = 100 * gateway_net_amt( |
---|
358 | self.context.amount_auth) |
---|
359 | xmltext = """<payment_item_detail> |
---|
360 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
361 | <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" /> |
---|
362 | </item_details> |
---|
363 | </payment_item_detail>""" % xmldict |
---|
364 | elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \ |
---|
365 | and student.current_mode != 'ijmbe': |
---|
366 | # Schoolfee including additional fees |
---|
367 | xmldict['student_union_due_amt'] = 100 * student_union_due_amt |
---|
368 | xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt |
---|
369 | |
---|
370 | if student.entry_session >= 2018 and student.is_fresh: |
---|
371 | xmldict['sports_amt'] = 100 * sports_amt |
---|
372 | if student.is_postgrad: |
---|
373 | xmldict['library_amt'] = 100 * library_amt_pg |
---|
374 | else: |
---|
375 | xmldict['library_amt'] = 100 * library_amt |
---|
376 | xmldict['institution_amt'] = 100 * ( |
---|
377 | gateway_net_amt(self.context.amount_auth) |
---|
378 | - provider_amt |
---|
379 | - joint_venture_amt |
---|
380 | - aaue_share_amt |
---|
381 | - student_union_due_amt |
---|
382 | - student_welfare_assurance_amt |
---|
383 | - sports_amt |
---|
384 | - library_amt) |
---|
385 | xmltext = """<payment_item_detail> |
---|
386 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
387 | <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" /> |
---|
388 | <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" /> |
---|
389 | <item_detail item_id="3" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="%(student_union_bank_id)s" acct_num="%(student_union_acct)s" /> |
---|
390 | <item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
391 | <item_detail item_id="5" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
392 | <item_detail item_id="6" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />""" % xmldict |
---|
393 | if contr_agreement_student(student) == 'second': |
---|
394 | xmltext += """" |
---|
395 | <item_detail item_id="7" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" /> |
---|
396 | <item_detail item_id="8" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" /> |
---|
397 | </item_details> |
---|
398 | </payment_item_detail>""" % xmldict |
---|
399 | else: |
---|
400 | xmltext += """" |
---|
401 | </item_details> |
---|
402 | </payment_item_detail>""" |
---|
403 | else: |
---|
404 | xmldict['institution_amt'] = 100 * ( |
---|
405 | gateway_net_amt(self.context.amount_auth) |
---|
406 | - provider_amt |
---|
407 | - joint_venture_amt |
---|
408 | - aaue_share_amt |
---|
409 | - student_union_due_amt |
---|
410 | - student_welfare_assurance_amt) |
---|
411 | xmltext = """<payment_item_detail> |
---|
412 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
413 | <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" /> |
---|
414 | <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" /> |
---|
415 | <item_detail item_id="3" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="%(student_union_bank_id)s" acct_num="%(student_union_acct)s" /> |
---|
416 | <item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />""" % xmldict |
---|
417 | if contr_agreement_student(student) == 'second': |
---|
418 | xmltext += """" |
---|
419 | <item_detail item_id="5" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" /> |
---|
420 | <item_detail item_id="6" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" /> |
---|
421 | </item_details> |
---|
422 | </payment_item_detail>""" % xmldict |
---|
423 | else: |
---|
424 | xmltext += """" |
---|
425 | </item_details> |
---|
426 | </payment_item_detail>""" |
---|
427 | elif contr_agreement_student(student) == 'second': |
---|
428 | # Schoolfee without Student Union Fee ands Student Welfare Assurance |
---|
429 | xmldict['institution_amt'] = 100 * ( |
---|
430 | gateway_net_amt(self.context.amount_auth) |
---|
431 | - provider_amt |
---|
432 | - joint_venture_amt |
---|
433 | - aaue_share_amt) |
---|
434 | xmltext = """<payment_item_detail> |
---|
435 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
436 | <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" /> |
---|
437 | <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" /> |
---|
438 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" /> |
---|
439 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" /> |
---|
440 | </item_details> |
---|
441 | </payment_item_detail>""" % xmldict |
---|
442 | else: |
---|
443 | xmldict['institution_amt'] = 100 * ( |
---|
444 | gateway_net_amt(self.context.amount_auth) |
---|
445 | - provider_amt) |
---|
446 | xmltext = """<payment_item_detail> |
---|
447 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
448 | <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" /> |
---|
449 | <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" /> |
---|
450 | </item_details> |
---|
451 | </payment_item_detail>""" % xmldict |
---|
452 | |
---|
453 | |
---|
454 | # Clearance |
---|
455 | elif self.context.p_category.startswith('clearance'): |
---|
456 | xmldict['institution_acct'] = '1010835352' |
---|
457 | provider_amt = 0.0 |
---|
458 | if contr_agreement_student(student) == 'first': |
---|
459 | # First agreement |
---|
460 | if student.current_mode == 'found': |
---|
461 | self.pay_item_id = '102' |
---|
462 | else: |
---|
463 | self.pay_item_id = '104' |
---|
464 | xmldict['institution_acct'] = '1014847058' |
---|
465 | xmldict['institution_bank_id'] = '7' |
---|
466 | else: |
---|
467 | # Second agreement |
---|
468 | self.pay_item_id = '102' |
---|
469 | if student.is_postgrad: |
---|
470 | self.pay_item_id = '110' |
---|
471 | xmldict['institution_acct'] = '5210006575' |
---|
472 | xmldict['institution_bank_id'] = '51' |
---|
473 | if student.current_mode == 'ijmbe': |
---|
474 | self.pay_item_id = '120' |
---|
475 | xmldict['institution_bank_id'] = '123' |
---|
476 | xmldict['institution_acct'] = '1012278272' |
---|
477 | # ivama: Acceptance fee split is unique to "ug_ft" |
---|
478 | # The reason for split is perculiar to them only... |
---|
479 | # That amount was deducted from UTME application fee because |
---|
480 | # some regulatory body have pegged the application fee which |
---|
481 | # didn't affect another programmes. |
---|
482 | if student.current_mode == 'ug_ft': |
---|
483 | provider_amt = 1500.0 |
---|
484 | xmldict['provider_amt'] = 100 * provider_amt |
---|
485 | if self.context.p_category.endswith('_incl'): |
---|
486 | # Clearance including additional fees |
---|
487 | gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee) |
---|
488 | aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee) |
---|
489 | xmldict['gown_fee_amt'] = 100 * gown_fee_amt |
---|
490 | xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt |
---|
491 | xmldict['institution_amt'] = 100 * ( |
---|
492 | gateway_net_amt(self.context.amount_auth) |
---|
493 | - gown_fee_amt |
---|
494 | - aaue_lf_fee_amt |
---|
495 | - provider_amt) |
---|
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_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num=" 1010835352" /> |
---|
500 | <item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_lf_fee_amt)d" bank_id="117" acct_num=" 1010835352" />""" % xmldict |
---|
501 | if provider_amt: |
---|
502 | xmltext += """" |
---|
503 | <item_detail item_id="4" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
504 | </item_details> |
---|
505 | </payment_item_detail>""" % xmldict |
---|
506 | else: |
---|
507 | xmltext += """" |
---|
508 | </item_details> |
---|
509 | </payment_item_detail>""" |
---|
510 | |
---|
511 | elif student.current_mode == 'bridge': |
---|
512 | # Clearance without any surcharge |
---|
513 | xmldict['institution_amt'] = 100 * gateway_net_amt( |
---|
514 | self.context.amount_auth) |
---|
515 | xmltext = """<payment_item_detail> |
---|
516 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
517 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
518 | </item_details> |
---|
519 | </payment_item_detail>""" % xmldict |
---|
520 | |
---|
521 | else: |
---|
522 | # Clearance without additional fees |
---|
523 | xmldict['institution_amt'] = 100 * ( |
---|
524 | gateway_net_amt(self.context.amount_auth) |
---|
525 | - provider_amt) |
---|
526 | xmltext = """<payment_item_detail> |
---|
527 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
528 | <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" />""" % xmldict |
---|
529 | if provider_amt: |
---|
530 | xmltext += """" |
---|
531 | <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" /> |
---|
532 | </item_details> |
---|
533 | </payment_item_detail>""" % xmldict |
---|
534 | else: |
---|
535 | xmltext += """" |
---|
536 | </item_details> |
---|
537 | </payment_item_detail>""" |
---|
538 | |
---|
539 | # Union Dues |
---|
540 | elif self.context.p_category == 'union': |
---|
541 | self.pay_item_id = '103' |
---|
542 | xmldict['institution_amt'] = 100 * ( |
---|
543 | gateway_net_amt(self.context.amount_auth)) |
---|
544 | if contr_agreement_student(student) == 'first': |
---|
545 | # First agreement |
---|
546 | xmldict['institution_acct'] = '0051005007' |
---|
547 | xmldict['institution_bank_id'] = '31' |
---|
548 | else: |
---|
549 | # Second agreement |
---|
550 | xmldict['institution_bank_id'] = '7' |
---|
551 | xmldict['institution_acct'] = '1019763348' |
---|
552 | |
---|
553 | # Lapel/File |
---|
554 | elif self.context.p_category == 'lapel': |
---|
555 | self.pay_item_id = '104' |
---|
556 | xmldict['institution_amt'] = 100 * ( |
---|
557 | gateway_net_amt(self.context.amount_auth)) |
---|
558 | |
---|
559 | # Welfare Assurance |
---|
560 | elif self.context.p_category == 'welfare': |
---|
561 | self.pay_item_id = '105' |
---|
562 | xmldict['institution_acct'] = '1006407792' |
---|
563 | xmldict['institution_bank_id'] = '123' |
---|
564 | xmldict['institution_amt'] = 100 * ( |
---|
565 | gateway_net_amt(self.context.amount_auth)) |
---|
566 | |
---|
567 | # ID Card |
---|
568 | elif self.context.p_category == 'id_card': |
---|
569 | self.pay_item_id = '000' |
---|
570 | xmldict['institution_amt'] = 100 * ( |
---|
571 | gateway_net_amt(self.context.amount_auth)) |
---|
572 | |
---|
573 | # Matric Gown |
---|
574 | elif self.context.p_category == 'matric_gown': |
---|
575 | self.pay_item_id = '106' |
---|
576 | xmldict['institution_amt'] = 100 * ( |
---|
577 | gateway_net_amt(self.context.amount_auth)) |
---|
578 | |
---|
579 | # Concessional |
---|
580 | elif self.context.p_category == 'concessional': |
---|
581 | self.pay_item_id = '107' |
---|
582 | xmldict['institution_amt'] = 100 * ( |
---|
583 | gateway_net_amt(self.context.amount_auth)) |
---|
584 | |
---|
585 | # Hostel Maintenance |
---|
586 | elif self.context.p_category == 'hostel_maintenance': |
---|
587 | provider_amt = 500.0 |
---|
588 | self.pay_item_id = '109' |
---|
589 | xmldict['institution_acct'] = '1006406795' |
---|
590 | xmldict['institution_bank_id'] = '123' |
---|
591 | xmldict['provider_amt'] = 100 * provider_amt |
---|
592 | xmldict['institution_amt'] = 100 * ( |
---|
593 | gateway_net_amt(self.context.amount_auth) - provider_amt) |
---|
594 | xmltext = """<payment_item_detail> |
---|
595 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
596 | <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" /> |
---|
597 | <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" /> |
---|
598 | </item_details> |
---|
599 | </payment_item_detail>""" % xmldict |
---|
600 | |
---|
601 | # GST Fees |
---|
602 | elif self.context.p_category.startswith('gst_'): |
---|
603 | if contr_agreement_student(student) == 'first': |
---|
604 | self.pay_item_id = '115' |
---|
605 | else: |
---|
606 | self.pay_item_id = '116' |
---|
607 | xmldict['institution_acct'] = '1010893123' |
---|
608 | xmldict['institution_bank_id'] = '117' |
---|
609 | xmldict['institution_amt'] = 100 * ( |
---|
610 | gateway_net_amt(self.context.amount_auth)) |
---|
611 | |
---|
612 | # ENT Fees |
---|
613 | elif self.context.p_category.startswith('ent_'): |
---|
614 | if contr_agreement_student(student) == 'first': |
---|
615 | self.pay_item_id = '114' |
---|
616 | else: |
---|
617 | self.pay_item_id = '118' |
---|
618 | xmldict['institution_acct'] = '6220029828' |
---|
619 | xmldict['institution_bank_id'] = '51' |
---|
620 | xmldict['institution_amt'] = 100 * ( |
---|
621 | gateway_net_amt(self.context.amount_auth)) |
---|
622 | |
---|
623 | # Faculty and Departmental Dues |
---|
624 | elif self.context.p_category == 'fac_dep': |
---|
625 | xmldict['institution_acct'] = '1016425386' |
---|
626 | xmldict['institution_bank_id'] = '117' |
---|
627 | self.pay_item_id = '117' |
---|
628 | xmldict['institution_amt'] = 100 * ( |
---|
629 | gateway_net_amt(self.context.amount_auth)) |
---|
630 | |
---|
631 | # Restitution Fee |
---|
632 | elif self.context.p_category == 'restitution': |
---|
633 | self.pay_item_id = '117' |
---|
634 | xmldict['institution_amt'] = 100 * ( |
---|
635 | gateway_net_amt(self.context.amount_auth)) |
---|
636 | |
---|
637 | # Faculty Laboratory Due |
---|
638 | elif self.context.p_category in ('lab_1', 'lab_2'): |
---|
639 | xmldict['institution_acct'] = '1016425386' |
---|
640 | xmldict['institution_bank_id'] = '117' |
---|
641 | self.pay_item_id = '117' |
---|
642 | xmldict['institution_amt'] = 100 * ( |
---|
643 | gateway_net_amt(self.context.amount_auth)) |
---|
644 | |
---|
645 | # Sports Fee |
---|
646 | #elif self.context.p_category == 'sports': |
---|
647 | # self.pay_item_id = '105' |
---|
648 | # xmldict['institution_amt'] = 100 * ( |
---|
649 | # gateway_net_amt(self.context.amount_auth)) |
---|
650 | |
---|
651 | # Library Fee |
---|
652 | #elif self.context.p_category == 'library': |
---|
653 | # self.pay_item_id = '105' |
---|
654 | # xmldict['institution_amt'] = 100 * ( |
---|
655 | # gateway_net_amt(self.context.amount_auth)) |
---|
656 | |
---|
657 | # Library PG Fee |
---|
658 | #elif self.context.p_category == 'library_pg': |
---|
659 | # self.pay_item_id = '105' |
---|
660 | # xmldict['institution_amt'] = 100 * ( |
---|
661 | # gateway_net_amt(self.context.amount_auth)) |
---|
662 | |
---|
663 | # Sports & Library Fee temporarily in 2020 |
---|
664 | elif self.context.p_category == 'sports_library': |
---|
665 | self.pay_item_id = '105' |
---|
666 | xmldict['sports_amt'] = 100 * 3000.0 |
---|
667 | xmldict['library_amt'] = 100 * 1000.0 |
---|
668 | xmltext = """<payment_item_detail> |
---|
669 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
670 | <item_detail item_id="1" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
671 | <item_detail item_id="2" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" /> |
---|
672 | </item_details> |
---|
673 | </payment_item_detail>""" % xmldict |
---|
674 | |
---|
675 | # Late Registration Fee |
---|
676 | elif self.context.p_category == 'late_registration': |
---|
677 | if contr_agreement_student(student) == 'first': |
---|
678 | self.pay_item_id = '113' |
---|
679 | else: |
---|
680 | self.pay_item_id = '123' |
---|
681 | xmldict['institution_amt'] = 100 * ( |
---|
682 | gateway_net_amt(self.context.amount_auth)) |
---|
683 | if student.is_postgrad: |
---|
684 | xmldict['institution_acct'] = '5210006575' |
---|
685 | xmldict['institution_bank_id'] = '51' |
---|
686 | if not xmltext: |
---|
687 | xmltext = """<payment_item_detail> |
---|
688 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
689 | <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" /> |
---|
690 | </item_details> |
---|
691 | </payment_item_detail>""" % xmldict |
---|
692 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
693 | self.context.provider_amt = provider_amt |
---|
694 | self.context.gateway_amt = self.context.amount_auth - gateway_net_amt( |
---|
695 | self.context.amount_auth) |
---|
696 | xmlitems = '' |
---|
697 | xmldoc = minidom.parseString(xmltext) |
---|
698 | itemlist = xmldoc.getElementsByTagName('item_detail') |
---|
699 | for s in itemlist: |
---|
700 | xmlitems += "%s: %s, N%s, %s (%s) " % ( |
---|
701 | s.attributes['item_id'].value, |
---|
702 | s.attributes['item_name'].value, |
---|
703 | int(s.attributes['item_amt'].value)/100, |
---|
704 | s.attributes['acct_num'].value, |
---|
705 | s.attributes['bank_id'].value, |
---|
706 | ) |
---|
707 | self.context.p_split_data = xmlitems |
---|
708 | self.amount_auth = int(100 * self.context.amount_auth) |
---|
709 | hashargs = ( |
---|
710 | self.context.p_id + |
---|
711 | self.product_id + |
---|
712 | self.pay_item_id + |
---|
713 | str(int(self.amount_auth)) + |
---|
714 | self.site_redirect_url + |
---|
715 | self.mac) |
---|
716 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
717 | return |
---|
718 | |
---|
719 | |
---|
720 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
721 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
722 | """Request webservice view for the CollegePAY gateway |
---|
723 | """ |
---|
724 | grok.context(ICustomApplicantOnlinePayment) |
---|
725 | gateway_host = HOST |
---|
726 | gateway_url = URL |
---|
727 | https = HTTPS |
---|
728 | |
---|
729 | @property |
---|
730 | def mac(self): |
---|
731 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
732 | return MAC_PT |
---|
733 | return MAC_REGULAR |
---|
734 | |
---|
735 | @property |
---|
736 | def product_id(self): |
---|
737 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
738 | return PRODUCT_ID_PT |
---|
739 | return PRODUCT_ID_REGULAR |
---|
740 | |
---|
741 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
742 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
743 | """Payment verify view for the CollegePAY gateway |
---|
744 | """ |
---|
745 | grok.context(ICustomApplicantOnlinePayment) |
---|
746 | gateway_host = HOST |
---|
747 | gateway_url = URL |
---|
748 | https = HTTPS |
---|
749 | |
---|
750 | @property |
---|
751 | def mac(self): |
---|
752 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
753 | return MAC_PT |
---|
754 | return MAC_REGULAR |
---|
755 | |
---|
756 | @property |
---|
757 | def product_id(self): |
---|
758 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
759 | return PRODUCT_ID_PT |
---|
760 | return PRODUCT_ID_REGULAR |
---|
761 | |
---|
762 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
763 | InterswitchPaymentRequestWebservicePageStudent): |
---|
764 | """Request webservice view for the CollegePAY gateway |
---|
765 | """ |
---|
766 | grok.context(ICustomStudentOnlinePayment) |
---|
767 | gateway_host = HOST |
---|
768 | gateway_url = URL |
---|
769 | https = HTTPS |
---|
770 | |
---|
771 | @property |
---|
772 | def mac(self): |
---|
773 | if contr_agreement_student(self.context.student) == 'first': |
---|
774 | return MAC_PT |
---|
775 | return MAC_REGULAR |
---|
776 | |
---|
777 | @property |
---|
778 | def product_id(self): |
---|
779 | if contr_agreement_student(self.context.student) == 'first': |
---|
780 | return PRODUCT_ID_PT |
---|
781 | return PRODUCT_ID_REGULAR |
---|
782 | |
---|
783 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
784 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
785 | """Payment verify view for the CollegePAY gateway |
---|
786 | """ |
---|
787 | grok.context(ICustomStudentOnlinePayment) |
---|
788 | gateway_host = HOST |
---|
789 | gateway_url = URL |
---|
790 | https = HTTPS |
---|
791 | |
---|
792 | @property |
---|
793 | def mac(self): |
---|
794 | if contr_agreement_student(self.context.student) == 'first': |
---|
795 | return MAC_PT |
---|
796 | return MAC_REGULAR |
---|
797 | |
---|
798 | @property |
---|
799 | def product_id(self): |
---|
800 | if contr_agreement_student(self.context.student) == 'first': |
---|
801 | return PRODUCT_ID_PT |
---|
802 | return PRODUCT_ID_REGULAR |
---|