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

Last change on this file since 15062 was 14987, checked in by Henrik Bettermann, 7 years ago

IJMBE students do not have to pay Student Union Dues + Welfare Assurance Fee.

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