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

Last change on this file since 14310 was 14268, checked in by Henrik Bettermann, 8 years ago

Change bank account for Student Union Dues second agreement.

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