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

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

Change provider amount again and adjust tests.

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