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
Line 
1## $Id: browser.py 14341 2016-12-14 09:37:16Z 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 = '1010764827'
39PROVIDER_BANK_ID = '117'
40PROVIDER_ITEM_NAME = 'BT Education'
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
81    def update(self):
82
83        error = self.init_update()
84        if error:
85            self.flash(error, type='danger')
86            self.redirect(self.url(self.context, '@@index'))
87            return
88        if contr_agreement_applicant(self.context.__parent__) == 'first':
89            self.product_id = PRODUCT_ID_PT
90            self.pay_item_id = '101'
91            self.mac = MAC_PT
92        else:
93            self.product_id = PRODUCT_ID_REGULAR
94            self.pay_item_id = '109'
95            self.mac = MAC_REGULAR
96        xmldict = {}
97        provider_amt = 2000.0
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
105        xmldict['institution_item_name'] = self.category
106        xmldict['institution_name'] = INSTITUTION_NAME
107
108        if self.applicant.applicant_id.startswith('ijmbe'):
109            xmldict['institution_acct'] = '0772012897'
110            xmldict['institution_bank_id'] = '47'
111
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>
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" />
121<item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1014270207" />
122</item_details>
123</payment_item_detail>""" % xmldict
124
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
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
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 +
156            self.product_id +
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
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
173    pay_item_id = '000'
174
175    def update(self):
176        error = self.init_update()
177
178        ######################################
179        #error = 'Sorry, Interswitch payments are temporarily disabled.'
180        ######################################
181
182        if error:
183            self.flash(error, type='danger')
184            self.redirect(self.url(self.context, '@@index'))
185            return
186
187        student = self.student
188        p_session = self.context.p_session
189        try:
190            academic_session = grok.getSite()['configuration'][str(p_session)]
191        except KeyError:
192            self.flash(_(u'Session configuration object is not available.'),
193                       type='danger')
194            self.redirect(self.url(self.context, '@@index'))
195            return
196        if contr_agreement_student(student) == 'first':
197            self.product_id = PRODUCT_ID_PT
198            self.mac = MAC_PT
199        else:
200            self.product_id = PRODUCT_ID_REGULAR
201            self.mac = MAC_REGULAR
202
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.
209        if self.context.p_category.startswith('schoolfee') and \
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 \
215                    ticket.p_category.startswith('clearance'):
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
224        xmldict = self.xmldict
225        xmltext = ""
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
233        provider_amt = 0.0
234
235        # Schoolfee
236        if self.context.p_category.startswith('schoolfee'):
237            if contr_agreement_student(student) == 'first':
238                # First agreement
239                provider_amt = 1900.0
240                joint_venture_amt = 1100.0
241                aaue_share_amt = 1000.0
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)
246                xmldict['institution_bank_id'] = '7'
247                xmldict['institution_acct'] = '1014847058'
248                xmldict['student_union_bank_id'] = '31'
249                xmldict['student_union_acct'] = '0051005007'
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'
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                xmldict['institution_bank_id'] = '117'
268                xmldict['institution_acct'] = '1010827641'
269                xmldict['student_union_bank_id'] = '7'
270                xmldict['student_union_acct'] = '1019763348'
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'
275                self.pay_item_id = '107'
276                if student.is_postgrad:
277                    xmldict['institution_bank_id'] = '51'
278                    xmldict['institution_acct'] = '5210006575'
279                    self.pay_item_id = '111'
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
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'):
293                # Schoolfee including additional fees
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 * (
297                    gateway_net_amt(self.context.amount_auth)
298                    - provider_amt
299                    - joint_venture_amt
300                    - aaue_share_amt
301                    - student_union_due_amt
302                    - student_welfare_assurance_amt)
303                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" />
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" />
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" />
310<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />
311</item_details>
312</payment_item_detail>""" % xmldict
313            else:
314                # Schoolfee without additional fees
315                xmldict['institution_amt'] = 100 * (
316                    gateway_net_amt(self.context.amount_auth)
317                    - provider_amt
318                    - joint_venture_amt
319                    - aaue_share_amt)
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" />
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" />
326</item_details>
327</payment_item_detail>""" % xmldict
328
329
330        # Clearance
331        elif self.context.p_category.startswith('clearance'):
332            if contr_agreement_student(student) == 'first':
333                # First agreement
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'
340            else:
341                # Second agreement
342                self.pay_item_id = '102'
343                xmldict['institution_acct'] = '1010827641'
344                xmldict['institution_bank_id'] = '117'
345                if student.is_postgrad:
346                    xmldict['institution_bank_id'] = '51'
347                    xmldict['institution_acct'] = '5210006575'
348                    self.pay_item_id = '110'
349
350            if self.context.p_category.endswith('_incl'):
351                # Clearance including additional fees
352                gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee)
353                aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee)
354                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
355                xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt
356                xmldict['institution_amt'] = 100 * (
357                    gateway_net_amt(self.context.amount_auth)
358                    - gown_fee_amt
359                    - aaue_lf_fee_amt)
360                xmltext = """<payment_item_detail>
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" />
363<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="51" acct_num="5060020947" />
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" />
365</item_details>
366</payment_item_detail>""" % xmldict
367
368            else:
369                # Clearance without additional fees
370                xmldict['institution_amt'] = 100 * (
371                    gateway_net_amt(self.context.amount_auth))
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
377
378        # Union Dues
379        elif self.context.p_category == 'union':
380            self.pay_item_id = '103'
381            if contr_agreement_student(student) == 'first':
382                # First agreement
383                xmldict['institution_acct'] = '0051005007'
384                xmldict['institution_bank_id'] = '31'
385            else:
386                # Second agreement
387                xmldict['institution_bank_id'] = '7'
388                xmldict['institution_acct'] = '1019763348'
389            xmldict['institution_amt'] = 100 * (
390                gateway_net_amt(self.context.amount_auth))
391            xmltext = """<payment_item_detail>
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
396
397        # Lapel/File
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 * (
403                gateway_net_amt(self.context.amount_auth))
404            xmltext = """<payment_item_detail>
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
410        # Welfare Assurance
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 * (
416                gateway_net_amt(self.context.amount_auth))
417            xmltext = """<payment_item_detail>
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
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
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 * (
442                gateway_net_amt(self.context.amount_auth))
443            xmltext = """<payment_item_detail>
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
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 * (
455                gateway_net_amt(self.context.amount_auth))
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
461
462        # Hostel Maintenance
463        elif self.context.p_category == 'hostel_maintenance':
464            provider_amt = 500.0
465            self.pay_item_id = '109'
466            xmldict['provider_amt'] = 100 * provider_amt
467            xmldict['institution_acct'] = '1006406795'
468            xmldict['institution_bank_id'] = '123'
469            xmldict['institution_amt'] = 100 * (
470                gateway_net_amt(self.context.amount_auth) - provider_amt)
471            xmltext = """<payment_item_detail>
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" />
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" />
475</item_details>
476</payment_item_detail>""" % xmldict
477
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
517        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
518        self.context.provider_amt = provider_amt
519        self.context.gateway_amt = self.amount_auth - gateway_net_amt(
520            self.amount_auth)
521        hashargs = (
522            self.context.p_id +
523            self.product_id +
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
532class CustomInterswitchPaymentRequestWebservicePageApplicant(
533    InterswitchPaymentRequestWebservicePageApplicant):
534    """Request webservice view for the CollegePAY gateway
535    """
536    grok.context(ICustomApplicantOnlinePayment)
537    gateway_host = HOST
538    gateway_url = URL
539    https = HTTPS
540
541    @property
542    def mac(self):
543        if contr_agreement_applicant(self.context.__parent__) == 'first':
544            return MAC_PT
545        return MAC_REGULAR
546
547    @property
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
556    """
557    grok.context(ICustomApplicantOnlinePayment)
558    gateway_host = HOST
559    gateway_url = URL
560    https = HTTPS
561
562    @property
563    def mac(self):
564        if contr_agreement_applicant(self.context.__parent__) == 'first':
565            return MAC_PT
566        return MAC_REGULAR
567
568    @property
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
574class CustomInterswitchPaymentRequestWebservicePageStudent(
575    InterswitchPaymentRequestWebservicePageStudent):
576    """Request webservice view for the CollegePAY gateway
577    """
578    grok.context(ICustomStudentOnlinePayment)
579    gateway_host = HOST
580    gateway_url = URL
581    https = HTTPS
582
583    @property
584    def mac(self):
585        if contr_agreement_student(self.context.student) == 'first':
586            return MAC_PT
587        return MAC_REGULAR
588
589    @property
590    def product_id(self):
591        if contr_agreement_student(self.context.student) == 'first':
592            return PRODUCT_ID_PT
593        return PRODUCT_ID_REGULAR
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
605    def mac(self):
606        if contr_agreement_student(self.context.student) == 'first':
607            return MAC_PT
608        return MAC_REGULAR
609
610    @property
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.