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

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

Change provider amount.

  • Property svn:keywords set to Id
File size: 27.5 KB
RevLine 
[12730]1## $Id: browser.py 15260 2018-12-04 08:18:51Z 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):
[13379]66    if student.current_mode == 'found' 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'
[13379]245                if student.current_mode == 'found':
246                    self.pay_item_id = '103'
247                else:
248                    self.pay_item_id = '105'
[13400]249            else:
[13403]250                # Second agreement
[13400]251                provider_amt = 1500.0
252                joint_venture_amt = 1000.0
253                aaue_share_amt = 1500.0
[13414]254                student_union_due_amt = gateway_net_amt(
255                    academic_session.union_fee)
256                student_welfare_assurance_amt = gateway_net_amt(
257                    academic_session.welfare_fee)
[15180]258                sports_amt = gateway_net_amt(
259                    academic_session.sports_fee)
260                library_amt = gateway_net_amt(
261                    academic_session.library_fee)
[15181]262                library_amt_pg = gateway_net_amt(
263                    academic_session.library_fee_pg)
[14980]264                xmldict['student_union_bank_id'] = '7'
265                xmldict['student_union_acct'] = '1019763348'
[14920]266                xmldict['aaue_share_bank_id'] = '117'
267                xmldict['aaue_share_acct'] = '1010827641'
[14235]268                xmldict['joint_venture_bank_id'] = '117'
[14920]269                xmldict['joint_venture_acct'] = '1010827641'
[13644]270                self.pay_item_id = '107'
[13527]271                if student.is_postgrad:
272                    self.pay_item_id = '111'
[14469]273                if student.current_mode == 'ijmbe':
[14523]274                    self.pay_item_id = '119'
[14469]275                    xmldict['joint_venture_bank_id'] = '117'
[14945]276                    xmldict['joint_venture_acct'] = '1010827641'
[13400]277
278            xmldict['provider_amt'] = 100 * provider_amt
279            xmldict['joint_venture_amt'] = 100 * joint_venture_amt
280            xmldict['aaue_share_amt'] = 100 * aaue_share_amt
[13732]281            if self.context.p_item == 'Balance':
282                xmldict['institution_amt'] = 100 * (
283                    gateway_net_amt(self.context.amount_auth))
[14987]284            elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \
285                and student.current_mode != 'ijmbe':
[13400]286                # Schoolfee including additional fees
[13379]287                xmldict['student_union_due_amt'] = 100 * student_union_due_amt
288                xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
[15192]289
290                if student.entry_session == 2018 and student.is_fresh:
291                    xmldict['sports_amt'] = 100 * sports_amt
292                    if student.is_postgrad:
293                        xmldict['library_amt'] = 100 * library_amt_pg
294                    else:
295                        xmldict['library_amt'] = 100 * library_amt
296                    xmldict['institution_amt'] = 100 * (
297                        gateway_net_amt(self.context.amount_auth)
298                        - provider_amt
299                        - joint_venture_amt
300                        - aaue_share_amt
301                        - student_union_due_amt
302                        - student_welfare_assurance_amt
303                        - sports_amt
304                        - library_amt)
305                    xmltext = """<payment_item_detail>
[11868]306<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
307<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]308<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]309<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" />
310<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]311<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]312<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
[15233]313<item_detail item_id="7" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" />
[15180]314<item_detail item_id="8" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />
[11868]315</item_details>
316</payment_item_detail>""" % xmldict
[15192]317                else:
318                    xmldict['institution_amt'] = 100 * (
319                        gateway_net_amt(self.context.amount_auth)
320                        - provider_amt
321                        - joint_venture_amt
322                        - aaue_share_amt
323                        - student_union_due_amt
324                        - student_welfare_assurance_amt)
325                    xmltext = """<payment_item_detail>
326<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
327<item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
328<item_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" />
329<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" />
330<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" />
331<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" />
332<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
333</item_details>
334</payment_item_detail>""" % xmldict
[13400]335            else:
336                # Schoolfee without additional fees
337                xmldict['institution_amt'] = 100 * (
[13414]338                    gateway_net_amt(self.context.amount_auth)
[13400]339                    - provider_amt
340                    - joint_venture_amt
[13414]341                    - aaue_share_amt)
[13400]342                xmltext = """<payment_item_detail>
343<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
344<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" />
345<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]346<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" />
347<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]348</item_details>
349</payment_item_detail>""" % xmldict
350
351
352        # Clearance
353        elif self.context.p_category.startswith('clearance'):
[15168]354            provider_amt = 1500.0
355            xmldict['provider_amt'] = 100 * provider_amt
[13532]356            if contr_agreement_student(student) == 'first':
[13403]357                # First agreement
[13379]358                if student.current_mode == 'found':
359                    self.pay_item_id = '102'
360                else:
361                    self.pay_item_id = '104'
[13400]362            else:
[13403]363                # Second agreement
[13400]364                self.pay_item_id = '102'
[13527]365                if student.is_postgrad:
366                    self.pay_item_id = '110'
[14469]367                if student.current_mode == 'ijmbe':
[14523]368                    self.pay_item_id = '120'
[13400]369
[13410]370            if self.context.p_category.endswith('_incl'):
[13400]371                # Clearance including additional fees
[13414]372                gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee)
373                aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee)
[13379]374                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
[13414]375                xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt
[13379]376                xmldict['institution_amt'] = 100 * (
[13414]377                    gateway_net_amt(self.context.amount_auth)
[13409]378                    - gown_fee_amt
[15190]379                    - aaue_lf_fee_amt
380                    - provider_amt)
[13379]381                xmltext = """<payment_item_detail>
[11868]382<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
383<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]384<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" />
[14945]385<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]386<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]387</item_details>
388</payment_item_detail>""" % xmldict
[13400]389
[13381]390            else:
[13400]391                # Clearance without additional fees
[13381]392                xmldict['institution_amt'] = 100 * (
[15190]393                    gateway_net_amt(self.context.amount_auth)
394                    - provider_amt)
[15168]395                xmltext = """<payment_item_detail>
396<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
397<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" />
398<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" />
399</item_details>
400</payment_item_detail>""" % xmldict
[13379]401
[15168]402
[13403]403        # Union Dues
[13400]404        elif self.context.p_category == 'union':
405            self.pay_item_id = '103'
406            xmldict['institution_amt'] = 100 * (
[13414]407                gateway_net_amt(self.context.amount_auth))
[14980]408            if contr_agreement_student(student) == 'first':
409                # First agreement
410                xmldict['institution_acct'] = '0051005007'
411                xmldict['institution_bank_id'] = '31'
412            else:
413                # Second agreement
414                xmldict['institution_bank_id'] = '7'
415                xmldict['institution_acct'] = '1019763348'
[13379]416
[13403]417        # Lapel/File
[13400]418        elif self.context.p_category == 'lapel':
419            self.pay_item_id = '104'
420            xmldict['institution_amt'] = 100 * (
[13414]421                gateway_net_amt(self.context.amount_auth))
[13381]422
[13403]423        # Welfare Assurance
[13400]424        elif self.context.p_category == 'welfare':
425            self.pay_item_id = '105'
[14979]426            xmldict['institution_acct'] = '1006407792'
427            xmldict['institution_bank_id'] = '123'
[13400]428            xmldict['institution_amt'] = 100 * (
[13414]429                gateway_net_amt(self.context.amount_auth))
[13381]430
[14234]431        # ID Card
432        elif self.context.p_category == 'id_card':
433            self.pay_item_id = '000'
434            xmldict['institution_amt'] = 100 * (
435                gateway_net_amt(self.context.amount_auth))
436
[13400]437        # Matric Gown
438        elif self.context.p_category == 'matric_gown':
439            self.pay_item_id = '106'
440            xmldict['institution_amt'] = 100 * (
[13414]441                gateway_net_amt(self.context.amount_auth))
[13381]442
[13400]443        # Concessional
444        elif self.context.p_category == 'concessional':
445            self.pay_item_id = '107'
446            xmldict['institution_amt'] = 100 * (
[13414]447                gateway_net_amt(self.context.amount_auth))
[13381]448
[13400]449        # Hostel Maintenance
450        elif self.context.p_category == 'hostel_maintenance':
[14223]451            provider_amt = 500.0
[13400]452            self.pay_item_id = '109'
[14223]453            xmldict['provider_amt'] = 100 * provider_amt
[13400]454            xmldict['institution_amt'] = 100 * (
[14223]455                gateway_net_amt(self.context.amount_auth) - provider_amt)
[13400]456            xmltext = """<payment_item_detail>
[13383]457<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
458<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]459<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]460</item_details>
461</payment_item_detail>""" % xmldict
462
[14258]463        # GST Fees
464        elif self.context.p_category.startswith('gst_'):
[14687]465            if contr_agreement_student(student) == 'first':
466                self.pay_item_id = '115'
467            else:
468                self.pay_item_id = '116'
[14979]469            xmldict['institution_acct'] = '1010893123'
470            xmldict['institution_bank_id'] = '117'
[14258]471            xmldict['institution_amt'] = 100 * (
472                gateway_net_amt(self.context.amount_auth))
473
474        # ENT Fees
475        elif self.context.p_category.startswith('ent_'):
[14687]476            if contr_agreement_student(student) == 'first':
477                self.pay_item_id = '114'
478            else:
479                self.pay_item_id = '118'
[14979]480            xmldict['institution_acct'] = '6220029828'
481            xmldict['institution_bank_id'] = '51'
[14258]482            xmldict['institution_amt'] = 100 * (
483                gateway_net_amt(self.context.amount_auth))
484
485        # Faculty and Departmental Dues
486        elif self.context.p_category == 'fac_dep':
487            self.pay_item_id = '117'
488            xmldict['institution_amt'] = 100 * (
489                gateway_net_amt(self.context.amount_auth))
490
[14376]491        # Restitution Fee
492        elif self.context.p_category == 'restitution':
493            self.pay_item_id = '117'
494            xmldict['institution_amt'] = 100 * (
495                gateway_net_amt(self.context.amount_auth))
496
[14676]497        # Late Registration Fee
498        elif self.context.p_category == 'late_registration':
[14686]499            if contr_agreement_student(student) == 'first':
500                self.pay_item_id = '113'
501            else:
502                self.pay_item_id = '123'
[14676]503            xmldict['institution_amt'] = 100 * (
504                gateway_net_amt(self.context.amount_auth))
[14945]505
506        if not xmltext:
[14676]507            xmltext = """<payment_item_detail>
508<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
509<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" />
510</item_details>
511</payment_item_detail>""" % xmldict
[11868]512        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
513        self.context.provider_amt = provider_amt
[13437]514        self.context.gateway_amt = self.amount_auth - gateway_net_amt(
515            self.amount_auth)
[11868]516        hashargs = (
517            self.context.p_id +
[13382]518            self.product_id +
[11868]519            self.pay_item_id +
520            str(int(self.amount_auth)) +
521            self.site_redirect_url +
522            self.mac)
523        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
524        return
525
526
[11846]527class CustomInterswitchPaymentRequestWebservicePageApplicant(
528    InterswitchPaymentRequestWebservicePageApplicant):
[13586]529    """Request webservice view for the CollegePAY gateway
530    """
531    grok.context(ICustomApplicantOnlinePayment)
532    gateway_host = HOST
533    gateway_url = URL
534    https = HTTPS
[13379]535
[13586]536    @property
[13606]537    def mac(self):
538        if contr_agreement_applicant(self.context.__parent__) == 'first':
539            return MAC_PT
540        return MAC_REGULAR
541
542    @property
[13586]543    def product_id(self):
544        if contr_agreement_applicant(self.context.__parent__) == 'first':
545            return PRODUCT_ID_PT
546        return PRODUCT_ID_REGULAR
547
548class CustomInterswitchPaymentVerifyWebservicePageApplicant(
549    InterswitchPaymentVerifyWebservicePageApplicant):
550    """Payment verify view for the CollegePAY gateway
[11846]551    """
552    grok.context(ICustomApplicantOnlinePayment)
553    gateway_host = HOST
[13586]554    gateway_url = URL
[11916]555    https = HTTPS
[11868]556
[13532]557    @property
[13606]558    def mac(self):
559        if contr_agreement_applicant(self.context.__parent__) == 'first':
560            return MAC_PT
561        return MAC_REGULAR
562
563    @property
[13532]564    def product_id(self):
565        if contr_agreement_applicant(self.context.__parent__) == 'first':
566            return PRODUCT_ID_PT
567        return PRODUCT_ID_REGULAR
568
[11868]569class CustomInterswitchPaymentRequestWebservicePageStudent(
570    InterswitchPaymentRequestWebservicePageStudent):
[13586]571    """Request webservice view for the CollegePAY gateway
[11868]572    """
573    grok.context(ICustomStudentOnlinePayment)
574    gateway_host = HOST
[13586]575    gateway_url = URL
[11916]576    https = HTTPS
[13379]577
578    @property
[13606]579    def mac(self):
580        if contr_agreement_student(self.context.student) == 'first':
581            return MAC_PT
582        return MAC_REGULAR
583
584    @property
[13379]585    def product_id(self):
[13532]586        if contr_agreement_student(self.context.student) == 'first':
[13379]587            return PRODUCT_ID_PT
588        return PRODUCT_ID_REGULAR
[13586]589
590class CustomInterswitchPaymentVerifyWebservicePageStudent(
591    InterswitchPaymentVerifyWebservicePageStudent):
592    """Payment verify view for the CollegePAY gateway
593    """
594    grok.context(ICustomStudentOnlinePayment)
595    gateway_host = HOST
596    gateway_url = URL
597    https = HTTPS
598
599    @property
[13606]600    def mac(self):
601        if contr_agreement_student(self.context.student) == 'first':
602            return MAC_PT
603        return MAC_REGULAR
604
605    @property
[13586]606    def product_id(self):
607        if contr_agreement_student(self.context.student) == 'first':
608            return PRODUCT_ID_PT
609        return PRODUCT_ID_REGULAR
Note: See TracBrowser for help on using the repository browser.