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

Last change on this file since 14357 was 14341, checked in by Henrik Bettermann, 8 years ago

Move if statement.

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