1 | ## $Id: browser.py 13532 2015-12-03 17:37:00Z 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 | InterswitchPageStudent, InterswitchPageApplicant, |
---|
28 | ) |
---|
29 | from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment |
---|
30 | from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
31 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
32 | |
---|
33 | PRODUCT_ID_PT = '5040' |
---|
34 | PRODUCT_ID_REGULAR = '5845' |
---|
35 | SITE_NAME = 'aaue.waeup.org' |
---|
36 | PROVIDER_ACCT = '2022866811' |
---|
37 | PROVIDER_BANK_ID = '8' |
---|
38 | PROVIDER_ITEM_NAME = 'BT Education' |
---|
39 | INSTITUTION_NAME = 'AAU Ekpoma' |
---|
40 | CURRENCY = '566' |
---|
41 | GATEWAY_AMT = 250.0 |
---|
42 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' |
---|
43 | |
---|
44 | HOST = 'webpay.interswitchng.com' |
---|
45 | HTTPS = True |
---|
46 | |
---|
47 | httplib.HTTPSConnection.debuglevel = 0 |
---|
48 | |
---|
49 | |
---|
50 | def gateway_net_amt(fee): |
---|
51 | if fee > GATEWAY_AMT: |
---|
52 | return fee - GATEWAY_AMT |
---|
53 | return 0.0 |
---|
54 | |
---|
55 | def contr_agreement_applicant(applicant): |
---|
56 | if applicant.__parent__.code[:2] in ('fp', 'pt'): |
---|
57 | return 'first' |
---|
58 | return 'second' |
---|
59 | |
---|
60 | def contr_agreement_student(student): |
---|
61 | if student.current_mode == 'found' or student.current_mode.endswith('_pt'): |
---|
62 | return 'first' |
---|
63 | return 'second' |
---|
64 | |
---|
65 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
66 | """ View which sends a POST request to the Interswitch |
---|
67 | CollegePAY payment gateway. |
---|
68 | |
---|
69 | So far only PT application has been configured. |
---|
70 | """ |
---|
71 | grok.context(ICustomApplicantOnlinePayment) |
---|
72 | action = POST_ACTION |
---|
73 | site_name = SITE_NAME |
---|
74 | currency = CURRENCY |
---|
75 | mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3' |
---|
76 | |
---|
77 | def update(self): |
---|
78 | |
---|
79 | error = self.init_update() |
---|
80 | if error: |
---|
81 | self.flash(error, type='danger') |
---|
82 | self.redirect(self.url(self.context, '@@index')) |
---|
83 | return |
---|
84 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
85 | self.product_id = PRODUCT_ID_PT |
---|
86 | self.pay_item_id = '101' |
---|
87 | else: |
---|
88 | self.product_id = PRODUCT_ID_REGULAR |
---|
89 | self.pay_item_id = '109' |
---|
90 | xmldict = {} |
---|
91 | provider_amt = 1000.0 |
---|
92 | xmldict['institution_acct'] = '1010835352' |
---|
93 | xmldict['institution_bank_id'] = '117' |
---|
94 | xmldict['detail_ref'] = self.context.p_id |
---|
95 | xmldict['provider_amt'] = 100 * provider_amt |
---|
96 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
97 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
98 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
99 | xmldict['institution_amt'] = 100 * ( |
---|
100 | self.context.amount_auth - provider_amt - GATEWAY_AMT) |
---|
101 | xmldict['institution_item_name'] = self.category |
---|
102 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
103 | # Interswitch amount is not part of the xml data |
---|
104 | xmltext = """<payment_item_detail> |
---|
105 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
106 | <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" /> |
---|
107 | <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" /> |
---|
108 | </item_details> |
---|
109 | </payment_item_detail>""" % xmldict |
---|
110 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
111 | self.context.provider_amt = provider_amt |
---|
112 | self.context.gateway_amt = GATEWAY_AMT |
---|
113 | |
---|
114 | hashargs = ( |
---|
115 | self.context.p_id + |
---|
116 | self.product_id + |
---|
117 | self.pay_item_id + |
---|
118 | str(int(self.amount_auth)) + |
---|
119 | self.site_redirect_url + |
---|
120 | self.mac) |
---|
121 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
122 | |
---|
123 | return |
---|
124 | |
---|
125 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
126 | """ View which sends a POST request to the Interswitch |
---|
127 | CollegePAY payment gateway. |
---|
128 | """ |
---|
129 | grok.context(ICustomStudentOnlinePayment) |
---|
130 | action = POST_ACTION |
---|
131 | site_name = SITE_NAME |
---|
132 | currency = CURRENCY |
---|
133 | #pay_item_id = '101' |
---|
134 | #mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3' |
---|
135 | mac = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023' |
---|
136 | |
---|
137 | def update(self): |
---|
138 | error = self.init_update() |
---|
139 | |
---|
140 | ###################################### |
---|
141 | #error = 'Sorry, Interswitch payments are temporarily disabled.' |
---|
142 | ###################################### |
---|
143 | |
---|
144 | if error: |
---|
145 | self.flash(error, type='danger') |
---|
146 | self.redirect(self.url(self.context, '@@index')) |
---|
147 | return |
---|
148 | |
---|
149 | student = self.student |
---|
150 | p_session = self.context.p_session |
---|
151 | try: |
---|
152 | academic_session = grok.getSite()['configuration'][str(p_session)] |
---|
153 | except KeyError: |
---|
154 | self.flash(_(u'Session configuration object is not available.'), |
---|
155 | type='danger') |
---|
156 | self.redirect(self.url(self.context, '@@index')) |
---|
157 | return |
---|
158 | if contr_agreement_student(student) == 'first': |
---|
159 | self.product_id = PRODUCT_ID_PT |
---|
160 | else: |
---|
161 | self.product_id = PRODUCT_ID_REGULAR |
---|
162 | |
---|
163 | # To guarantee that cleared students pay both acceptance fee |
---|
164 | # and school fees, the page can only be accessed |
---|
165 | # for school fee payments if acceptance/clearance fee has |
---|
166 | # been successfully queried/paid beforehand. This |
---|
167 | # requirement applies to students in state 'cleared' and |
---|
168 | # entry_session greater than 2013 only. |
---|
169 | if self.context.p_category.startswith('schoolfee') and \ |
---|
170 | student.state == CLEARED and \ |
---|
171 | student.entry_session > 2012: |
---|
172 | acceptance_fee_paid = False |
---|
173 | for ticket in student['payments'].values(): |
---|
174 | if ticket.p_state == 'paid' and \ |
---|
175 | ticket.p_category.startswith('clearance'): |
---|
176 | acceptance_fee_paid = True |
---|
177 | break |
---|
178 | if not acceptance_fee_paid: |
---|
179 | self.flash( |
---|
180 | _('Please pay acceptance fee first.'), type="danger") |
---|
181 | self.redirect(self.url(self.context, '@@index')) |
---|
182 | return |
---|
183 | |
---|
184 | xmldict = self.xmldict |
---|
185 | xmltext = "" |
---|
186 | # Provider data |
---|
187 | xmldict['detail_ref'] = self.context.p_id |
---|
188 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
189 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
190 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
191 | xmldict['institution_item_name'] = self.category |
---|
192 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
193 | provider_amt = 0.0 |
---|
194 | |
---|
195 | # Schoolfee |
---|
196 | if self.context.p_category.startswith('schoolfee'): |
---|
197 | if contr_agreement_student(student) == 'first': |
---|
198 | # First agreement |
---|
199 | provider_amt = 1900.0 |
---|
200 | joint_venture_amt = 1100.0 |
---|
201 | aaue_share_amt = 1000.0 |
---|
202 | student_union_due_amt = gateway_net_amt( |
---|
203 | academic_session.union_fee) |
---|
204 | student_welfare_assurance_amt = gateway_net_amt( |
---|
205 | academic_session.welfare_fee) |
---|
206 | xmldict['institution_bank_id'] = '7' |
---|
207 | xmldict['institution_acct'] = '1014847058' |
---|
208 | if student.current_mode == 'found': |
---|
209 | self.pay_item_id = '103' |
---|
210 | else: |
---|
211 | self.pay_item_id = '105' |
---|
212 | else: |
---|
213 | # Second agreement |
---|
214 | provider_amt = 1500.0 |
---|
215 | joint_venture_amt = 1000.0 |
---|
216 | aaue_share_amt = 1500.0 |
---|
217 | student_union_due_amt = gateway_net_amt( |
---|
218 | academic_session.union_fee) |
---|
219 | student_welfare_assurance_amt = gateway_net_amt( |
---|
220 | academic_session.welfare_fee) |
---|
221 | xmldict['institution_bank_id'] = '117' |
---|
222 | xmldict['institution_acct'] = '1010827641' |
---|
223 | self.pay_item_id = '101' |
---|
224 | if student.is_postgrad: |
---|
225 | xmldict['institution_bank_id'] = '51' |
---|
226 | xmldict['institution_acct'] = '5210006575' |
---|
227 | self.pay_item_id = '111' |
---|
228 | |
---|
229 | xmldict['provider_amt'] = 100 * provider_amt |
---|
230 | xmldict['joint_venture_amt'] = 100 * joint_venture_amt |
---|
231 | xmldict['aaue_share_amt'] = 100 * aaue_share_amt |
---|
232 | if self.context.p_category in ('schoolfee_incl', 'schoolfee_1'): |
---|
233 | # Schoolfee including additional fees |
---|
234 | xmldict['student_union_due_amt'] = 100 * student_union_due_amt |
---|
235 | xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt |
---|
236 | xmldict['institution_amt'] = 100 * ( |
---|
237 | gateway_net_amt(self.context.amount_auth) |
---|
238 | - provider_amt |
---|
239 | - joint_venture_amt |
---|
240 | - aaue_share_amt |
---|
241 | - student_union_due_amt |
---|
242 | - student_welfare_assurance_amt) |
---|
243 | xmltext = """<payment_item_detail> |
---|
244 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
245 | <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" /> |
---|
246 | <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" /> |
---|
247 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="51" acct_num="5060023759" /> |
---|
248 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
249 | <item_detail item_id="5" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="123" acct_num="1006360118" /> |
---|
250 | <item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="31" acct_num="1006407792" /> |
---|
251 | </item_details> |
---|
252 | </payment_item_detail>""" % xmldict |
---|
253 | else: |
---|
254 | # Schoolfee without additional fees |
---|
255 | xmldict['institution_amt'] = 100 * ( |
---|
256 | gateway_net_amt(self.context.amount_auth) |
---|
257 | - provider_amt |
---|
258 | - joint_venture_amt |
---|
259 | - aaue_share_amt) |
---|
260 | xmltext = """<payment_item_detail> |
---|
261 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
262 | <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" /> |
---|
263 | <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" /> |
---|
264 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="51" acct_num="5060023759" /> |
---|
265 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
266 | </item_details> |
---|
267 | </payment_item_detail>""" % xmldict |
---|
268 | |
---|
269 | |
---|
270 | # Clearance |
---|
271 | elif self.context.p_category.startswith('clearance'): |
---|
272 | if contr_agreement_student(student) == 'first': |
---|
273 | # First agreement |
---|
274 | if student.current_mode == 'found': |
---|
275 | self.pay_item_id = '102' |
---|
276 | else: |
---|
277 | self.pay_item_id = '104' |
---|
278 | xmldict['institution_acct'] = '1014066976' |
---|
279 | xmldict['institution_bank_id'] = '117' |
---|
280 | else: |
---|
281 | # Second agreement |
---|
282 | self.pay_item_id = '102' |
---|
283 | xmldict['institution_acct'] = '1010827641' |
---|
284 | xmldict['institution_bank_id'] = '117' |
---|
285 | if student.is_postgrad: |
---|
286 | xmldict['institution_bank_id'] = '51' |
---|
287 | xmldict['institution_acct'] = '5210006575' |
---|
288 | self.pay_item_id = '110' |
---|
289 | |
---|
290 | if self.context.p_category.endswith('_incl'): |
---|
291 | # Clearance including additional fees |
---|
292 | gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee) |
---|
293 | aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee) |
---|
294 | xmldict['gown_fee_amt'] = 100 * gown_fee_amt |
---|
295 | xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt |
---|
296 | xmldict['institution_amt'] = 100 * ( |
---|
297 | gateway_net_amt(self.context.amount_auth) |
---|
298 | - gown_fee_amt |
---|
299 | - aaue_lf_fee_amt) |
---|
300 | xmltext = """<payment_item_detail> |
---|
301 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
302 | <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" /> |
---|
303 | <item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
304 | <item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_lf_fee_amt)d" bank_id="51" acct_num="4010660109" /> |
---|
305 | </item_details> |
---|
306 | </payment_item_detail>""" % xmldict |
---|
307 | |
---|
308 | else: |
---|
309 | # Clearance without additional fees |
---|
310 | xmldict['institution_amt'] = 100 * ( |
---|
311 | gateway_net_amt(self.context.amount_auth)) |
---|
312 | xmltext = """<payment_item_detail> |
---|
313 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
314 | <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" /> |
---|
315 | </item_details> |
---|
316 | </payment_item_detail>""" % xmldict |
---|
317 | |
---|
318 | # Union Dues |
---|
319 | elif self.context.p_category == 'union': |
---|
320 | self.pay_item_id = '103' |
---|
321 | xmldict['institution_acct'] = '1006360118' |
---|
322 | xmldict['institution_bank_id'] = '123' |
---|
323 | xmldict['institution_amt'] = 100 * ( |
---|
324 | gateway_net_amt(self.context.amount_auth)) |
---|
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_details> |
---|
329 | </payment_item_detail>""" % xmldict |
---|
330 | |
---|
331 | # Lapel/File |
---|
332 | elif self.context.p_category == 'lapel': |
---|
333 | self.pay_item_id = '104' |
---|
334 | xmldict['institution_acct'] = '4010660109' |
---|
335 | xmldict['institution_bank_id'] = '51' |
---|
336 | xmldict['institution_amt'] = 100 * ( |
---|
337 | gateway_net_amt(self.context.amount_auth)) |
---|
338 | xmltext = """<payment_item_detail> |
---|
339 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
340 | <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" /> |
---|
341 | </item_details> |
---|
342 | </payment_item_detail>""" % xmldict |
---|
343 | |
---|
344 | # Welfare Assurance |
---|
345 | elif self.context.p_category == 'welfare': |
---|
346 | self.pay_item_id = '105' |
---|
347 | xmldict['institution_acct'] = '1006407792' |
---|
348 | xmldict['institution_bank_id'] = '123' |
---|
349 | xmldict['institution_amt'] = 100 * ( |
---|
350 | gateway_net_amt(self.context.amount_auth)) |
---|
351 | xmltext = """<payment_item_detail> |
---|
352 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
353 | <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" /> |
---|
354 | </item_details> |
---|
355 | </payment_item_detail>""" % xmldict |
---|
356 | |
---|
357 | # Matric Gown |
---|
358 | elif self.context.p_category == 'matric_gown': |
---|
359 | self.pay_item_id = '106' |
---|
360 | xmldict['institution_acct'] = '5060023429' |
---|
361 | xmldict['institution_bank_id'] = '51' |
---|
362 | xmldict['institution_amt'] = 100 * ( |
---|
363 | gateway_net_amt(self.context.amount_auth)) |
---|
364 | xmltext = """<payment_item_detail> |
---|
365 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
366 | <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" /> |
---|
367 | </item_details> |
---|
368 | </payment_item_detail>""" % xmldict |
---|
369 | |
---|
370 | # Concessional |
---|
371 | elif self.context.p_category == 'concessional': |
---|
372 | self.pay_item_id = '107' |
---|
373 | xmldict['institution_acct'] = '1010835352' |
---|
374 | xmldict['institution_bank_id'] = '117' |
---|
375 | xmldict['institution_amt'] = 100 * ( |
---|
376 | gateway_net_amt(self.context.amount_auth)) |
---|
377 | xmltext = """<payment_item_detail> |
---|
378 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
379 | <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" /> |
---|
380 | </item_details> |
---|
381 | </payment_item_detail>""" % xmldict |
---|
382 | |
---|
383 | # Hostel Maintenance |
---|
384 | elif self.context.p_category == 'hostel_maintenance': |
---|
385 | self.pay_item_id = '109' |
---|
386 | xmldict['institution_acct'] = '1006406795' |
---|
387 | xmldict['institution_bank_id'] = '123' |
---|
388 | xmldict['institution_amt'] = 100 * ( |
---|
389 | gateway_net_amt(self.context.amount_auth)) |
---|
390 | xmltext = """<payment_item_detail> |
---|
391 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
392 | <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" /> |
---|
393 | </item_details> |
---|
394 | </payment_item_detail>""" % xmldict |
---|
395 | |
---|
396 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
397 | self.context.provider_amt = provider_amt |
---|
398 | self.context.gateway_amt = self.amount_auth - gateway_net_amt( |
---|
399 | self.amount_auth) |
---|
400 | hashargs = ( |
---|
401 | self.context.p_id + |
---|
402 | self.product_id + |
---|
403 | self.pay_item_id + |
---|
404 | str(int(self.amount_auth)) + |
---|
405 | self.site_redirect_url + |
---|
406 | self.mac) |
---|
407 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
408 | return |
---|
409 | |
---|
410 | |
---|
411 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
412 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
413 | """ Request webservice view for the CollegePAY gateway |
---|
414 | |
---|
415 | So far only PT application has been configured. |
---|
416 | """ |
---|
417 | grok.context(ICustomApplicantOnlinePayment) |
---|
418 | gateway_host = HOST |
---|
419 | gateway_url = '/paydirect/api/v1/gettransaction.json' |
---|
420 | https = HTTPS |
---|
421 | mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3' |
---|
422 | |
---|
423 | @property |
---|
424 | def product_id(self): |
---|
425 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
426 | return PRODUCT_ID_PT |
---|
427 | return PRODUCT_ID_REGULAR |
---|
428 | |
---|
429 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
430 | InterswitchPaymentRequestWebservicePageStudent): |
---|
431 | """ Request webservice view for the CollegePAY gateway |
---|
432 | """ |
---|
433 | grok.context(ICustomStudentOnlinePayment) |
---|
434 | gateway_host = HOST |
---|
435 | gateway_url = '/paydirect/api/v1/gettransaction.json' |
---|
436 | https = HTTPS |
---|
437 | mac = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023' |
---|
438 | |
---|
439 | @property |
---|
440 | def product_id(self): |
---|
441 | if contr_agreement_student(self.context.student) == 'first': |
---|
442 | return PRODUCT_ID_PT |
---|
443 | return PRODUCT_ID_REGULAR |
---|