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

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

Deduct provider amount.

  • Property svn:keywords set to Id
File size: 26.4 KB
Line 
1## $Id: browser.py 15190 2018-10-15 14:00:33Z henrik $
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
23from waeup.kofa.interfaces import CLEARED
24from kofacustom.nigeria.interswitch.browser import (
25    InterswitchPaymentRequestWebservicePageStudent,
26    InterswitchPaymentRequestWebservicePageApplicant,
27    InterswitchPaymentVerifyWebservicePageApplicant,
28    InterswitchPaymentVerifyWebservicePageStudent,
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
35PRODUCT_ID_PT = '5040'
36PRODUCT_ID_REGULAR = '5845'
37SITE_NAME = 'aaue.waeup.org'
38PROVIDER_ACCT = '1014261520'
39PROVIDER_BANK_ID = '117'
40PROVIDER_ITEM_NAME = 'WAeAC'
41INSTITUTION_NAME = 'AAU Ekpoma'
42CURRENCY = '566'
43GATEWAY_AMT = 250.0
44POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
45
46HOST = 'webpay.interswitchng.com'
47URL = '/paydirect/api/v1/gettransaction.json'
48HTTPS = True
49MAC_REGULAR = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023'
50MAC_PT = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
51
52httplib.HTTPSConnection.debuglevel = 0
53
54
55def gateway_net_amt(fee):
56    if fee > GATEWAY_AMT:
57        return fee - GATEWAY_AMT
58    return 0.0
59
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):
66    if student.current_mode == 'found' or student.current_mode.endswith('_pt'):
67        return 'first'
68    return 'second'
69
70class CustomInterswitchPageApplicant(InterswitchPageApplicant):
71    """ View which sends a POST request to the Interswitch
72    CollegePAY payment gateway.
73
74    So far only PT application has been configured.
75    """
76    grok.context(ICustomApplicantOnlinePayment)
77    action = POST_ACTION
78    site_name = SITE_NAME
79    currency = CURRENCY
80    provider_bank_id = PROVIDER_BANK_ID
81    provider_acct = PROVIDER_ACCT
82
83    def update(self):
84
85        error = self.init_update()
86        if error:
87            self.flash(error, type='danger')
88            self.redirect(self.url(self.context, '@@index'))
89            return
90        if contr_agreement_applicant(self.context.__parent__) == 'first':
91            self.product_id = PRODUCT_ID_PT
92            self.pay_item_id = '101'
93            self.mac = MAC_PT
94            provider_amt = 4000.0
95        else:
96            self.product_id = PRODUCT_ID_REGULAR
97            self.pay_item_id = '109'
98            self.mac = MAC_REGULAR
99            provider_amt = 1000.0
100            if self.applicant.__parent__.prefix in ('trans', 'cert'):
101                provider_amt = 2000.0
102                self.provider_bank_id = '10'
103                self.provider_acct = '0427773399'
104        xmldict = {}
105        xmldict['institution_acct'] = '1010835352'
106        xmldict['institution_bank_id'] = '117'
107        xmldict['detail_ref'] = self.context.p_id
108        xmldict['provider_amt'] = 100 * provider_amt
109        xmldict['provider_acct'] = self.provider_acct
110        xmldict['provider_bank_id'] = self.provider_bank_id
111        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
112        xmldict['institution_item_name'] = self.category
113        xmldict['institution_name'] = INSTITUTION_NAME
114
115        if self.applicant.applicant_id.startswith('pg'):
116            handbook_amount = 2000.0
117            xmldict['handbook_amount'] = 100 * handbook_amount
118            xmldict['institution_amt'] = 100 * (
119                self.context.amount_auth - provider_amt - handbook_amount -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_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1010827641" />
125</item_details>
126</payment_item_detail>""" % xmldict
127
128        elif self.applicant.applicant_id.startswith('utme'):
129            xmldict['provider_amt'] = 100 * provider_amt
130            xmldict['institution_amt'] = 100 * (
131                self.context.amount_auth - provider_amt - 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_details>
137</payment_item_detail>""" % xmldict
138
139        else:
140            xmldict['institution_amt'] = 100 * (
141                self.context.amount_auth - provider_amt - GATEWAY_AMT)
142            xmltext = """<payment_item_detail>
143<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
144<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" />
145<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" />
146</item_details>
147</payment_item_detail>""" % xmldict
148
149        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
150        self.context.provider_amt = provider_amt
151        self.context.gateway_amt = GATEWAY_AMT
152
153        hashargs = (
154            self.context.p_id +
155            self.product_id +
156            self.pay_item_id +
157            str(int(self.amount_auth)) +
158            self.site_redirect_url +
159            self.mac)
160        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
161
162        return
163
164class CustomInterswitchPageStudent(InterswitchPageStudent):
165    """ View which sends a POST request to the Interswitch
166    CollegePAY payment gateway.
167    """
168    grok.context(ICustomStudentOnlinePayment)
169    action = POST_ACTION
170    site_name = SITE_NAME
171    currency = CURRENCY
172    pay_item_id = '000'
173
174    def update(self):
175        error = self.init_update()
176
177        if error:
178            self.flash(error, type='danger')
179            self.redirect(self.url(self.context, '@@index'))
180            return
181
182        student = self.student
183        p_session = self.context.p_session
184        try:
185            academic_session = grok.getSite()['configuration'][str(p_session)]
186        except KeyError:
187            self.flash(_(u'Session configuration object is not available.'),
188                       type='danger')
189            self.redirect(self.url(self.context, '@@index'))
190            return
191        if contr_agreement_student(student) == 'first':
192            self.product_id = PRODUCT_ID_PT
193            self.mac = MAC_PT
194        else:
195            self.product_id = PRODUCT_ID_REGULAR
196            self.mac = MAC_REGULAR
197
198        # To guarantee that cleared students pay both acceptance fee
199        # and school fees, the page can only be accessed
200        # for school fee payments if acceptance/clearance fee has
201        # been successfully queried/paid beforehand. This
202        # requirement applies to students in state 'cleared' and
203        # entry_session greater than 2012 only.
204        if self.context.p_category.startswith('schoolfee') and \
205            student.state == CLEARED and \
206            student.entry_session > 2012:
207            acceptance_fee_paid = False
208            for ticket in student['payments'].values():
209                if ticket.p_state == 'paid' and \
210                    ticket.p_category.startswith('clearance'):
211                    acceptance_fee_paid = True
212                    break
213            if not acceptance_fee_paid:
214                self.flash(
215                    _('Please pay acceptance fee first.'), type="danger")
216                self.redirect(self.url(self.context, '@@index'))
217                return
218
219        xmldict = self.xmldict
220        xmltext = ""
221        xmldict['institution_acct'] = '1010827641'
222        xmldict['institution_bank_id'] = '117'
223        xmldict['detail_ref'] = self.context.p_id
224        xmldict['provider_acct'] = PROVIDER_ACCT
225        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
226        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
227        xmldict['institution_item_name'] = self.category
228        xmldict['institution_name'] = INSTITUTION_NAME
229        provider_amt = 0.0
230
231        # Schoolfee
232        if self.context.p_category.startswith('schoolfee'):
233            if contr_agreement_student(student) == 'first':
234                # First agreement
235                provider_amt = 1900.0
236                joint_venture_amt = 1100.0
237                aaue_share_amt = 1000.0
238                student_union_due_amt = gateway_net_amt(
239                    academic_session.union_fee)
240                student_welfare_assurance_amt = gateway_net_amt(
241                    academic_session.welfare_fee)
242                sports_amt = gateway_net_amt(
243                    academic_session.sports_fee)
244                library_amt = gateway_net_amt(
245                    academic_session.library_fee)
246                library_amt_pg = gateway_net_amt(
247                    academic_session.library_fee_pg)
248                xmldict['student_union_bank_id'] = '31'
249                xmldict['student_union_acct'] = '0051005007'
250                xmldict['aaue_share_bank_id'] = '117'
251                xmldict['aaue_share_acct'] = '1010827641'
252                xmldict['joint_venture_bank_id'] = '117'
253                xmldict['joint_venture_acct'] = '1010827641'
254                if student.current_mode == 'found':
255                    self.pay_item_id = '103'
256                else:
257                    self.pay_item_id = '105'
258            else:
259                # Second agreement
260                provider_amt = 1500.0
261                joint_venture_amt = 1000.0
262                aaue_share_amt = 1500.0
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)
267                sports_amt = gateway_net_amt(
268                    academic_session.sports_fee)
269                library_amt = gateway_net_amt(
270                    academic_session.library_fee)
271                library_amt_pg = gateway_net_amt(
272                    academic_session.library_fee_pg)
273                xmldict['student_union_bank_id'] = '7'
274                xmldict['student_union_acct'] = '1019763348'
275                xmldict['aaue_share_bank_id'] = '117'
276                xmldict['aaue_share_acct'] = '1010827641'
277                xmldict['joint_venture_bank_id'] = '117'
278                xmldict['joint_venture_acct'] = '1010827641'
279                self.pay_item_id = '107'
280                if student.is_postgrad:
281                    self.pay_item_id = '111'
282                if student.current_mode == 'ijmbe':
283                    self.pay_item_id = '119'
284                    xmldict['joint_venture_bank_id'] = '117'
285                    xmldict['joint_venture_acct'] = '1010827641'
286
287            xmldict['provider_amt'] = 100 * provider_amt
288            xmldict['joint_venture_amt'] = 100 * joint_venture_amt
289            xmldict['aaue_share_amt'] = 100 * aaue_share_amt
290            if self.context.p_item == 'Balance':
291                xmldict['institution_amt'] = 100 * (
292                    gateway_net_amt(self.context.amount_auth))
293            elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \
294                and student.current_mode != 'ijmbe':
295                # Schoolfee including additional fees
296                xmldict['student_union_due_amt'] = 100 * student_union_due_amt
297                xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
298                xmldict['sports_amt'] = 100 * sports_amt
299                if student.is_postgrad:
300                    xmldict['library_amt'] = 100 * library_amt_pg
301                else:
302                    xmldict['library_amt'] = 100 * library_amt
303                xmldict['institution_amt'] = 100 * (
304                    gateway_net_amt(self.context.amount_auth)
305                    - provider_amt
306                    - joint_venture_amt
307                    - aaue_share_amt
308                    - student_union_due_amt
309                    - student_welfare_assurance_amt
310                    - sports_amt
311                    - library_amt)
312                xmltext = """<payment_item_detail>
313<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
314<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" />
315<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" />
316<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" />
317<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" />
318<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" />
319<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
320<item_detail item_id="7" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1005407792" />
321<item_detail item_id="8" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />
322</item_details>
323</payment_item_detail>""" % xmldict
324            else:
325                # Schoolfee without additional fees
326                xmldict['institution_amt'] = 100 * (
327                    gateway_net_amt(self.context.amount_auth)
328                    - provider_amt
329                    - joint_venture_amt
330                    - aaue_share_amt)
331                xmltext = """<payment_item_detail>
332<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
333<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" />
334<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" />
335<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" />
336<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" />
337</item_details>
338</payment_item_detail>""" % xmldict
339
340
341        # Clearance
342        elif self.context.p_category.startswith('clearance'):
343            provider_amt = 1500.0
344            xmldict['provider_amt'] = 100 * provider_amt
345            if contr_agreement_student(student) == 'first':
346                # First agreement
347                if student.current_mode == 'found':
348                    self.pay_item_id = '102'
349                else:
350                    self.pay_item_id = '104'
351            else:
352                # Second agreement
353                self.pay_item_id = '102'
354                if student.is_postgrad:
355                    self.pay_item_id = '110'
356                if student.current_mode == 'ijmbe':
357                    self.pay_item_id = '120'
358
359            if self.context.p_category.endswith('_incl'):
360                # Clearance including additional fees
361                gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee)
362                aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee)
363                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
364                xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt
365                xmldict['institution_amt'] = 100 * (
366                    gateway_net_amt(self.context.amount_auth)
367                    - gown_fee_amt
368                    - aaue_lf_fee_amt
369                    - provider_amt)
370                xmltext = """<payment_item_detail>
371<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
372<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" />
373<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" />
374<item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_lf_fee_amt)d" bank_id="117" acct_num="1010827641" />
375<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" />
376</item_details>
377</payment_item_detail>""" % xmldict
378
379            else:
380                # Clearance without additional fees
381                xmldict['institution_amt'] = 100 * (
382                    gateway_net_amt(self.context.amount_auth)
383                    - provider_amt)
384                xmltext = """<payment_item_detail>
385<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
386<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" />
387<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" />
388</item_details>
389</payment_item_detail>""" % xmldict
390
391
392        # Union Dues
393        elif self.context.p_category == 'union':
394            self.pay_item_id = '103'
395            xmldict['institution_amt'] = 100 * (
396                gateway_net_amt(self.context.amount_auth))
397            if contr_agreement_student(student) == 'first':
398                # First agreement
399                xmldict['institution_acct'] = '0051005007'
400                xmldict['institution_bank_id'] = '31'
401            else:
402                # Second agreement
403                xmldict['institution_bank_id'] = '7'
404                xmldict['institution_acct'] = '1019763348'
405
406        # Lapel/File
407        elif self.context.p_category == 'lapel':
408            self.pay_item_id = '104'
409            xmldict['institution_amt'] = 100 * (
410                gateway_net_amt(self.context.amount_auth))
411
412        # Welfare Assurance
413        elif self.context.p_category == 'welfare':
414            self.pay_item_id = '105'
415            xmldict['institution_acct'] = '1006407792'
416            xmldict['institution_bank_id'] = '123'
417            xmldict['institution_amt'] = 100 * (
418                gateway_net_amt(self.context.amount_auth))
419
420        # ID Card
421        elif self.context.p_category == 'id_card':
422            self.pay_item_id = '000'
423            xmldict['institution_amt'] = 100 * (
424                gateway_net_amt(self.context.amount_auth))
425
426        # Matric Gown
427        elif self.context.p_category == 'matric_gown':
428            self.pay_item_id = '106'
429            xmldict['institution_amt'] = 100 * (
430                gateway_net_amt(self.context.amount_auth))
431
432        # Concessional
433        elif self.context.p_category == 'concessional':
434            self.pay_item_id = '107'
435            xmldict['institution_amt'] = 100 * (
436                gateway_net_amt(self.context.amount_auth))
437
438        # Hostel Maintenance
439        elif self.context.p_category == 'hostel_maintenance':
440            provider_amt = 500.0
441            self.pay_item_id = '109'
442            xmldict['provider_amt'] = 100 * provider_amt
443            xmldict['institution_amt'] = 100 * (
444                gateway_net_amt(self.context.amount_auth) - provider_amt)
445            xmltext = """<payment_item_detail>
446<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
447<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" />
448<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" />
449</item_details>
450</payment_item_detail>""" % xmldict
451
452        # GST Fees
453        elif self.context.p_category.startswith('gst_'):
454            if contr_agreement_student(student) == 'first':
455                self.pay_item_id = '115'
456            else:
457                self.pay_item_id = '116'
458            xmldict['institution_acct'] = '1010893123'
459            xmldict['institution_bank_id'] = '117'
460            xmldict['institution_amt'] = 100 * (
461                gateway_net_amt(self.context.amount_auth))
462
463        # ENT Fees
464        elif self.context.p_category.startswith('ent_'):
465            if contr_agreement_student(student) == 'first':
466                self.pay_item_id = '114'
467            else:
468                self.pay_item_id = '118'
469            xmldict['institution_acct'] = '6220029828'
470            xmldict['institution_bank_id'] = '51'
471            xmldict['institution_amt'] = 100 * (
472                gateway_net_amt(self.context.amount_auth))
473
474        # Faculty and Departmental Dues
475        elif self.context.p_category == 'fac_dep':
476            self.pay_item_id = '117'
477            xmldict['institution_amt'] = 100 * (
478                gateway_net_amt(self.context.amount_auth))
479
480        # Restitution Fee
481        elif self.context.p_category == 'restitution':
482            self.pay_item_id = '117'
483            xmldict['institution_amt'] = 100 * (
484                gateway_net_amt(self.context.amount_auth))
485
486        # Late Registration Fee
487        elif self.context.p_category == 'late_registration':
488            if contr_agreement_student(student) == 'first':
489                self.pay_item_id = '113'
490            else:
491                self.pay_item_id = '123'
492            xmldict['institution_amt'] = 100 * (
493                gateway_net_amt(self.context.amount_auth))
494
495        if not xmltext:
496            xmltext = """<payment_item_detail>
497<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
498<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" />
499</item_details>
500</payment_item_detail>""" % xmldict
501        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
502        self.context.provider_amt = provider_amt
503        self.context.gateway_amt = self.amount_auth - gateway_net_amt(
504            self.amount_auth)
505        hashargs = (
506            self.context.p_id +
507            self.product_id +
508            self.pay_item_id +
509            str(int(self.amount_auth)) +
510            self.site_redirect_url +
511            self.mac)
512        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
513        return
514
515
516class CustomInterswitchPaymentRequestWebservicePageApplicant(
517    InterswitchPaymentRequestWebservicePageApplicant):
518    """Request webservice view for the CollegePAY gateway
519    """
520    grok.context(ICustomApplicantOnlinePayment)
521    gateway_host = HOST
522    gateway_url = URL
523    https = HTTPS
524
525    @property
526    def mac(self):
527        if contr_agreement_applicant(self.context.__parent__) == 'first':
528            return MAC_PT
529        return MAC_REGULAR
530
531    @property
532    def product_id(self):
533        if contr_agreement_applicant(self.context.__parent__) == 'first':
534            return PRODUCT_ID_PT
535        return PRODUCT_ID_REGULAR
536
537class CustomInterswitchPaymentVerifyWebservicePageApplicant(
538    InterswitchPaymentVerifyWebservicePageApplicant):
539    """Payment verify view for the CollegePAY gateway
540    """
541    grok.context(ICustomApplicantOnlinePayment)
542    gateway_host = HOST
543    gateway_url = URL
544    https = HTTPS
545
546    @property
547    def mac(self):
548        if contr_agreement_applicant(self.context.__parent__) == 'first':
549            return MAC_PT
550        return MAC_REGULAR
551
552    @property
553    def product_id(self):
554        if contr_agreement_applicant(self.context.__parent__) == 'first':
555            return PRODUCT_ID_PT
556        return PRODUCT_ID_REGULAR
557
558class CustomInterswitchPaymentRequestWebservicePageStudent(
559    InterswitchPaymentRequestWebservicePageStudent):
560    """Request webservice view for the CollegePAY gateway
561    """
562    grok.context(ICustomStudentOnlinePayment)
563    gateway_host = HOST
564    gateway_url = URL
565    https = HTTPS
566
567    @property
568    def mac(self):
569        if contr_agreement_student(self.context.student) == 'first':
570            return MAC_PT
571        return MAC_REGULAR
572
573    @property
574    def product_id(self):
575        if contr_agreement_student(self.context.student) == 'first':
576            return PRODUCT_ID_PT
577        return PRODUCT_ID_REGULAR
578
579class CustomInterswitchPaymentVerifyWebservicePageStudent(
580    InterswitchPaymentVerifyWebservicePageStudent):
581    """Payment verify view for the CollegePAY gateway
582    """
583    grok.context(ICustomStudentOnlinePayment)
584    gateway_host = HOST
585    gateway_url = URL
586    https = HTTPS
587
588    @property
589    def mac(self):
590        if contr_agreement_student(self.context.student) == 'first':
591            return MAC_PT
592        return MAC_REGULAR
593
594    @property
595    def product_id(self):
596        if contr_agreement_student(self.context.student) == 'first':
597            return PRODUCT_ID_PT
598        return PRODUCT_ID_REGULAR
Note: See TracBrowser for help on using the repository browser.