source: main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py @ 15362

Last change on this file since 15362 was 15359, checked in by Henrik Bettermann, 6 years ago

Configure bridge student payments.

  • Property svn:keywords set to Id
File size: 27.7 KB
Line 
1## $Id: browser.py 15359 2019-03-21 22:42:34Z 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##
18import httplib
19import hashlib
20import grok
21from zope.interface import Interface
22from zope.component import queryAdapter
23from waeup.kofa.interfaces import CLEARED
24from kofacustom.nigeria.interswitch.browser import (
25    InterswitchPaymentRequestWebservicePageStudent,
26    InterswitchPaymentRequestWebservicePageApplicant,
27    InterswitchPaymentVerifyWebservicePageApplicant,
28    InterswitchPaymentVerifyWebservicePageStudent,
29    InterswitchPageStudent, InterswitchPageApplicant,
30    )
31from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment
32from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment
33from waeup.aaue.interfaces import MessageFactory as _
34
35PRODUCT_ID_PT = '5040'
36PRODUCT_ID_REGULAR = '5845'
37SITE_NAME = 'aaue.waeup.org'
38PROVIDER_ACCT = '1014261520'
39PROVIDER_BANK_ID = '117'
40PROVIDER_ITEM_NAME = 'WAeAC'
41INSTITUTION_NAME = 'AAU Ekpoma'
42CURRENCY = '566'
43GATEWAY_AMT = 250.0
44POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
45
46HOST = 'webpay.interswitchng.com'
47URL = '/paydirect/api/v1/gettransaction.json'
48HTTPS = True
49MAC_REGULAR = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023'
50MAC_PT = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
51
52httplib.HTTPSConnection.debuglevel = 0
53
54
55def gateway_net_amt(fee):
56    if fee > GATEWAY_AMT:
57        return fee - GATEWAY_AMT
58    return 0.0
59
60def contr_agreement_applicant(applicant):
61    if applicant.__parent__.code[:2] in ('fp', 'pt'):
62        return 'first'
63    return 'second'
64
65def contr_agreement_student(student):
66    if student.current_mode in ('found', 'bridge') or student.current_mode.endswith('_pt'):
67        return 'first'
68    return 'second'
69
70class 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
155class 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                xmldict['institution_acct'] = '1014847058'
246                xmldict['institution_bank_id'] = '7'
247                if student.current_mode == 'found':
248                    self.pay_item_id = '103'
249                else:
250                    self.pay_item_id = '105'
251            else:
252                # Second agreement
253                provider_amt = 1500.0
254                joint_venture_amt = 1000.0
255                aaue_share_amt = 1500.0
256                student_union_due_amt = gateway_net_amt(
257                    academic_session.union_fee)
258                student_welfare_assurance_amt = gateway_net_amt(
259                    academic_session.welfare_fee)
260                sports_amt = gateway_net_amt(
261                    academic_session.sports_fee)
262                library_amt = gateway_net_amt(
263                    academic_session.library_fee)
264                library_amt_pg = gateway_net_amt(
265                    academic_session.library_fee_pg)
266                xmldict['student_union_bank_id'] = '7'
267                xmldict['student_union_acct'] = '1019763348'
268                xmldict['aaue_share_bank_id'] = '117'
269                xmldict['aaue_share_acct'] = '1010827641'
270                xmldict['joint_venture_bank_id'] = '117'
271                xmldict['joint_venture_acct'] = '1010827641'
272                self.pay_item_id = '107'
273                if student.is_postgrad:
274                    self.pay_item_id = '111'
275                if student.current_mode == 'ijmbe':
276                    self.pay_item_id = '119'
277                    xmldict['joint_venture_bank_id'] = '117'
278                    xmldict['joint_venture_acct'] = '1010827641'
279
280            xmldict['provider_amt'] = 100 * provider_amt
281            xmldict['joint_venture_amt'] = 100 * joint_venture_amt
282            xmldict['aaue_share_amt'] = 100 * aaue_share_amt
283            if self.context.p_item == 'Balance':
284                xmldict['institution_amt'] = 100 * (
285                    gateway_net_amt(self.context.amount_auth))
286            elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \
287                and student.current_mode != 'ijmbe':
288                # Schoolfee including additional fees
289                xmldict['student_union_due_amt'] = 100 * student_union_due_amt
290                xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
291
292                if student.entry_session == 2018 and student.is_fresh:
293                    xmldict['sports_amt'] = 100 * sports_amt
294                    if student.is_postgrad:
295                        xmldict['library_amt'] = 100 * library_amt_pg
296                    else:
297                        xmldict['library_amt'] = 100 * library_amt
298                    xmldict['institution_amt'] = 100 * (
299                        gateway_net_amt(self.context.amount_auth)
300                        - provider_amt
301                        - joint_venture_amt
302                        - aaue_share_amt
303                        - student_union_due_amt
304                        - student_welfare_assurance_amt
305                        - sports_amt
306                        - library_amt)
307                    xmltext = """<payment_item_detail>
308<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
309<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" />
310<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" />
311<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" />
312<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" />
313<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" />
314<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
315<item_detail item_id="7" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" />
316<item_detail item_id="8" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />
317</item_details>
318</payment_item_detail>""" % xmldict
319                else:
320                    xmldict['institution_amt'] = 100 * (
321                        gateway_net_amt(self.context.amount_auth)
322                        - provider_amt
323                        - joint_venture_amt
324                        - aaue_share_amt
325                        - student_union_due_amt
326                        - student_welfare_assurance_amt)
327                    xmltext = """<payment_item_detail>
328<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
329<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" />
330<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" />
331<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" />
332<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" />
333<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" />
334<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
335</item_details>
336</payment_item_detail>""" % xmldict
337            else:
338                # Schoolfee without additional fees
339                xmldict['institution_amt'] = 100 * (
340                    gateway_net_amt(self.context.amount_auth)
341                    - provider_amt
342                    - joint_venture_amt
343                    - aaue_share_amt)
344                xmltext = """<payment_item_detail>
345<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
346<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" />
347<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" />
348<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" />
349<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" />
350</item_details>
351</payment_item_detail>""" % xmldict
352
353
354        # Clearance
355        elif self.context.p_category.startswith('clearance'):
356            provider_amt = 1500.0
357            xmldict['provider_amt'] = 100 * provider_amt
358            if contr_agreement_student(student) == 'first':
359                # First agreement
360                if student.current_mode == 'found':
361                    self.pay_item_id = '102'
362                else:
363                    self.pay_item_id = '104'
364                xmldict['institution_acct'] = '1014847058'
365                xmldict['institution_bank_id'] = '7'
366            else:
367                # Second agreement
368                self.pay_item_id = '102'
369                if student.is_postgrad:
370                    self.pay_item_id = '110'
371                if student.current_mode == 'ijmbe':
372                    self.pay_item_id = '120'
373
374            if self.context.p_category.endswith('_incl'):
375                # Clearance including additional fees
376                gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee)
377                aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee)
378                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
379                xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt
380                xmldict['institution_amt'] = 100 * (
381                    gateway_net_amt(self.context.amount_auth)
382                    - gown_fee_amt
383                    - aaue_lf_fee_amt
384                    - provider_amt)
385                xmltext = """<payment_item_detail>
386<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
387<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" />
388<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" />
389<item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_lf_fee_amt)d" bank_id="117" acct_num="1010827641" />
390<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" />
391</item_details>
392</payment_item_detail>""" % xmldict
393
394            else:
395                # Clearance without additional fees
396                xmldict['institution_amt'] = 100 * (
397                    gateway_net_amt(self.context.amount_auth)
398                    - provider_amt)
399                xmltext = """<payment_item_detail>
400<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
401<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" />
402<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" />
403</item_details>
404</payment_item_detail>""" % xmldict
405
406
407        # Union Dues
408        elif self.context.p_category == 'union':
409            self.pay_item_id = '103'
410            xmldict['institution_amt'] = 100 * (
411                gateway_net_amt(self.context.amount_auth))
412            if contr_agreement_student(student) == 'first':
413                # First agreement
414                xmldict['institution_acct'] = '0051005007'
415                xmldict['institution_bank_id'] = '31'
416            else:
417                # Second agreement
418                xmldict['institution_bank_id'] = '7'
419                xmldict['institution_acct'] = '1019763348'
420
421        # Lapel/File
422        elif self.context.p_category == 'lapel':
423            self.pay_item_id = '104'
424            xmldict['institution_amt'] = 100 * (
425                gateway_net_amt(self.context.amount_auth))
426
427        # Welfare Assurance
428        elif self.context.p_category == 'welfare':
429            self.pay_item_id = '105'
430            xmldict['institution_acct'] = '1006407792'
431            xmldict['institution_bank_id'] = '123'
432            xmldict['institution_amt'] = 100 * (
433                gateway_net_amt(self.context.amount_auth))
434
435        # ID Card
436        elif self.context.p_category == 'id_card':
437            self.pay_item_id = '000'
438            xmldict['institution_amt'] = 100 * (
439                gateway_net_amt(self.context.amount_auth))
440
441        # Matric Gown
442        elif self.context.p_category == 'matric_gown':
443            self.pay_item_id = '106'
444            xmldict['institution_amt'] = 100 * (
445                gateway_net_amt(self.context.amount_auth))
446
447        # Concessional
448        elif self.context.p_category == 'concessional':
449            self.pay_item_id = '107'
450            xmldict['institution_amt'] = 100 * (
451                gateway_net_amt(self.context.amount_auth))
452
453        # Hostel Maintenance
454        elif self.context.p_category == 'hostel_maintenance':
455            provider_amt = 500.0
456            self.pay_item_id = '109'
457            xmldict['provider_amt'] = 100 * provider_amt
458            xmldict['institution_amt'] = 100 * (
459                gateway_net_amt(self.context.amount_auth) - provider_amt)
460            xmltext = """<payment_item_detail>
461<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
462<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" />
463<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" />
464</item_details>
465</payment_item_detail>""" % xmldict
466
467        # GST Fees
468        elif self.context.p_category.startswith('gst_'):
469            if contr_agreement_student(student) == 'first':
470                self.pay_item_id = '115'
471            else:
472                self.pay_item_id = '116'
473            xmldict['institution_acct'] = '1010893123'
474            xmldict['institution_bank_id'] = '117'
475            xmldict['institution_amt'] = 100 * (
476                gateway_net_amt(self.context.amount_auth))
477
478        # ENT Fees
479        elif self.context.p_category.startswith('ent_'):
480            if contr_agreement_student(student) == 'first':
481                self.pay_item_id = '114'
482            else:
483                self.pay_item_id = '118'
484            xmldict['institution_acct'] = '6220029828'
485            xmldict['institution_bank_id'] = '51'
486            xmldict['institution_amt'] = 100 * (
487                gateway_net_amt(self.context.amount_auth))
488
489        # Faculty and Departmental Dues
490        elif self.context.p_category == 'fac_dep':
491            self.pay_item_id = '117'
492            xmldict['institution_amt'] = 100 * (
493                gateway_net_amt(self.context.amount_auth))
494
495        # Restitution Fee
496        elif self.context.p_category == 'restitution':
497            self.pay_item_id = '117'
498            xmldict['institution_amt'] = 100 * (
499                gateway_net_amt(self.context.amount_auth))
500
501        # Late Registration Fee
502        elif self.context.p_category == 'late_registration':
503            if contr_agreement_student(student) == 'first':
504                self.pay_item_id = '113'
505            else:
506                self.pay_item_id = '123'
507            xmldict['institution_amt'] = 100 * (
508                gateway_net_amt(self.context.amount_auth))
509
510        if not xmltext:
511            xmltext = """<payment_item_detail>
512<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
513<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" />
514</item_details>
515</payment_item_detail>""" % xmldict
516        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
517        self.context.provider_amt = provider_amt
518        self.context.gateway_amt = self.amount_auth - gateway_net_amt(
519            self.amount_auth)
520        hashargs = (
521            self.context.p_id +
522            self.product_id +
523            self.pay_item_id +
524            str(int(self.amount_auth)) +
525            self.site_redirect_url +
526            self.mac)
527        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
528        return
529
530
531class CustomInterswitchPaymentRequestWebservicePageApplicant(
532    InterswitchPaymentRequestWebservicePageApplicant):
533    """Request webservice view for the CollegePAY gateway
534    """
535    grok.context(ICustomApplicantOnlinePayment)
536    gateway_host = HOST
537    gateway_url = URL
538    https = HTTPS
539
540    @property
541    def mac(self):
542        if contr_agreement_applicant(self.context.__parent__) == 'first':
543            return MAC_PT
544        return MAC_REGULAR
545
546    @property
547    def product_id(self):
548        if contr_agreement_applicant(self.context.__parent__) == 'first':
549            return PRODUCT_ID_PT
550        return PRODUCT_ID_REGULAR
551
552class CustomInterswitchPaymentVerifyWebservicePageApplicant(
553    InterswitchPaymentVerifyWebservicePageApplicant):
554    """Payment verify view for the CollegePAY gateway
555    """
556    grok.context(ICustomApplicantOnlinePayment)
557    gateway_host = HOST
558    gateway_url = URL
559    https = HTTPS
560
561    @property
562    def mac(self):
563        if contr_agreement_applicant(self.context.__parent__) == 'first':
564            return MAC_PT
565        return MAC_REGULAR
566
567    @property
568    def product_id(self):
569        if contr_agreement_applicant(self.context.__parent__) == 'first':
570            return PRODUCT_ID_PT
571        return PRODUCT_ID_REGULAR
572
573class CustomInterswitchPaymentRequestWebservicePageStudent(
574    InterswitchPaymentRequestWebservicePageStudent):
575    """Request webservice view for the CollegePAY gateway
576    """
577    grok.context(ICustomStudentOnlinePayment)
578    gateway_host = HOST
579    gateway_url = URL
580    https = HTTPS
581
582    @property
583    def mac(self):
584        if contr_agreement_student(self.context.student) == 'first':
585            return MAC_PT
586        return MAC_REGULAR
587
588    @property
589    def product_id(self):
590        if contr_agreement_student(self.context.student) == 'first':
591            return PRODUCT_ID_PT
592        return PRODUCT_ID_REGULAR
593
594class CustomInterswitchPaymentVerifyWebservicePageStudent(
595    InterswitchPaymentVerifyWebservicePageStudent):
596    """Payment verify view for the CollegePAY gateway
597    """
598    grok.context(ICustomStudentOnlinePayment)
599    gateway_host = HOST
600    gateway_url = URL
601    https = HTTPS
602
603    @property
604    def mac(self):
605        if contr_agreement_student(self.context.student) == 'first':
606            return MAC_PT
607        return MAC_REGULAR
608
609    @property
610    def product_id(self):
611        if contr_agreement_student(self.context.student) == 'first':
612            return PRODUCT_ID_PT
613        return PRODUCT_ID_REGULAR
Note: See TracBrowser for help on using the repository browser.