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