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

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

Change provider bank accoiunt and name.

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