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