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

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

First contract students don't pay Joint Venture and AAUE Share.

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