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