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