1 | ## $Id: browser.py 15084 2018-07-11 04:18:55Z 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 | |
---|
81 | def update(self): |
---|
82 | |
---|
83 | error = self.init_update() |
---|
84 | if error: |
---|
85 | self.flash(error, type='danger') |
---|
86 | self.redirect(self.url(self.context, '@@index')) |
---|
87 | return |
---|
88 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
89 | self.product_id = PRODUCT_ID_PT |
---|
90 | self.pay_item_id = '101' |
---|
91 | self.mac = MAC_PT |
---|
92 | provider_amt = 4000.0 |
---|
93 | else: |
---|
94 | self.product_id = PRODUCT_ID_REGULAR |
---|
95 | self.pay_item_id = '109' |
---|
96 | self.mac = MAC_REGULAR |
---|
97 | provider_amt = 1000.0 |
---|
98 | xmldict = {} |
---|
99 | xmldict['institution_acct'] = '1010835352' |
---|
100 | xmldict['institution_bank_id'] = '117' |
---|
101 | xmldict['detail_ref'] = self.context.p_id |
---|
102 | xmldict['provider_amt'] = 100 * provider_amt |
---|
103 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
104 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
105 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
106 | xmldict['institution_item_name'] = self.category |
---|
107 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
108 | |
---|
109 | if self.applicant.applicant_id.startswith('pg'): |
---|
110 | handbook_amount = 2000.0 |
---|
111 | xmldict['handbook_amount'] = 100 * handbook_amount |
---|
112 | xmldict['institution_amt'] = 100 * ( |
---|
113 | self.context.amount_auth - provider_amt - handbook_amount -GATEWAY_AMT) |
---|
114 | xmltext = """<payment_item_detail> |
---|
115 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
116 | <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" /> |
---|
117 | <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" /> |
---|
118 | <item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1010827641" /> |
---|
119 | </item_details> |
---|
120 | </payment_item_detail>""" % xmldict |
---|
121 | |
---|
122 | elif self.applicant.applicant_id.startswith('utme'): |
---|
123 | xmldict['provider_amt'] = 100 * provider_amt |
---|
124 | xmldict['institution_amt'] = 100 * ( |
---|
125 | self.context.amount_auth - provider_amt - GATEWAY_AMT) |
---|
126 | xmltext = """<payment_item_detail> |
---|
127 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
128 | <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" /> |
---|
129 | <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" /> |
---|
130 | </item_details> |
---|
131 | </payment_item_detail>""" % xmldict |
---|
132 | |
---|
133 | else: |
---|
134 | xmldict['institution_amt'] = 100 * ( |
---|
135 | self.context.amount_auth - provider_amt - GATEWAY_AMT) |
---|
136 | xmltext = """<payment_item_detail> |
---|
137 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
138 | <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" /> |
---|
139 | <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" /> |
---|
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 | xmldict['student_union_bank_id'] = '31' |
---|
237 | xmldict['student_union_acct'] = '0051005007' |
---|
238 | xmldict['aaue_share_bank_id'] = '117' |
---|
239 | xmldict['aaue_share_acct'] = '1010827641' |
---|
240 | xmldict['joint_venture_bank_id'] = '117' |
---|
241 | xmldict['joint_venture_acct'] = '1010827641' |
---|
242 | if student.current_mode == 'found': |
---|
243 | self.pay_item_id = '103' |
---|
244 | else: |
---|
245 | self.pay_item_id = '105' |
---|
246 | else: |
---|
247 | # Second agreement |
---|
248 | provider_amt = 1500.0 |
---|
249 | joint_venture_amt = 1000.0 |
---|
250 | aaue_share_amt = 1500.0 |
---|
251 | student_union_due_amt = gateway_net_amt( |
---|
252 | academic_session.union_fee) |
---|
253 | student_welfare_assurance_amt = gateway_net_amt( |
---|
254 | academic_session.welfare_fee) |
---|
255 | xmldict['student_union_bank_id'] = '7' |
---|
256 | xmldict['student_union_acct'] = '1019763348' |
---|
257 | xmldict['aaue_share_bank_id'] = '117' |
---|
258 | xmldict['aaue_share_acct'] = '1010827641' |
---|
259 | xmldict['joint_venture_bank_id'] = '117' |
---|
260 | xmldict['joint_venture_acct'] = '1010827641' |
---|
261 | self.pay_item_id = '107' |
---|
262 | if student.is_postgrad: |
---|
263 | self.pay_item_id = '111' |
---|
264 | if student.current_mode == 'ijmbe': |
---|
265 | self.pay_item_id = '119' |
---|
266 | xmldict['joint_venture_bank_id'] = '117' |
---|
267 | xmldict['joint_venture_acct'] = '1010827641' |
---|
268 | |
---|
269 | xmldict['provider_amt'] = 100 * provider_amt |
---|
270 | xmldict['joint_venture_amt'] = 100 * joint_venture_amt |
---|
271 | xmldict['aaue_share_amt'] = 100 * aaue_share_amt |
---|
272 | if self.context.p_item == 'Balance': |
---|
273 | xmldict['institution_amt'] = 100 * ( |
---|
274 | gateway_net_amt(self.context.amount_auth)) |
---|
275 | elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \ |
---|
276 | and student.current_mode != 'ijmbe': |
---|
277 | # Schoolfee including additional fees |
---|
278 | xmldict['student_union_due_amt'] = 100 * student_union_due_amt |
---|
279 | xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt |
---|
280 | xmldict['institution_amt'] = 100 * ( |
---|
281 | gateway_net_amt(self.context.amount_auth) |
---|
282 | - provider_amt |
---|
283 | - joint_venture_amt |
---|
284 | - aaue_share_amt |
---|
285 | - student_union_due_amt |
---|
286 | - student_welfare_assurance_amt) |
---|
287 | xmltext = """<payment_item_detail> |
---|
288 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
289 | <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" /> |
---|
290 | <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" /> |
---|
291 | <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" /> |
---|
292 | <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" /> |
---|
293 | <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" /> |
---|
294 | <item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
295 | </item_details> |
---|
296 | </payment_item_detail>""" % xmldict |
---|
297 | else: |
---|
298 | # Schoolfee without additional fees |
---|
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 | xmltext = """<payment_item_detail> |
---|
305 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
306 | <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" /> |
---|
307 | <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" /> |
---|
308 | <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" /> |
---|
309 | <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" /> |
---|
310 | </item_details> |
---|
311 | </payment_item_detail>""" % xmldict |
---|
312 | |
---|
313 | |
---|
314 | # Clearance |
---|
315 | elif self.context.p_category.startswith('clearance'): |
---|
316 | if contr_agreement_student(student) == 'first': |
---|
317 | # First agreement |
---|
318 | if student.current_mode == 'found': |
---|
319 | self.pay_item_id = '102' |
---|
320 | else: |
---|
321 | self.pay_item_id = '104' |
---|
322 | else: |
---|
323 | # Second agreement |
---|
324 | self.pay_item_id = '102' |
---|
325 | if student.is_postgrad: |
---|
326 | self.pay_item_id = '110' |
---|
327 | if student.current_mode == 'ijmbe': |
---|
328 | self.pay_item_id = '120' |
---|
329 | |
---|
330 | if self.context.p_category.endswith('_incl'): |
---|
331 | # Clearance including additional fees |
---|
332 | gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee) |
---|
333 | aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee) |
---|
334 | xmldict['gown_fee_amt'] = 100 * gown_fee_amt |
---|
335 | xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt |
---|
336 | xmldict['institution_amt'] = 100 * ( |
---|
337 | gateway_net_amt(self.context.amount_auth) |
---|
338 | - gown_fee_amt |
---|
339 | - aaue_lf_fee_amt) |
---|
340 | xmltext = """<payment_item_detail> |
---|
341 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
342 | <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" /> |
---|
343 | <item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" /> |
---|
344 | <item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_lf_fee_amt)d" bank_id="117" acct_num="1010827641" /> |
---|
345 | </item_details> |
---|
346 | </payment_item_detail>""" % xmldict |
---|
347 | |
---|
348 | else: |
---|
349 | # Clearance without additional fees |
---|
350 | xmldict['institution_amt'] = 100 * ( |
---|
351 | gateway_net_amt(self.context.amount_auth)) |
---|
352 | |
---|
353 | # Union Dues |
---|
354 | elif self.context.p_category == 'union': |
---|
355 | self.pay_item_id = '103' |
---|
356 | xmldict['institution_amt'] = 100 * ( |
---|
357 | gateway_net_amt(self.context.amount_auth)) |
---|
358 | if contr_agreement_student(student) == 'first': |
---|
359 | # First agreement |
---|
360 | xmldict['institution_acct'] = '0051005007' |
---|
361 | xmldict['institution_bank_id'] = '31' |
---|
362 | else: |
---|
363 | # Second agreement |
---|
364 | xmldict['institution_bank_id'] = '7' |
---|
365 | xmldict['institution_acct'] = '1019763348' |
---|
366 | |
---|
367 | # Lapel/File |
---|
368 | elif self.context.p_category == 'lapel': |
---|
369 | self.pay_item_id = '104' |
---|
370 | xmldict['institution_amt'] = 100 * ( |
---|
371 | gateway_net_amt(self.context.amount_auth)) |
---|
372 | |
---|
373 | # Welfare Assurance |
---|
374 | elif self.context.p_category == 'welfare': |
---|
375 | self.pay_item_id = '105' |
---|
376 | xmldict['institution_acct'] = '1006407792' |
---|
377 | xmldict['institution_bank_id'] = '123' |
---|
378 | xmldict['institution_amt'] = 100 * ( |
---|
379 | gateway_net_amt(self.context.amount_auth)) |
---|
380 | |
---|
381 | # ID Card |
---|
382 | elif self.context.p_category == 'id_card': |
---|
383 | self.pay_item_id = '000' |
---|
384 | xmldict['institution_amt'] = 100 * ( |
---|
385 | gateway_net_amt(self.context.amount_auth)) |
---|
386 | |
---|
387 | # Matric Gown |
---|
388 | elif self.context.p_category == 'matric_gown': |
---|
389 | self.pay_item_id = '106' |
---|
390 | xmldict['institution_amt'] = 100 * ( |
---|
391 | gateway_net_amt(self.context.amount_auth)) |
---|
392 | |
---|
393 | # Concessional |
---|
394 | elif self.context.p_category == 'concessional': |
---|
395 | self.pay_item_id = '107' |
---|
396 | xmldict['institution_amt'] = 100 * ( |
---|
397 | gateway_net_amt(self.context.amount_auth)) |
---|
398 | |
---|
399 | # Hostel Maintenance |
---|
400 | elif self.context.p_category == 'hostel_maintenance': |
---|
401 | provider_amt = 500.0 |
---|
402 | self.pay_item_id = '109' |
---|
403 | xmldict['provider_amt'] = 100 * provider_amt |
---|
404 | xmldict['institution_amt'] = 100 * ( |
---|
405 | gateway_net_amt(self.context.amount_auth) - provider_amt) |
---|
406 | xmltext = """<payment_item_detail> |
---|
407 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
408 | <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" /> |
---|
409 | <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" /> |
---|
410 | </item_details> |
---|
411 | </payment_item_detail>""" % xmldict |
---|
412 | |
---|
413 | # GST Fees |
---|
414 | elif self.context.p_category.startswith('gst_'): |
---|
415 | if contr_agreement_student(student) == 'first': |
---|
416 | self.pay_item_id = '115' |
---|
417 | else: |
---|
418 | self.pay_item_id = '116' |
---|
419 | xmldict['institution_acct'] = '1010893123' |
---|
420 | xmldict['institution_bank_id'] = '117' |
---|
421 | xmldict['institution_amt'] = 100 * ( |
---|
422 | gateway_net_amt(self.context.amount_auth)) |
---|
423 | |
---|
424 | # ENT Fees |
---|
425 | elif self.context.p_category.startswith('ent_'): |
---|
426 | if contr_agreement_student(student) == 'first': |
---|
427 | self.pay_item_id = '114' |
---|
428 | else: |
---|
429 | self.pay_item_id = '118' |
---|
430 | xmldict['institution_acct'] = '6220029828' |
---|
431 | xmldict['institution_bank_id'] = '51' |
---|
432 | xmldict['institution_amt'] = 100 * ( |
---|
433 | gateway_net_amt(self.context.amount_auth)) |
---|
434 | |
---|
435 | # Faculty and Departmental Dues |
---|
436 | elif self.context.p_category == 'fac_dep': |
---|
437 | self.pay_item_id = '117' |
---|
438 | xmldict['institution_amt'] = 100 * ( |
---|
439 | gateway_net_amt(self.context.amount_auth)) |
---|
440 | |
---|
441 | # Restitution Fee |
---|
442 | elif self.context.p_category == 'restitution': |
---|
443 | self.pay_item_id = '117' |
---|
444 | xmldict['institution_amt'] = 100 * ( |
---|
445 | gateway_net_amt(self.context.amount_auth)) |
---|
446 | |
---|
447 | # Late Registration Fee |
---|
448 | elif self.context.p_category == 'late_registration': |
---|
449 | if contr_agreement_student(student) == 'first': |
---|
450 | self.pay_item_id = '113' |
---|
451 | else: |
---|
452 | self.pay_item_id = '123' |
---|
453 | xmldict['institution_amt'] = 100 * ( |
---|
454 | gateway_net_amt(self.context.amount_auth)) |
---|
455 | |
---|
456 | if not xmltext: |
---|
457 | xmltext = """<payment_item_detail> |
---|
458 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
459 | <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" /> |
---|
460 | </item_details> |
---|
461 | </payment_item_detail>""" % xmldict |
---|
462 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
463 | self.context.provider_amt = provider_amt |
---|
464 | self.context.gateway_amt = self.amount_auth - gateway_net_amt( |
---|
465 | self.amount_auth) |
---|
466 | hashargs = ( |
---|
467 | self.context.p_id + |
---|
468 | self.product_id + |
---|
469 | self.pay_item_id + |
---|
470 | str(int(self.amount_auth)) + |
---|
471 | self.site_redirect_url + |
---|
472 | self.mac) |
---|
473 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
474 | return |
---|
475 | |
---|
476 | |
---|
477 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
478 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
479 | """Request webservice view for the CollegePAY gateway |
---|
480 | """ |
---|
481 | grok.context(ICustomApplicantOnlinePayment) |
---|
482 | gateway_host = HOST |
---|
483 | gateway_url = URL |
---|
484 | https = HTTPS |
---|
485 | |
---|
486 | @property |
---|
487 | def mac(self): |
---|
488 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
489 | return MAC_PT |
---|
490 | return MAC_REGULAR |
---|
491 | |
---|
492 | @property |
---|
493 | def product_id(self): |
---|
494 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
495 | return PRODUCT_ID_PT |
---|
496 | return PRODUCT_ID_REGULAR |
---|
497 | |
---|
498 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
499 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
500 | """Payment verify view for the CollegePAY gateway |
---|
501 | """ |
---|
502 | grok.context(ICustomApplicantOnlinePayment) |
---|
503 | gateway_host = HOST |
---|
504 | gateway_url = URL |
---|
505 | https = HTTPS |
---|
506 | |
---|
507 | @property |
---|
508 | def mac(self): |
---|
509 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
510 | return MAC_PT |
---|
511 | return MAC_REGULAR |
---|
512 | |
---|
513 | @property |
---|
514 | def product_id(self): |
---|
515 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
516 | return PRODUCT_ID_PT |
---|
517 | return PRODUCT_ID_REGULAR |
---|
518 | |
---|
519 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
520 | InterswitchPaymentRequestWebservicePageStudent): |
---|
521 | """Request webservice view for the CollegePAY gateway |
---|
522 | """ |
---|
523 | grok.context(ICustomStudentOnlinePayment) |
---|
524 | gateway_host = HOST |
---|
525 | gateway_url = URL |
---|
526 | https = HTTPS |
---|
527 | |
---|
528 | @property |
---|
529 | def mac(self): |
---|
530 | if contr_agreement_student(self.context.student) == 'first': |
---|
531 | return MAC_PT |
---|
532 | return MAC_REGULAR |
---|
533 | |
---|
534 | @property |
---|
535 | def product_id(self): |
---|
536 | if contr_agreement_student(self.context.student) == 'first': |
---|
537 | return PRODUCT_ID_PT |
---|
538 | return PRODUCT_ID_REGULAR |
---|
539 | |
---|
540 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
541 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
542 | """Payment verify view for the CollegePAY gateway |
---|
543 | """ |
---|
544 | grok.context(ICustomStudentOnlinePayment) |
---|
545 | gateway_host = HOST |
---|
546 | gateway_url = URL |
---|
547 | https = HTTPS |
---|
548 | |
---|
549 | @property |
---|
550 | def mac(self): |
---|
551 | if contr_agreement_student(self.context.student) == 'first': |
---|
552 | return MAC_PT |
---|
553 | return MAC_REGULAR |
---|
554 | |
---|
555 | @property |
---|
556 | def product_id(self): |
---|
557 | if contr_agreement_student(self.context.student) == 'first': |
---|
558 | return PRODUCT_ID_PT |
---|
559 | return PRODUCT_ID_REGULAR |
---|