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