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

Last change on this file since 15369 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
RevLine 
[12730]1## $Id: browser.py 15359 2019-03-21 22:42:34Z henrik $
[11846]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
[12975]23from waeup.kofa.interfaces import CLEARED
[11846]24from kofacustom.nigeria.interswitch.browser import (
25    InterswitchPaymentRequestWebservicePageStudent,
26    InterswitchPaymentRequestWebservicePageApplicant,
[13586]27    InterswitchPaymentVerifyWebservicePageApplicant,
28    InterswitchPaymentVerifyWebservicePageStudent,
[11846]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
[13379]35PRODUCT_ID_PT = '5040'
36PRODUCT_ID_REGULAR = '5845'
[11846]37SITE_NAME = 'aaue.waeup.org'
[14823]38PROVIDER_ACCT = '1014261520'
[14232]39PROVIDER_BANK_ID = '117'
[14823]40PROVIDER_ITEM_NAME = 'WAeAC'
[11846]41INSTITUTION_NAME = 'AAU Ekpoma'
42CURRENCY = '566'
[11934]43GATEWAY_AMT = 250.0
[11933]44POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
[11846]45
[11933]46HOST = 'webpay.interswitchng.com'
[13586]47URL = '/paydirect/api/v1/gettransaction.json'
[11916]48HTTPS = True
[13606]49MAC_REGULAR = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023'
50MAC_PT = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
[11846]51
[11917]52httplib.HTTPSConnection.debuglevel = 0
[11846]53
[13379]54
[13414]55def gateway_net_amt(fee):
[13438]56    if fee > GATEWAY_AMT:
[13414]57        return fee - GATEWAY_AMT
[13438]58    return 0.0
[13406]59
[13532]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):
[15359]66    if student.current_mode in ('found', 'bridge') or student.current_mode.endswith('_pt'):
[13403]67        return 'first'
68    return 'second'
[13379]69
[11846]70class CustomInterswitchPageApplicant(InterswitchPageApplicant):
71    """ View which sends a POST request to the Interswitch
72    CollegePAY payment gateway.
[13379]73
74    So far only PT application has been configured.
[11846]75    """
76    grok.context(ICustomApplicantOnlinePayment)
77    action = POST_ACTION
78    site_name = SITE_NAME
79    currency = CURRENCY
[15135]80    provider_bank_id = PROVIDER_BANK_ID
81    provider_acct = PROVIDER_ACCT
[15224]82    institution_acct = '1010835352'
83    institution_bank_id = '117'
[11846]84
85    def update(self):
86
[12975]87        error = self.init_update()
88        if error:
89            self.flash(error, type='danger')
90            self.redirect(self.url(self.context, '@@index'))
91            return
[15260]92        provider_amt = 2000.0
[13532]93        if contr_agreement_applicant(self.context.__parent__) == 'first':
94            self.product_id = PRODUCT_ID_PT
95            self.pay_item_id = '101'
[13606]96            self.mac = MAC_PT
[13532]97        else:
98            self.product_id = PRODUCT_ID_REGULAR
99            self.pay_item_id = '109'
[13606]100            self.mac = MAC_REGULAR
[15121]101            if self.applicant.__parent__.prefix in ('trans', 'cert'):
[15135]102                self.provider_bank_id = '10'
103                self.provider_acct = '0427773399'
[15224]104            elif self.applicant.applicant_id.startswith('bridge',): # easier to test
105                self.institution_acct = '1014847058'
106                self.institution_bank_id = '7'
107
[11846]108        xmldict = {}
109        xmldict['detail_ref'] = self.context.p_id
110        xmldict['provider_amt'] = 100 * provider_amt
[15135]111        xmldict['provider_acct'] = self.provider_acct
112        xmldict['provider_bank_id'] = self.provider_bank_id
[11846]113        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
[15224]114        xmldict['institution_acct'] = self.institution_acct
115        xmldict['institution_bank_id'] = self.institution_bank_id
[13532]116        xmldict['institution_item_name'] = self.category
[11846]117        xmldict['institution_name'] = INSTITUTION_NAME
[15224]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
[14121]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>
[11846]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" />
[14945]136<item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1010827641" />
[11846]137</item_details>
138</payment_item_detail>""" % xmldict
[14121]139
[11846]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 +
[13532]146            self.product_id +
[11846]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
[11868]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
[14248]163    pay_item_id = '000'
[11846]164
[11868]165    def update(self):
[12975]166        error = self.init_update()
[13376]167
[12975]168        if error:
169            self.flash(error, type='danger')
170            self.redirect(self.url(self.context, '@@index'))
171            return
[13400]172
[11868]173        student = self.student
[13408]174        p_session = self.context.p_session
[13400]175        try:
[13408]176            academic_session = grok.getSite()['configuration'][str(p_session)]
[13400]177        except KeyError:
[13407]178            self.flash(_(u'Session configuration object is not available.'),
179                       type='danger')
[13400]180            self.redirect(self.url(self.context, '@@index'))
181            return
[13532]182        if contr_agreement_student(student) == 'first':
[13382]183            self.product_id = PRODUCT_ID_PT
[13606]184            self.mac = MAC_PT
[13382]185        else:
186            self.product_id = PRODUCT_ID_REGULAR
[13606]187            self.mac = MAC_REGULAR
[13382]188
[12975]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
[14380]194        # entry_session greater than 2012 only.
[13400]195        if self.context.p_category.startswith('schoolfee') and \
[12975]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 \
[13400]201                    ticket.p_category.startswith('clearance'):
[12975]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
[11868]210        xmldict = self.xmldict
[12729]211        xmltext = ""
[14945]212        xmldict['institution_acct'] = '1010827641'
213        xmldict['institution_bank_id'] = '117'
[11868]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
[13381]220        provider_amt = 0.0
[12729]221
[13400]222        # Schoolfee
223        if self.context.p_category.startswith('schoolfee'):
[13532]224            if contr_agreement_student(student) == 'first':
[13403]225                # First agreement
[13400]226                provider_amt = 1900.0
227                joint_venture_amt = 1100.0
228                aaue_share_amt = 1000.0
[13414]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)
[15180]233                sports_amt = gateway_net_amt(
234                    academic_session.sports_fee)
235                library_amt = gateway_net_amt(
236                    academic_session.library_fee)
[15181]237                library_amt_pg = gateway_net_amt(
238                    academic_session.library_fee_pg)
[14980]239                xmldict['student_union_bank_id'] = '31'
240                xmldict['student_union_acct'] = '0051005007'
[14920]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'
[15359]245                xmldict['institution_acct'] = '1014847058'
246                xmldict['institution_bank_id'] = '7'
[13379]247                if student.current_mode == 'found':
248                    self.pay_item_id = '103'
249                else:
250                    self.pay_item_id = '105'
[13400]251            else:
[13403]252                # Second agreement
[13400]253                provider_amt = 1500.0
254                joint_venture_amt = 1000.0
255                aaue_share_amt = 1500.0
[13414]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)
[15180]260                sports_amt = gateway_net_amt(
261                    academic_session.sports_fee)
262                library_amt = gateway_net_amt(
263                    academic_session.library_fee)
[15181]264                library_amt_pg = gateway_net_amt(
265                    academic_session.library_fee_pg)
[14980]266                xmldict['student_union_bank_id'] = '7'
267                xmldict['student_union_acct'] = '1019763348'
[14920]268                xmldict['aaue_share_bank_id'] = '117'
269                xmldict['aaue_share_acct'] = '1010827641'
[14235]270                xmldict['joint_venture_bank_id'] = '117'
[14920]271                xmldict['joint_venture_acct'] = '1010827641'
[13644]272                self.pay_item_id = '107'
[13527]273                if student.is_postgrad:
274                    self.pay_item_id = '111'
[14469]275                if student.current_mode == 'ijmbe':
[14523]276                    self.pay_item_id = '119'
[14469]277                    xmldict['joint_venture_bank_id'] = '117'
[14945]278                    xmldict['joint_venture_acct'] = '1010827641'
[13400]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
[13732]283            if self.context.p_item == 'Balance':
284                xmldict['institution_amt'] = 100 * (
285                    gateway_net_amt(self.context.amount_auth))
[14987]286            elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \
287                and student.current_mode != 'ijmbe':
[13400]288                # Schoolfee including additional fees
[13379]289                xmldict['student_union_due_amt'] = 100 * student_union_due_amt
290                xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
[15192]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>
[11868]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" />
[12729]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" />
[14235]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" />
[14086]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" />
[14979]314<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
[15233]315<item_detail item_id="7" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" />
[15180]316<item_detail item_id="8" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />
[11868]317</item_details>
318</payment_item_detail>""" % xmldict
[15192]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
[13400]337            else:
338                # Schoolfee without additional fees
339                xmldict['institution_amt'] = 100 * (
[13414]340                    gateway_net_amt(self.context.amount_auth)
[13400]341                    - provider_amt
342                    - joint_venture_amt
[13414]343                    - aaue_share_amt)
[13400]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" />
[14235]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" />
[13400]350</item_details>
351</payment_item_detail>""" % xmldict
352
353
354        # Clearance
355        elif self.context.p_category.startswith('clearance'):
[15168]356            provider_amt = 1500.0
357            xmldict['provider_amt'] = 100 * provider_amt
[13532]358            if contr_agreement_student(student) == 'first':
[13403]359                # First agreement
[13379]360                if student.current_mode == 'found':
361                    self.pay_item_id = '102'
362                else:
363                    self.pay_item_id = '104'
[15359]364                xmldict['institution_acct'] = '1014847058'
365                xmldict['institution_bank_id'] = '7'
[13400]366            else:
[13403]367                # Second agreement
[13400]368                self.pay_item_id = '102'
[13527]369                if student.is_postgrad:
370                    self.pay_item_id = '110'
[14469]371                if student.current_mode == 'ijmbe':
[14523]372                    self.pay_item_id = '120'
[13400]373
[13410]374            if self.context.p_category.endswith('_incl'):
[13400]375                # Clearance including additional fees
[13414]376                gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee)
377                aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee)
[13379]378                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
[13414]379                xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt
[13379]380                xmldict['institution_amt'] = 100 * (
[13414]381                    gateway_net_amt(self.context.amount_auth)
[13409]382                    - gown_fee_amt
[15190]383                    - aaue_lf_fee_amt
384                    - provider_amt)
[13379]385                xmltext = """<payment_item_detail>
[11868]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" />
[14920]388<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" />
[14945]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" />
[15168]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" />
[11868]391</item_details>
392</payment_item_detail>""" % xmldict
[13400]393
[13381]394            else:
[13400]395                # Clearance without additional fees
[13381]396                xmldict['institution_amt'] = 100 * (
[15190]397                    gateway_net_amt(self.context.amount_auth)
398                    - provider_amt)
[15168]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
[13379]405
[15168]406
[13403]407        # Union Dues
[13400]408        elif self.context.p_category == 'union':
409            self.pay_item_id = '103'
410            xmldict['institution_amt'] = 100 * (
[13414]411                gateway_net_amt(self.context.amount_auth))
[14980]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'
[13379]420
[13403]421        # Lapel/File
[13400]422        elif self.context.p_category == 'lapel':
423            self.pay_item_id = '104'
424            xmldict['institution_amt'] = 100 * (
[13414]425                gateway_net_amt(self.context.amount_auth))
[13381]426
[13403]427        # Welfare Assurance
[13400]428        elif self.context.p_category == 'welfare':
429            self.pay_item_id = '105'
[14979]430            xmldict['institution_acct'] = '1006407792'
431            xmldict['institution_bank_id'] = '123'
[13400]432            xmldict['institution_amt'] = 100 * (
[13414]433                gateway_net_amt(self.context.amount_auth))
[13381]434
[14234]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
[13400]441        # Matric Gown
442        elif self.context.p_category == 'matric_gown':
443            self.pay_item_id = '106'
444            xmldict['institution_amt'] = 100 * (
[13414]445                gateway_net_amt(self.context.amount_auth))
[13381]446
[13400]447        # Concessional
448        elif self.context.p_category == 'concessional':
449            self.pay_item_id = '107'
450            xmldict['institution_amt'] = 100 * (
[13414]451                gateway_net_amt(self.context.amount_auth))
[13381]452
[13400]453        # Hostel Maintenance
454        elif self.context.p_category == 'hostel_maintenance':
[14223]455            provider_amt = 500.0
[13400]456            self.pay_item_id = '109'
[14223]457            xmldict['provider_amt'] = 100 * provider_amt
[13400]458            xmldict['institution_amt'] = 100 * (
[14223]459                gateway_net_amt(self.context.amount_auth) - provider_amt)
[13400]460            xmltext = """<payment_item_detail>
[13383]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" />
[14223]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" />
[13383]464</item_details>
465</payment_item_detail>""" % xmldict
466
[14258]467        # GST Fees
468        elif self.context.p_category.startswith('gst_'):
[14687]469            if contr_agreement_student(student) == 'first':
470                self.pay_item_id = '115'
471            else:
472                self.pay_item_id = '116'
[14979]473            xmldict['institution_acct'] = '1010893123'
474            xmldict['institution_bank_id'] = '117'
[14258]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_'):
[14687]480            if contr_agreement_student(student) == 'first':
481                self.pay_item_id = '114'
482            else:
483                self.pay_item_id = '118'
[14979]484            xmldict['institution_acct'] = '6220029828'
485            xmldict['institution_bank_id'] = '51'
[14258]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
[14376]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
[14676]501        # Late Registration Fee
502        elif self.context.p_category == 'late_registration':
[14686]503            if contr_agreement_student(student) == 'first':
504                self.pay_item_id = '113'
505            else:
506                self.pay_item_id = '123'
[14676]507            xmldict['institution_amt'] = 100 * (
508                gateway_net_amt(self.context.amount_auth))
[14945]509
510        if not xmltext:
[14676]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
[11868]516        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
517        self.context.provider_amt = provider_amt
[13437]518        self.context.gateway_amt = self.amount_auth - gateway_net_amt(
519            self.amount_auth)
[11868]520        hashargs = (
521            self.context.p_id +
[13382]522            self.product_id +
[11868]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
[11846]531class CustomInterswitchPaymentRequestWebservicePageApplicant(
532    InterswitchPaymentRequestWebservicePageApplicant):
[13586]533    """Request webservice view for the CollegePAY gateway
534    """
535    grok.context(ICustomApplicantOnlinePayment)
536    gateway_host = HOST
537    gateway_url = URL
538    https = HTTPS
[13379]539
[13586]540    @property
[13606]541    def mac(self):
542        if contr_agreement_applicant(self.context.__parent__) == 'first':
543            return MAC_PT
544        return MAC_REGULAR
545
546    @property
[13586]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
[11846]555    """
556    grok.context(ICustomApplicantOnlinePayment)
557    gateway_host = HOST
[13586]558    gateway_url = URL
[11916]559    https = HTTPS
[11868]560
[13532]561    @property
[13606]562    def mac(self):
563        if contr_agreement_applicant(self.context.__parent__) == 'first':
564            return MAC_PT
565        return MAC_REGULAR
566
567    @property
[13532]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
[11868]573class CustomInterswitchPaymentRequestWebservicePageStudent(
574    InterswitchPaymentRequestWebservicePageStudent):
[13586]575    """Request webservice view for the CollegePAY gateway
[11868]576    """
577    grok.context(ICustomStudentOnlinePayment)
578    gateway_host = HOST
[13586]579    gateway_url = URL
[11916]580    https = HTTPS
[13379]581
582    @property
[13606]583    def mac(self):
584        if contr_agreement_student(self.context.student) == 'first':
585            return MAC_PT
586        return MAC_REGULAR
587
588    @property
[13379]589    def product_id(self):
[13532]590        if contr_agreement_student(self.context.student) == 'first':
[13379]591            return PRODUCT_ID_PT
592        return PRODUCT_ID_REGULAR
[13586]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
[13606]604    def mac(self):
605        if contr_agreement_student(self.context.student) == 'first':
606            return MAC_PT
607        return MAC_REGULAR
608
609    @property
[13586]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.