1 | ## $Id: browser.py 15464 2019-06-19 09:55:22Z 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 zope.interface import Interface |
---|
22 | from zope.component import queryAdapter |
---|
23 | from waeup.kofa.interfaces import CLEARED |
---|
24 | from kofacustom.nigeria.interswitch.browser import ( |
---|
25 | InterswitchPaymentRequestWebservicePageStudent, |
---|
26 | InterswitchPaymentRequestWebservicePageApplicant, |
---|
27 | InterswitchPaymentVerifyWebservicePageApplicant, |
---|
28 | InterswitchPaymentVerifyWebservicePageStudent, |
---|
29 | InterswitchPageStudent, InterswitchPageApplicant, |
---|
30 | ) |
---|
31 | from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment |
---|
32 | from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
33 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
34 | |
---|
35 | PRODUCT_ID_PT = '5040' |
---|
36 | PRODUCT_ID_REGULAR = '5845' |
---|
37 | SITE_NAME = 'aaue.waeup.org' |
---|
38 | PROVIDER_ACCT = '1014261520' |
---|
39 | PROVIDER_BANK_ID = '117' |
---|
40 | PROVIDER_ITEM_NAME = 'WAeAC' |
---|
41 | INSTITUTION_NAME = 'AAU Ekpoma' |
---|
42 | CURRENCY = '566' |
---|
43 | GATEWAY_AMT = 250.0 |
---|
44 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' |
---|
45 | |
---|
46 | HOST = 'webpay.interswitchng.com' |
---|
47 | URL = '/paydirect/api/v1/gettransaction.json' |
---|
48 | HTTPS = True |
---|
49 | MAC_REGULAR = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023' |
---|
50 | MAC_PT = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3' |
---|
51 | |
---|
52 | httplib.HTTPSConnection.debuglevel = 0 |
---|
53 | |
---|
54 | |
---|
55 | def gateway_net_amt(fee): |
---|
56 | if fee > GATEWAY_AMT: |
---|
57 | return fee - GATEWAY_AMT |
---|
58 | return 0.0 |
---|
59 | |
---|
60 | def contr_agreement_applicant(applicant): |
---|
61 | if applicant.__parent__ in ( |
---|
62 | 'fp', |
---|
63 | 'ptee', |
---|
64 | 'dsh', |
---|
65 | 'bridge', |
---|
66 | 'ijmbe', |
---|
67 | ): |
---|
68 | return 'first' |
---|
69 | return 'second' |
---|
70 | |
---|
71 | def contr_agreement_student(student): |
---|
72 | if student.current_mode in ( |
---|
73 | 'found', |
---|
74 | 'bridge', |
---|
75 | 'ug_dsh', |
---|
76 | 'de_dsh', |
---|
77 | 'ug_pt', |
---|
78 | 'de_pt', |
---|
79 | 'dp_pt', |
---|
80 | 'ijmbe', |
---|
81 | ): |
---|
82 | return 'first' |
---|
83 | return 'second' |
---|
84 | |
---|
85 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
86 | """ View which sends a POST request to the Interswitch |
---|
87 | CollegePAY payment gateway. |
---|
88 | |
---|
89 | So far only PT application has been configured. |
---|
90 | """ |
---|
91 | grok.context(ICustomApplicantOnlinePayment) |
---|
92 | action = POST_ACTION |
---|
93 | site_name = SITE_NAME |
---|
94 | currency = CURRENCY |
---|
95 | provider_bank_id = PROVIDER_BANK_ID |
---|
96 | provider_acct = PROVIDER_ACCT |
---|
97 | institution_acct = '1010835352' |
---|
98 | institution_bank_id = '117' |
---|
99 | |
---|
100 | def update(self): |
---|
101 | |
---|
102 | error = self.init_update() |
---|
103 | if error: |
---|
104 | self.flash(error, type='danger') |
---|
105 | self.redirect(self.url(self.context, '@@index')) |
---|
106 | return |
---|
107 | provider_amt = 2000.0 |
---|
108 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
109 | self.product_id = PRODUCT_ID_PT |
---|
110 | self.pay_item_id = '101' |
---|
111 | self.mac = MAC_PT |
---|
112 | else: |
---|
113 | self.product_id = PRODUCT_ID_REGULAR |
---|
114 | self.pay_item_id = '109' |
---|
115 | self.mac = MAC_REGULAR |
---|
116 | if self.applicant.__parent__.prefix in ('utme', 'ude'): |
---|
117 | provider_amt = 1000.0 |
---|
118 | if self.applicant.__parent__.prefix in ('trans', 'cert'): |
---|
119 | self.provider_bank_id = '10' |
---|
120 | self.provider_acct = '0427773399' |
---|
121 | elif self.applicant.applicant_id.startswith('bridge',): # easier to test |
---|
122 | self.institution_acct = '1014847058' |
---|
123 | self.institution_bank_id = '7' |
---|
124 | |
---|
125 | xmldict = {} |
---|
126 | xmldict['detail_ref'] = self.context.p_id |
---|
127 | xmldict['provider_amt'] = 100 * provider_amt |
---|
128 | xmldict['provider_acct'] = self.provider_acct |
---|
129 | xmldict['provider_bank_id'] = self.provider_bank_id |
---|
130 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
131 | xmldict['institution_acct'] = self.institution_acct |
---|
132 | xmldict['institution_bank_id'] = self.institution_bank_id |
---|
133 | xmldict['institution_item_name'] = self.category |
---|
134 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
135 | xmldict['institution_amt'] = 100 * ( |
---|
136 | self.context.amount_auth - provider_amt - GATEWAY_AMT) |
---|
137 | xmltext = """<payment_item_detail> |
---|
138 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
139 | <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" /> |
---|
140 | <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" /> |
---|
141 | </item_details> |
---|
142 | </payment_item_detail>""" % xmldict |
---|
143 | |
---|
144 | if self.applicant.applicant_id.startswith('pg'): |
---|
145 | handbook_amount = 2000.0 |
---|
146 | xmldict['handbook_amount'] = 100 * handbook_amount |
---|
147 | xmldict['institution_amt'] = 100 * ( |
---|
148 | self.context.amount_auth - provider_amt - handbook_amount -GATEWAY_AMT) |
---|
149 | xmltext = """<payment_item_detail> |
---|
150 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
151 | <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" /> |
---|
152 | <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" /> |
---|
153 | <item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1010827641" /> |
---|
154 | </item_details> |
---|
155 | </payment_item_detail>""" % xmldict |
---|
156 | |
---|
157 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
158 | self.context.provider_amt = provider_amt |
---|
159 | self.context.gateway_amt = GATEWAY_AMT |
---|
160 | |
---|
161 | hashargs = ( |
---|
162 | self.context.p_id + |
---|
163 | self.product_id + |
---|
164 | self.pay_item_id + |
---|
165 | str(int(self.amount_auth)) + |
---|
166 | self.site_redirect_url + |
---|
167 | self.mac) |
---|
168 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
169 | |
---|
170 | return |
---|
171 | |
---|
172 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
173 | """ View which sends a POST request to the Interswitch |
---|
174 | CollegePAY payment gateway. |
---|
175 | """ |
---|
176 | grok.context(ICustomStudentOnlinePayment) |
---|
177 | action = POST_ACTION |
---|
178 | site_name = SITE_NAME |
---|
179 | currency = CURRENCY |
---|
180 | pay_item_id = '000' |
---|
181 | |
---|
182 | def update(self): |
---|
183 | error = self.init_update() |
---|
184 | |
---|
185 | if error: |
---|
186 | self.flash(error, type='danger') |
---|
187 | self.redirect(self.url(self.context, '@@index')) |
---|
188 | return |
---|
189 | |
---|
190 | student = self.student |
---|
191 | p_session = self.context.p_session |
---|
192 | try: |
---|
193 | academic_session = grok.getSite()['configuration'][str(p_session)] |
---|
194 | except KeyError: |
---|
195 | self.flash(_(u'Session configuration object is not available.'), |
---|
196 | type='danger') |
---|
197 | self.redirect(self.url(self.context, '@@index')) |
---|
198 | return |
---|
199 | if contr_agreement_student(student) == 'first': |
---|
200 | self.product_id = PRODUCT_ID_PT |
---|
201 | self.mac = MAC_PT |
---|
202 | else: |
---|
203 | self.product_id = PRODUCT_ID_REGULAR |
---|
204 | self.mac = MAC_REGULAR |
---|
205 | |
---|
206 | # To guarantee that cleared students pay both acceptance fee |
---|
207 | # and school fees, the page can only be accessed |
---|
208 | # for school fee payments if acceptance/clearance fee has |
---|
209 | # been successfully queried/paid beforehand. This |
---|
210 | # requirement applies to students in state 'cleared' and |
---|
211 | # entry_session greater than 2012 only. |
---|
212 | if self.context.p_category.startswith('schoolfee') and \ |
---|
213 | student.state == CLEARED and \ |
---|
214 | student.entry_session > 2012: |
---|
215 | acceptance_fee_paid = False |
---|
216 | for ticket in student['payments'].values(): |
---|
217 | if ticket.p_state == 'paid' and \ |
---|
218 | ticket.p_category.startswith('clearance'): |
---|
219 | acceptance_fee_paid = True |
---|
220 | break |
---|
221 | if not acceptance_fee_paid: |
---|
222 | self.flash( |
---|
223 | _('Please pay acceptance fee first.'), type="danger") |
---|
224 | self.redirect(self.url(self.context, '@@index')) |
---|
225 | return |
---|
226 | |
---|
227 | xmldict = self.xmldict |
---|
228 | xmltext = "" |
---|
229 | xmldict['institution_acct'] = '1010827641' |
---|
230 | xmldict['institution_bank_id'] = '117' |
---|
231 | xmldict['detail_ref'] = self.context.p_id |
---|
232 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
233 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
234 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
235 | xmldict['institution_item_name'] = self.category |
---|
236 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
237 | provider_amt = 0.0 |
---|
238 | |
---|
239 | # Schoolfee |
---|
240 | if self.context.p_category.startswith('schoolfee'): |
---|
241 | if contr_agreement_student(student) == 'first': |
---|
242 | # First agreement |
---|
243 | provider_amt = 1900.0 |
---|
244 | joint_venture_amt = 0.0 |
---|
245 | aaue_share_amt = 0.0 |
---|
246 | student_union_due_amt = gateway_net_amt( |
---|
247 | academic_session.union_fee) |
---|
248 | student_welfare_assurance_amt = gateway_net_amt( |
---|
249 | academic_session.welfare_fee) |
---|
250 | sports_amt = gateway_net_amt( |
---|
251 | academic_session.sports_fee) |
---|
252 | library_amt = gateway_net_amt( |
---|
253 | academic_session.library_fee) |
---|
254 | library_amt_pg = gateway_net_amt( |
---|
255 | academic_session.library_fee_pg) |
---|
256 | xmldict['student_union_bank_id'] = '31' |
---|
257 | xmldict['student_union_acct'] = '0051005007' |
---|
258 | xmldict['aaue_share_bank_id'] = '117' |
---|
259 | xmldict['aaue_share_acct'] = '1010827641' |
---|
260 | xmldict['joint_venture_bank_id'] = '117' |
---|
261 | xmldict['joint_venture_acct'] = '1010827641' |
---|
262 | xmldict['institution_acct'] = '1014847058' |
---|
263 | xmldict['institution_bank_id'] = '7' |
---|
264 | if student.current_mode == 'found': |
---|
265 | self.pay_item_id = '103' |
---|
266 | else: |
---|
267 | self.pay_item_id = '105' |
---|
268 | else: |
---|
269 | # Second agreement |
---|
270 | provider_amt = 1500.0 |
---|
271 | joint_venture_amt = 1000.0 |
---|
272 | aaue_share_amt = 1500.0 |
---|
273 | student_union_due_amt = gateway_net_amt( |
---|
274 | academic_session.union_fee) |
---|
275 | student_welfare_assurance_amt = gateway_net_amt( |
---|
276 | academic_session.welfare_fee) |
---|
277 | sports_amt = gateway_net_amt( |
---|
278 | academic_session.sports_fee) |
---|
279 | library_amt = gateway_net_amt( |
---|
280 | academic_session.library_fee) |
---|
281 | library_amt_pg = gateway_net_amt( |
---|
282 | academic_session.library_fee_pg) |
---|
283 | xmldict['student_union_bank_id'] = '7' |
---|
284 | xmldict['student_union_acct'] = '1019763348' |
---|
285 | xmldict['aaue_share_bank_id'] = '117' |
---|
286 | xmldict['aaue_share_acct'] = '1010827641' |
---|
287 | xmldict['joint_venture_bank_id'] = '117' |
---|
288 | xmldict['joint_venture_acct'] = '1010827641' |
---|
289 | self.pay_item_id = '107' |
---|
290 | if student.is_postgrad: |
---|
291 | self.pay_item_id = '111' |
---|
292 | xmldict['institution_acct'] = '5210006575' |
---|
293 | xmldict['institution_bank_id'] = '51' |
---|
294 | if student.current_mode == 'ijmbe': |
---|
295 | self.pay_item_id = '119' |
---|
296 | xmldict['joint_venture_bank_id'] = '117' |
---|
297 | xmldict['joint_venture_acct'] = '1010827641' |
---|
298 | |
---|
299 | xmldict['provider_amt'] = 100 * provider_amt |
---|
300 | xmldict['joint_venture_amt'] = 100 * joint_venture_amt |
---|
301 | xmldict['aaue_share_amt'] = 100 * aaue_share_amt |
---|
302 | if self.context.p_item == 'Balance': |
---|
303 | xmldict['institution_amt'] = 100 * ( |
---|
304 | gateway_net_amt(self.context.amount_auth)) |
---|
305 | elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \ |
---|
306 | and student.current_mode != 'ijmbe': |
---|
307 | # Schoolfee including additional fees |
---|
308 | xmldict['student_union_due_amt'] = 100 * student_union_due_amt |
---|
309 | xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt |
---|
310 | |
---|
311 | if student.entry_session == 2018 and student.is_fresh: |
---|
312 | xmldict['sports_amt'] = 100 * sports_amt |
---|
313 | if student.is_postgrad: |
---|
314 | xmldict['library_amt'] = 100 * library_amt_pg |
---|
315 | else: |
---|
316 | xmldict['library_amt'] = 100 * library_amt |
---|
317 | xmldict['institution_amt'] = 100 * ( |
---|
318 | gateway_net_amt(self.context.amount_auth) |
---|
319 | - provider_amt |
---|
320 | - joint_venture_amt |
---|
321 | - aaue_share_amt |
---|
322 | - student_union_due_amt |
---|
323 | - student_welfare_assurance_amt |
---|
324 | - sports_amt |
---|
325 | - library_amt) |
---|
326 | xmltext = """<payment_item_detail> |
---|
327 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
328 | <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" /> |
---|
329 | <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" /> |
---|
330 | <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" /> |
---|
331 | <item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
332 | <item_detail item_id="5" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
333 | <item_detail item_id="6" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />""" % xmldict |
---|
334 | if contr_agreement_student(student) == 'second': |
---|
335 | xmltext += """" |
---|
336 | <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" /> |
---|
337 | <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" /> |
---|
338 | </item_details> |
---|
339 | </payment_item_detail>""" % xmldict |
---|
340 | else: |
---|
341 | xmltext += """" |
---|
342 | </item_details> |
---|
343 | </payment_item_detail>""" |
---|
344 | else: |
---|
345 | xmldict['institution_amt'] = 100 * ( |
---|
346 | gateway_net_amt(self.context.amount_auth) |
---|
347 | - provider_amt |
---|
348 | - joint_venture_amt |
---|
349 | - aaue_share_amt |
---|
350 | - student_union_due_amt |
---|
351 | - student_welfare_assurance_amt) |
---|
352 | xmltext = """<payment_item_detail> |
---|
353 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
354 | <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" /> |
---|
355 | <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" /> |
---|
356 | <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" /> |
---|
357 | <item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />""" % xmldict |
---|
358 | if contr_agreement_student(student) == 'second': |
---|
359 | xmltext += """" |
---|
360 | <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" /> |
---|
361 | <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" /> |
---|
362 | </item_details> |
---|
363 | </payment_item_detail>""" % xmldict |
---|
364 | else: |
---|
365 | xmltext += """" |
---|
366 | </item_details> |
---|
367 | </payment_item_detail>""" |
---|
368 | elif contr_agreement_student(student) == 'second': |
---|
369 | # Schoolfee without Student Union Fee ands Student Welfare Assurance |
---|
370 | xmldict['institution_amt'] = 100 * ( |
---|
371 | gateway_net_amt(self.context.amount_auth) |
---|
372 | - provider_amt |
---|
373 | - joint_venture_amt |
---|
374 | - aaue_share_amt) |
---|
375 | xmltext = """<payment_item_detail> |
---|
376 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
377 | <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" /> |
---|
378 | <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" /> |
---|
379 | <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" /> |
---|
380 | <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" /> |
---|
381 | </item_details> |
---|
382 | </payment_item_detail>""" % xmldict |
---|
383 | else: |
---|
384 | xmldict['institution_amt'] = 100 * ( |
---|
385 | gateway_net_amt(self.context.amount_auth) |
---|
386 | - provider_amt) |
---|
387 | xmltext = """<payment_item_detail> |
---|
388 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
389 | <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" /> |
---|
390 | <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" /> |
---|
391 | </item_details> |
---|
392 | </payment_item_detail>""" % xmldict |
---|
393 | |
---|
394 | |
---|
395 | # Clearance |
---|
396 | elif self.context.p_category.startswith('clearance'): |
---|
397 | provider_amt = 1500.0 |
---|
398 | xmldict['provider_amt'] = 100 * provider_amt |
---|
399 | if contr_agreement_student(student) == 'first': |
---|
400 | # First agreement |
---|
401 | if student.current_mode == 'found': |
---|
402 | self.pay_item_id = '102' |
---|
403 | else: |
---|
404 | self.pay_item_id = '104' |
---|
405 | provider_amt = 0.0 |
---|
406 | xmldict['institution_acct'] = '1014847058' |
---|
407 | xmldict['institution_bank_id'] = '7' |
---|
408 | else: |
---|
409 | # Second agreement |
---|
410 | self.pay_item_id = '102' |
---|
411 | if student.is_postgrad: |
---|
412 | self.pay_item_id = '110' |
---|
413 | xmldict['institution_acct'] = '5210006575' |
---|
414 | xmldict['institution_bank_id'] = '51' |
---|
415 | if student.current_mode == 'ijmbe': |
---|
416 | self.pay_item_id = '120' |
---|
417 | |
---|
418 | if self.context.p_category.endswith('_incl'): |
---|
419 | # Clearance including additional fees |
---|
420 | gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee) |
---|
421 | aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee) |
---|
422 | xmldict['gown_fee_amt'] = 100 * gown_fee_amt |
---|
423 | xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt |
---|
424 | xmldict['institution_amt'] = 100 * ( |
---|
425 | gateway_net_amt(self.context.amount_auth) |
---|
426 | - gown_fee_amt |
---|
427 | - aaue_lf_fee_amt |
---|
428 | - provider_amt) |
---|
429 | xmltext = """<payment_item_detail> |
---|
430 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
431 | <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" /> |
---|
432 | <item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" /> |
---|
433 | <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 |
---|
434 | if contr_agreement_student(student) == 'second': |
---|
435 | xmltext += """" |
---|
436 | <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" /> |
---|
437 | </item_details> |
---|
438 | </payment_item_detail>""" % xmldict |
---|
439 | else: |
---|
440 | xmltext += """" |
---|
441 | </item_details> |
---|
442 | </payment_item_detail>""" |
---|
443 | |
---|
444 | elif student.current_mode == 'bridge': |
---|
445 | # Clearance without any surcharge |
---|
446 | xmldict['institution_amt'] = 100 * gateway_net_amt( |
---|
447 | self.context.amount_auth) |
---|
448 | xmltext = """<payment_item_detail> |
---|
449 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
450 | <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" /> |
---|
451 | </item_details> |
---|
452 | </payment_item_detail>""" % xmldict |
---|
453 | |
---|
454 | else: |
---|
455 | # Clearance without additional fees |
---|
456 | xmldict['institution_amt'] = 100 * ( |
---|
457 | gateway_net_amt(self.context.amount_auth) |
---|
458 | - provider_amt) |
---|
459 | xmltext = """<payment_item_detail> |
---|
460 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
461 | <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 |
---|
462 | if contr_agreement_student(student) == 'second': |
---|
463 | xmltext += """" |
---|
464 | <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" /> |
---|
465 | </item_details> |
---|
466 | </payment_item_detail>""" % xmldict |
---|
467 | else: |
---|
468 | xmltext += """" |
---|
469 | </item_details> |
---|
470 | </payment_item_detail>""" |
---|
471 | |
---|
472 | # Union Dues |
---|
473 | elif self.context.p_category == 'union': |
---|
474 | self.pay_item_id = '103' |
---|
475 | xmldict['institution_amt'] = 100 * ( |
---|
476 | gateway_net_amt(self.context.amount_auth)) |
---|
477 | if contr_agreement_student(student) == 'first': |
---|
478 | # First agreement |
---|
479 | xmldict['institution_acct'] = '0051005007' |
---|
480 | xmldict['institution_bank_id'] = '31' |
---|
481 | else: |
---|
482 | # Second agreement |
---|
483 | xmldict['institution_bank_id'] = '7' |
---|
484 | xmldict['institution_acct'] = '1019763348' |
---|
485 | |
---|
486 | # Lapel/File |
---|
487 | elif self.context.p_category == 'lapel': |
---|
488 | self.pay_item_id = '104' |
---|
489 | xmldict['institution_amt'] = 100 * ( |
---|
490 | gateway_net_amt(self.context.amount_auth)) |
---|
491 | |
---|
492 | # Welfare Assurance |
---|
493 | elif self.context.p_category == 'welfare': |
---|
494 | self.pay_item_id = '105' |
---|
495 | xmldict['institution_acct'] = '1006407792' |
---|
496 | xmldict['institution_bank_id'] = '123' |
---|
497 | xmldict['institution_amt'] = 100 * ( |
---|
498 | gateway_net_amt(self.context.amount_auth)) |
---|
499 | |
---|
500 | # ID Card |
---|
501 | elif self.context.p_category == 'id_card': |
---|
502 | self.pay_item_id = '000' |
---|
503 | xmldict['institution_amt'] = 100 * ( |
---|
504 | gateway_net_amt(self.context.amount_auth)) |
---|
505 | |
---|
506 | # Matric Gown |
---|
507 | elif self.context.p_category == 'matric_gown': |
---|
508 | self.pay_item_id = '106' |
---|
509 | xmldict['institution_amt'] = 100 * ( |
---|
510 | gateway_net_amt(self.context.amount_auth)) |
---|
511 | |
---|
512 | # Concessional |
---|
513 | elif self.context.p_category == 'concessional': |
---|
514 | self.pay_item_id = '107' |
---|
515 | xmldict['institution_amt'] = 100 * ( |
---|
516 | gateway_net_amt(self.context.amount_auth)) |
---|
517 | |
---|
518 | # Hostel Maintenance |
---|
519 | elif self.context.p_category == 'hostel_maintenance': |
---|
520 | provider_amt = 500.0 |
---|
521 | self.pay_item_id = '109' |
---|
522 | xmldict['provider_amt'] = 100 * provider_amt |
---|
523 | xmldict['institution_amt'] = 100 * ( |
---|
524 | gateway_net_amt(self.context.amount_auth) - provider_amt) |
---|
525 | xmltext = """<payment_item_detail> |
---|
526 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
527 | <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" /> |
---|
528 | <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" /> |
---|
529 | </item_details> |
---|
530 | </payment_item_detail>""" % xmldict |
---|
531 | |
---|
532 | # GST Fees |
---|
533 | elif self.context.p_category.startswith('gst_'): |
---|
534 | if contr_agreement_student(student) == 'first': |
---|
535 | self.pay_item_id = '115' |
---|
536 | else: |
---|
537 | self.pay_item_id = '116' |
---|
538 | xmldict['institution_acct'] = '1010893123' |
---|
539 | xmldict['institution_bank_id'] = '117' |
---|
540 | xmldict['institution_amt'] = 100 * ( |
---|
541 | gateway_net_amt(self.context.amount_auth)) |
---|
542 | |
---|
543 | # ENT Fees |
---|
544 | elif self.context.p_category.startswith('ent_'): |
---|
545 | if contr_agreement_student(student) == 'first': |
---|
546 | self.pay_item_id = '114' |
---|
547 | else: |
---|
548 | self.pay_item_id = '118' |
---|
549 | xmldict['institution_acct'] = '6220029828' |
---|
550 | xmldict['institution_bank_id'] = '51' |
---|
551 | xmldict['institution_amt'] = 100 * ( |
---|
552 | gateway_net_amt(self.context.amount_auth)) |
---|
553 | |
---|
554 | # Faculty and Departmental Dues |
---|
555 | elif self.context.p_category == 'fac_dep': |
---|
556 | self.pay_item_id = '117' |
---|
557 | xmldict['institution_amt'] = 100 * ( |
---|
558 | gateway_net_amt(self.context.amount_auth)) |
---|
559 | |
---|
560 | # Restitution Fee |
---|
561 | elif self.context.p_category == 'restitution': |
---|
562 | self.pay_item_id = '117' |
---|
563 | xmldict['institution_amt'] = 100 * ( |
---|
564 | gateway_net_amt(self.context.amount_auth)) |
---|
565 | |
---|
566 | # Late Registration Fee |
---|
567 | elif self.context.p_category == 'late_registration': |
---|
568 | if contr_agreement_student(student) == 'first': |
---|
569 | self.pay_item_id = '113' |
---|
570 | else: |
---|
571 | self.pay_item_id = '123' |
---|
572 | xmldict['institution_amt'] = 100 * ( |
---|
573 | gateway_net_amt(self.context.amount_auth)) |
---|
574 | if student.is_postgrad: |
---|
575 | xmldict['institution_acct'] = '5210006575' |
---|
576 | xmldict['institution_bank_id'] = '51' |
---|
577 | if not xmltext: |
---|
578 | xmltext = """<payment_item_detail> |
---|
579 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
580 | <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" /> |
---|
581 | </item_details> |
---|
582 | </payment_item_detail>""" % xmldict |
---|
583 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
584 | self.context.provider_amt = provider_amt |
---|
585 | self.context.gateway_amt = self.amount_auth - gateway_net_amt( |
---|
586 | self.amount_auth) |
---|
587 | hashargs = ( |
---|
588 | self.context.p_id + |
---|
589 | self.product_id + |
---|
590 | self.pay_item_id + |
---|
591 | str(int(self.amount_auth)) + |
---|
592 | self.site_redirect_url + |
---|
593 | self.mac) |
---|
594 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
595 | return |
---|
596 | |
---|
597 | |
---|
598 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
599 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
600 | """Request webservice view for the CollegePAY gateway |
---|
601 | """ |
---|
602 | grok.context(ICustomApplicantOnlinePayment) |
---|
603 | gateway_host = HOST |
---|
604 | gateway_url = URL |
---|
605 | https = HTTPS |
---|
606 | |
---|
607 | @property |
---|
608 | def mac(self): |
---|
609 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
610 | return MAC_PT |
---|
611 | return MAC_REGULAR |
---|
612 | |
---|
613 | @property |
---|
614 | def product_id(self): |
---|
615 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
616 | return PRODUCT_ID_PT |
---|
617 | return PRODUCT_ID_REGULAR |
---|
618 | |
---|
619 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
620 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
621 | """Payment verify view for the CollegePAY gateway |
---|
622 | """ |
---|
623 | grok.context(ICustomApplicantOnlinePayment) |
---|
624 | gateway_host = HOST |
---|
625 | gateway_url = URL |
---|
626 | https = HTTPS |
---|
627 | |
---|
628 | @property |
---|
629 | def mac(self): |
---|
630 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
631 | return MAC_PT |
---|
632 | return MAC_REGULAR |
---|
633 | |
---|
634 | @property |
---|
635 | def product_id(self): |
---|
636 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
637 | return PRODUCT_ID_PT |
---|
638 | return PRODUCT_ID_REGULAR |
---|
639 | |
---|
640 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
641 | InterswitchPaymentRequestWebservicePageStudent): |
---|
642 | """Request webservice view for the CollegePAY gateway |
---|
643 | """ |
---|
644 | grok.context(ICustomStudentOnlinePayment) |
---|
645 | gateway_host = HOST |
---|
646 | gateway_url = URL |
---|
647 | https = HTTPS |
---|
648 | |
---|
649 | @property |
---|
650 | def mac(self): |
---|
651 | if contr_agreement_student(self.context.student) == 'first': |
---|
652 | return MAC_PT |
---|
653 | return MAC_REGULAR |
---|
654 | |
---|
655 | @property |
---|
656 | def product_id(self): |
---|
657 | if contr_agreement_student(self.context.student) == 'first': |
---|
658 | return PRODUCT_ID_PT |
---|
659 | return PRODUCT_ID_REGULAR |
---|
660 | |
---|
661 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
662 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
663 | """Payment verify view for the CollegePAY gateway |
---|
664 | """ |
---|
665 | grok.context(ICustomStudentOnlinePayment) |
---|
666 | gateway_host = HOST |
---|
667 | gateway_url = URL |
---|
668 | https = HTTPS |
---|
669 | |
---|
670 | @property |
---|
671 | def mac(self): |
---|
672 | if contr_agreement_student(self.context.student) == 'first': |
---|
673 | return MAC_PT |
---|
674 | return MAC_REGULAR |
---|
675 | |
---|
676 | @property |
---|
677 | def product_id(self): |
---|
678 | if contr_agreement_student(self.context.student) == 'first': |
---|
679 | return PRODUCT_ID_PT |
---|
680 | return PRODUCT_ID_REGULAR |
---|