source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/browser.py @ 16421

Last change on this file since 16421 was 16421, checked in by Henrik Bettermann, 4 years ago

Add Microsoft Fee to schoolfee.

  • Property svn:keywords set to Id
File size: 39.5 KB
Line 
1## $Id: browser.py 16421 2021-03-22 10:11:09Z 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 waeup.kofa.interfaces import CLEARED, RETURNING
22from kofacustom.nigeria.interswitch.browser import (
23    InterswitchPaymentRequestWebservicePageApplicant,
24    InterswitchPaymentRequestWebservicePageStudent,
25    InterswitchPaymentVerifyWebservicePageApplicant,
26    InterswitchPaymentVerifyWebservicePageStudent,
27    InterswitchPageStudent, InterswitchPageApplicant,
28    )
29from kofacustom.dspg.students.interfaces import ICustomStudentOnlinePayment
30from kofacustom.dspg.applicants.interfaces import ICustomApplicantOnlinePayment
31from kofacustom.dspg.interfaces import MessageFactory as _
32from kofacustom.dspg.students.utils import MICROSOFT_FEE
33
34PRODUCT_ID = '7269' # must be provided by Interswitch
35SITE_NAME = 'dspg.waeup.org'
36PROVIDER_ACCT = '2028964403'
37PROVIDER_BANK_ID = '8'
38PROVIDER_ITEM_NAME = 'WAEAC'
39INSTITUTION_NAME = 'Delta State Polytechnic Ogwashi-Uku'
40CURRENCY = '566'
41GATEWAY_AMT = 250.0
42MAC = 'D43ED93B7A307B152C7111D04E1F384428057CD1E75428D3A4C5631C28ACB9C8C822A88CA76DEDC5F9A520CF4BFDB2824FF8B207AAFC667DF3CBB13685B66627'
43
44POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
45#POST_ACTION = 'https://sandbox.interswitchng.com/webpay/pay'
46HOST = 'webpay.interswitchng.com'
47#HOST = 'sandbox.interswitchng.com'
48URL = '/paydirect/api/v1/gettransaction.json'
49#URL = '/webpay/api/v1/gettransaction.json'
50
51httplib.HTTPSConnection.debuglevel = 0
52HTTPS = True
53
54SPECIAL_PAYMENT_PARAMS = {
55
56    'carryover1': ('101', 500.0, '1015220292', '117'),
57    'carryover4': ('101', 500.0, '1015220292', '117'),
58    'carryover5': ('101', 500.0, '1015220292', '117'),
59    'carryover6': ('101', 500.0, '1015220292', '117'),
60    'carryover7': ('101', 500.0, '1015220292', '117'),
61    'carryover8': ('101', 500.0, '1015220292', '117'),
62    'carryover9': ('101', 500.0, '1015220292', '117'),
63    'carryover10': ('101', 500.0, '1015220292', '117'),
64    'carryover11': ('101', 500.0, '1015220292', '117'),
65    'carryover12': ('101', 500.0, '1015220292', '117'),
66    'balance': ('101', 500.0, '1015220292', '117'),
67
68    'certificate': ('111', 500.0, '1012808851', '117'),
69    'state_result': ('112', 500.0, '1012808851', '117'),
70    'transcript_local': ('113', 500.0, '1012808851', '117'),
71    'transcript_foreign': ('114', 500.0, '1012808851', '117'),
72    'ver_result': ('115', 500.0, '1012808851', '117'),
73    'change_course': ('116', 500.0, '1012808851', '117'),
74    'change_inst': ('117', 500.0, '1012808851', '117'),
75    'jamb_reject': ('118', 500.0, '1012808851', '117'),
76    'cert_of_cert': ('119', 500.0, '1012808851', '117'),
77    'ref_let': ('120', 500.0, '1012808851', '117'),
78    'proc_cert': ('121', 500.0, '1012808851', '117'),
79    'loss_idcard': ('122', 9.0, '1012808851', '117'),
80    'loss_examcard': ('123', 4.5, '1012808851', '117'),
81    'loss_result': ('124', 500.0, '1012808851', '117'),
82    'loss_receipt': ('125', 500.0, '1012808851', '117'),
83    'loss_clearance': ('126', 500.0, '1012808851', '117'),
84    'conv_brochure': ('127', 500.0, '1012808851', '117'),
85    'hnd_certificate': ('128', 500.0, '1012808851', '117'),
86    'hnd_state_result': ('129', 500.0, '1012808851', '117'),
87    'hnd_transcript_local': ('130', 500.0, '1012808851', '117'),
88    'hnd_transcript_foreign': ('131', 500.0, '1012808851', '117'),
89    'staff_loss_idcard': ('132', 9.0, '1012808851', '117'),
90    'hnd_conv_brochure': ('133', 500.0, '1012808851', '117'),
91    'pgd_state_result': ('134', 500.0, '1012808851', '117'),
92    'pgd_conv_brochure': ('135', 500.0, '1012808851', '117'),
93    'pgd_certificate': ('136', 500.0, '1012808851', '117'),
94    'log_book': ('137', 4.5, '1012808851', '117'),
95    'pgd_transcript_foreign': ('138', 500.0, '1012808851', '117'),
96    'pgd_transcript_local': ('139', 500.0, '1012808851', '117'),
97    'jamb_regularization': ('140', 500.0, '1012808851', '117'),
98    'utme_registration': ('142', 9.0, '1012808851', '117'),
99    'utme_cbt': ('143', 9.0, '1012808851', '117'),
100    'nysc_id_card': ('144', 9.0, '1012808851', '117'),
101    'ijmb_result': ('147', 500.0, '1012808851', '117'),
102    'conv': ('151', 500.0, '1012808851', '117'),
103    }
104
105
106# Not yet readily configured. Bank account numbers are
107# contradictory. pay_item_ids are not yet assigned.
108
109class CustomInterswitchPageStudent(InterswitchPageStudent):
110    """ View which sends a POST request to the Interswitch
111    CollegePAY payment gateway.
112    """
113    grok.context(ICustomStudentOnlinePayment)
114    action = POST_ACTION
115    site_name = SITE_NAME
116    currency = CURRENCY
117    product_id = PRODUCT_ID
118    mac = MAC
119    pay_item_id = '000'
120
121    def update(self):
122        error = self.init_update()
123        if error:
124            self.flash(error, type='danger')
125            self.redirect(self.url(self.context, '@@index'))
126            return
127        self.context.r_company = u'interswitch'
128        student = self.student
129        xmldict = self.xmldict
130        # Provider data
131        xmldict['detail_ref'] = self.context.p_id
132        xmldict['provider_acct'] = PROVIDER_ACCT
133        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
134        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
135        # Institution data
136        xmldict['institution_acct'] = '00000000'
137        xmldict['institution_bank_id'] = '00'
138        xmldict['institution_amt'] = '0.0'
139        provider_amt = 0.0
140        tech_fee = 0.0
141        microsoft_fee = 0.0
142        if self.context.p_category.startswith('schoolfee'):
143            self.pay_item_id = '102'
144            if self.context.p_item != 'Balance':
145                provider_amt = 2800.0
146                tech_fee = 1200.0
147                if student.state == RETURNING:
148                    microsoft_fee = MICROSOFT_FEE
149            if student.faccode == 'SPAT':
150                xmldict['institution_acct'] = '1015220292'
151                xmldict['institution_bank_id'] = '117'
152            elif student.current_mode in ('nd_ft', 'hnd_ft'):
153                xmldict['institution_acct'] = '2004145840'
154                xmldict['institution_bank_id'] = '8'
155        elif self.context.p_category == 'clearance':
156            self.pay_item_id = '103'
157            if self.context.p_item != 'Balance':
158                provider_amt = 500.0
159            if student.faccode == 'SPAT':
160                xmldict['institution_acct'] = '1015220292'
161                xmldict['institution_bank_id'] = '117'
162            elif student.current_mode in ('nd_ft', 'hnd_ft'):
163                xmldict['institution_acct'] = '0072223654'
164                xmldict['institution_bank_id'] = '121'
165        elif self.context.p_category == 'gown':
166            self.pay_item_id = '102' # We use school fee item id.
167            xmldict['institution_acct'] = '2006612782'
168            xmldict['institution_bank_id'] = '8'
169        elif self.context.p_category == 'sports':
170            self.pay_item_id = '110'
171            xmldict['institution_acct'] = '6060300688'
172            xmldict['institution_bank_id'] = '51'
173        elif self.context.p_category == 'siwes':
174            self.pay_item_id = '111'
175            xmldict['institution_acct'] = '0080527351'
176            xmldict['institution_bank_id'] = '11'
177        elif self.context.p_category == 'eed_1':
178            self.pay_item_id = '112'
179            xmldict['institution_acct'] = '0039782431'
180            xmldict['institution_bank_id'] = '11'
181        elif self.context.p_category == 'eed_2':
182            self.pay_item_id = '116'
183            xmldict['institution_acct'] = '0039782431'
184            xmldict['institution_bank_id'] = '11'
185        elif self.context.p_category == 'eed_extra':
186            self.pay_item_id = '157'
187            xmldict['institution_acct'] = '0039782431'
188            xmldict['institution_bank_id'] = '11'
189        elif self.context.p_category == 'olevel_results_1':
190            self.pay_item_id = '113'
191            xmldict['institution_acct'] = '2015327204'
192            xmldict['institution_bank_id'] = '8'
193        elif self.context.p_category == 'olevel_results_2':
194            self.pay_item_id = '115'
195            xmldict['institution_acct'] = '2015327204'
196            xmldict['institution_bank_id'] = '8'
197        elif self.context.p_category == 'gns_1':
198            self.pay_item_id = '154'
199            xmldict['institution_acct'] = '2017447652'
200            xmldict['institution_bank_id'] = '8'
201        elif self.context.p_category == 'gns_2':
202            self.pay_item_id = '155'
203            xmldict['institution_acct'] = '2017447652'
204            xmldict['institution_bank_id'] = '8'
205        elif self.context.p_category == 'hostel_maintenance':
206            if self.context.p_item != 'Balance':
207                provider_amt = 500.0
208            self.pay_item_id = '117'
209            xmldict['institution_acct'] = '1012808851'
210            xmldict['institution_bank_id'] = '117'
211        elif self.context.p_category == 'lsfp_penalty':
212            self.pay_item_id = '102'
213            xmldict['institution_acct'] = '1012808851'
214            xmldict['institution_bank_id'] = '117'
215        elif self.context.p_category == 'eng_1':
216            self.pay_item_id = '118'
217            xmldict['institution_acct'] = '2024473077'
218            xmldict['institution_bank_id'] = '8'
219        elif self.context.p_category == 'eng_2':
220            self.pay_item_id = '119'
221            xmldict['institution_acct'] = '2024473077'
222            xmldict['institution_bank_id'] = '8'
223        elif self.context.p_category == 'bfn':
224            self.pay_item_id = '125'
225            xmldict['institution_acct'] = '0048039049'
226            xmldict['institution_bank_id'] = '11'
227        elif self.context.p_category == 'facilities':
228            self.pay_item_id = '156'
229            xmldict['institution_acct'] = '1012808851'
230            xmldict['institution_bank_id'] = '117'
231        elif self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys():
232            self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0]
233            provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1]
234            xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2]
235            xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3]
236        xmldict['provider_amt'] = 100 * provider_amt
237        xmldict['tech_fee'] = 100 * tech_fee
238        xmldict['institution_item_name'] = self.context.category
239        xmldict['institution_name'] = INSTITUTION_NAME
240        xmldict['institution_amt'] = institution_amt = 100 * (
241            self.context.amount_auth - provider_amt - tech_fee - GATEWAY_AMT)
242
243        if provider_amt == 0:
244            xmltext = """<payment_item_detail>
245<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
246<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" />
247</item_details>
248</payment_item_detail>""" % xmldict
249        elif tech_fee == 0:
250            xmltext = """<payment_item_detail>
251<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
252<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" />
253<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" />
254</item_details>
255</payment_item_detail>""" % xmldict
256        elif microsoft_fee == 0:
257            xmltext = """<payment_item_detail>
258<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
259<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" />
260<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" />
261<item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
262</item_details>
263</payment_item_detail>""" % xmldict
264        else:
265            xmltext = """<payment_item_detail>
266<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
267<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" />
268<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" />
269<item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
270<item_detail item_id="4" item_name="Microsoft Academy Fee" item_amt="%(microsoft_fee)d" bank_id="8" acct_num="2011810360" />
271</item_details>
272</payment_item_detail>""" % xmldict
273
274        # isouaba: All certificates in SPAT are part time thus any payments
275        # coming from those certificates (Application, Acceptance, school fees
276        # etc) 40% should be split to keystone account.
277        # abraham: Please, kindly exclude the 40% going to Keystone bank for school of part-
278        # time (SPAT) O'level Results Verification payment.
279        if student.faccode == 'SPAT' and not self.context.p_category.startswith('olevel_results'):
280            xmldict['institution_amt_2'] = 0.4 * institution_amt
281            xmldict['institution_amt_1'] = 0.6 * institution_amt
282            if provider_amt == 0:
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 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
286<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
287</item_details>
288</payment_item_detail>""" % xmldict
289            elif tech_fee == 0:
290                xmltext = """<payment_item_detail>
291<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
292<item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
293<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
294<item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
295</item_details>
296</payment_item_detail>""" % xmldict
297            else:
298                xmltext = """<payment_item_detail>
299<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
300<item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
301<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
302<item_detail item_id="3" 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="4" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
304</item_details>
305</payment_item_detail>""" % xmldict
306
307
308        # Some payments are treated completely separately. The following lines
309        # override the configuration above.
310
311        if self.context.p_category == 'dep_sug':
312            self.pay_item_id = '102' # We use school fee item id
313            # amount_auth is being ignored. However, the sum of all split payments
314            # must coincide with the amount_auth configured in students/utils.py
315            xmldict['amt1'] = 100 * 1000
316            xmldict['amt2'] = 100 * 500
317            xmldict['amt3'] = 100 * 900
318            xmldict['amt4'] = 100 * 500
319
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="SUG" item_amt="%(amt1)d" bank_id="11" acct_num="0038079930" />
323<item_detail item_id="2" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" />
324<item_detail item_id="3" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" />
325<item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
326</item_details>
327</payment_item_detail>""" % xmldict
328
329        if self.context.p_category == 'sbs_1':
330            self.pay_item_id = '120'
331            # amount_auth is being ignored. However, the sum of all split payments
332            # must coincide with the amount_auth configured in students/utils.py
333            xmldict['amt1'] = 100 * 800
334            xmldict['amt2'] = 100 * 1000
335            xmldict['amt3'] = 100 * 500
336
337            xmltext = """<payment_item_detail>
338<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
339<item_detail item_id="1" item_name="SBS Dues I" item_amt="%(amt1)d" bank_id="11" acct_num="0010772626" />
340<item_detail item_id="2" item_name="Journal fee" item_amt="%(amt2)d" bank_id="11" acct_num="0010772626" />
341<item_detail item_id="3" item_name="ABSOBS" item_amt="%(amt3)d" bank_id="8" acct_num="2008185712" />
342</item_details>
343</payment_item_detail>""" % xmldict
344
345        if self.context.p_category == 'sbs_2':
346            self.pay_item_id = '123'
347            # amount_auth is being ignored. However, the sum of all split payments
348            # must coincide with the amount_auth configured in students/utils.py
349            xmldict['amt1'] = 100 * 300
350            xmldict['amt2'] = 100 * 500
351            xmltext = """<payment_item_detail>
352<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
353<item_detail item_id="1" item_name="SBS Dues II" item_amt="%(amt1)d" bank_id="11" acct_num="0010772626" />
354<item_detail item_id="2" item_name="ABSOBS" item_amt="%(amt2)d" bank_id="8" acct_num="2008185712" />
355</item_details>
356</payment_item_detail>""" % xmldict
357
358        if self.context.p_category == 'mkt':
359            self.pay_item_id = '127'
360            # amount_auth is being ignored. However, the sum of all split payments
361            # must coincide with the amount_auth configured in students/utils.py
362            xmldict['amt1'] = 100 * 500
363            xmldict['amt2'] = 100 * 500
364            xmltext = """<payment_item_detail>
365<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
366<item_detail item_id="1" item_name="MKT Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0048297823" />
367<item_detail item_id="2" item_name="NAMS" item_amt="%(amt2)d" bank_id="8" acct_num="2032309812" />
368</item_details>
369</payment_item_detail>""" % xmldict
370
371        if self.context.p_category == 'mcn':
372            self.pay_item_id = '129'
373            # amount_auth is being ignored. However, the sum of all split payments
374            # must coincide with the amount_auth configured in students/utils.py
375            xmldict['amt1'] = 100 * 500
376            xmldict['amt2'] = 100 * 500
377            xmltext = """<payment_item_detail>
378<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
379<item_detail item_id="1" item_name="MCN Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0010789213" />
380<item_detail item_id="2" item_name="AMCOS" item_amt="%(amt2)d" bank_id="8" acct_num="3020253234" />
381</item_details>
382</payment_item_detail>""" % xmldict
383
384        if self.context.p_category == 'otm':
385            self.pay_item_id = '131'
386            # amount_auth is being ignored. However, the sum of all split payments
387            # must coincide with the amount_auth configured in students/utils.py
388            xmldict['amt1'] = 100 * 500
389            xmldict['amt2'] = 100 * 500
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="OTM Dues" item_amt="%(amt1)d" bank_id="8" acct_num="3068446702" />
393<item_detail item_id="2" item_name="NAOTM" item_amt="%(amt2)d" bank_id="11" acct_num="0036652027" />
394</item_details>
395</payment_item_detail>""" % xmldict
396
397        if self.context.p_category == 'acct':
398            self.pay_item_id = '134'
399            # amount_auth is being ignored. However, the sum of all split payments
400            # must coincide with the amount_auth configured in students/utils.py
401            xmldict['amt1'] = 100 * 3000
402            xmldict['amt2'] = 100 * 500
403            xmldict['amt3'] = 100 * 500
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="Profession Accreditation" item_amt="%(amt1)d" bank_id="11" acct_num="0040285084" />
407<item_detail item_id="2" item_name="ACCT Dues" item_amt="%(amt2)d" bank_id="11" acct_num="0036184955" />
408<item_detail item_id="3" item_name="NAPAS" item_amt="%(amt3)d" bank_id="8" acct_num="2008498661" />
409</item_details>
410</payment_item_detail>""" % xmldict
411
412        if self.context.p_category == 'bam':
413            self.pay_item_id = '136'
414            # amount_auth is being ignored. However, the sum of all split payments
415            # must coincide with the amount_auth configured in students/utils.py
416            xmldict['amt1'] = 100 * 500
417            xmldict['amt2'] = 100 * 500
418            xmltext = """<payment_item_detail>
419<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
420<item_detail item_id="1" item_name="BAM Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0010788058" />
421<item_detail item_id="2" item_name="NABAS" item_amt="%(amt2)d" bank_id="8" acct_num="2006936848" />
422</item_details>
423</payment_item_detail>""" % xmldict
424
425        if self.context.p_category == 'pom':
426            self.pay_item_id = '138'
427            # amount_auth is being ignored. However, the sum of all split payments
428            # must coincide with the amount_auth configured in students/utils.py
429            xmldict['amt1'] = 100 * 500
430            xmldict['amt2'] = 100 * 500
431            xmltext = """<payment_item_detail>
432<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
433<item_detail item_id="1" item_name="POM Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0096851444" />
434<item_detail item_id="2" item_name="NAMS" item_amt="%(amt2)d" bank_id="8" acct_num="2033423003" />
435</item_details>
436</payment_item_detail>""" % xmldict
437
438        if self.context.p_category == 'hrm':
439            self.pay_item_id = '140'
440            # amount_auth is being ignored. However, the sum of all split payments
441            # must coincide with the amount_auth configured in students/utils.py
442            xmldict['amt1'] = 100 * 500
443            xmldict['amt2'] = 100 * 500
444            xmltext = """<payment_item_detail>
445<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
446<item_detail item_id="1" item_name="HRM Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0096858546" />
447<item_detail item_id="2" item_name="NAMS" item_amt="%(amt2)d" bank_id="8" acct_num="2033423003" />
448</item_details>
449</payment_item_detail>""" % xmldict
450
451        if self.context.p_category == 'ndgrad':
452            self.pay_item_id = '152'
453            # amount_auth is being ignored. However, the sum of all split payments
454            # must coincide with the amount_auth configured in students/utils.py
455            xmldict['amt1'] = 100 * 3000
456            xmldict['amt2'] = 100 * 5000
457            xmldict['amt3'] = 100 * 1000
458            xmldict['amt4'] = 100 * 3500
459            xmltext = """<payment_item_detail>
460<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
461<item_detail item_id="1" item_name="Collection of Results" item_amt="%(amt1)d" bank_id="117" acct_num="1012808851" />
462<item_detail item_id="2" item_name="Collection of Certificate" item_amt="%(amt2)d" bank_id="117" acct_num="1012808851" />
463<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
464<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
465</item_details>
466</payment_item_detail>""" % xmldict
467
468        if self.context.p_category == 'hndgrad':
469            self.pay_item_id = '153'
470            # amount_auth is being ignored. However, the sum of all split payments
471            # must coincide with the amount_auth configured in students/utils.py
472            xmldict['amt1'] = 100 * 5000
473            xmldict['amt2'] = 100 * 7500
474            xmldict['amt3'] = 100 * 1000
475            xmldict['amt4'] = 100 * 3500
476            xmltext = """<payment_item_detail>
477<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
478<item_detail item_id="1" item_name="Collection of Results" item_amt="%(amt1)d" bank_id="117" acct_num="1012808851" />
479<item_detail item_id="2" item_name="Collection of Certificate" item_amt="%(amt2)d" bank_id="117" acct_num="1012808851" />
480<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
481<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
482</item_details>
483</payment_item_detail>""" % xmldict
484
485        if self.context.p_category == 'sas_1':
486            self.pay_item_id = '158'
487            # amount_auth is being ignored. However, the sum of all split payments
488            # must coincide with the amount_auth configured in students/utils.py
489            xmldict['amt1'] = 100 * 500
490            xmldict['amt2'] = 100 * 500
491            xmldict['amt3'] = 100 * 500
492            xmltext = """<payment_item_detail>
493<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
494<item_detail item_id="1" item_name="SAS Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0038956822" />
495<item_detail item_id="2" item_name="Handbook Fee" item_amt="%(amt2)d" bank_id="11" acct_num="0010772626" />
496<item_detail item_id="3" item_name="Association Due" item_amt="%(amt3)d" bank_id="8" acct_num="3069091989" />
497</item_details>
498</payment_item_detail>""" % xmldict
499
500        if self.context.p_category == 'sas_2':
501            self.pay_item_id = '159'
502            # amount_auth is being ignored. However, the sum of all split payments
503            # must coincide with the amount_auth configured in students/utils.py
504            xmldict['amt1'] = 100 * 500
505            xmldict['amt2'] = 100 * 500
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="SAS Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0038956822" />
509<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="8" acct_num="3069091989" />
510</item_details>
511</payment_item_detail>""" % xmldict
512
513        if self.context.p_category == 'com':
514            self.pay_item_id = '160'
515            # amount_auth is being ignored. However, the sum of all split payments
516            # must coincide with the amount_auth configured in students/utils.py
517            xmldict['amt1'] = 100 * 500
518            xmldict['amt2'] = 100 * 500
519            xmltext = """<payment_item_detail>
520<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
521<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="11" acct_num="0010787594" />
522<item_detail item_id="2" item_name="NACOS " item_amt="%(amt2)d" bank_id="8" acct_num="3047146881" />
523</item_details>
524</payment_item_detail>""" % xmldict
525
526        if self.context.p_category == 'sta':
527            self.pay_item_id = '161'
528            # amount_auth is being ignored. However, the sum of all split payments
529            # must coincide with the amount_auth configured in students/utils.py
530            xmldict['amt1'] = 100 * 500
531            xmldict['amt2'] = 100 * 500
532            xmltext = """<payment_item_detail>
533<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
534<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="11" acct_num="0048794281" />
535<item_detail item_id="2" item_name="NASS " item_amt="%(amt2)d" bank_id="8" acct_num="203000173" />
536</item_details>
537</payment_item_detail>""" % xmldict
538
539        if self.context.p_category == 'slt_1':
540            self.pay_item_id = '162'
541            # amount_auth is being ignored. However, the sum of all split payments
542            # must coincide with the amount_auth configured in students/utils.py
543            xmldict['amt1'] = 100 * 500
544            xmldict['amt2'] = 100 * 500
545            xmldict['amt3'] = 100 * 3000
546            xmldict['amt4'] = 100 * 500
547            xmldict['amt5'] = 100 * 3000
548            xmldict['amt6'] = 100 * 2000
549            xmltext = """<payment_item_detail>
550<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
551<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="8" acct_num="2033492885" />
552<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="11" acct_num="0115800071" />
553<item_detail item_id="3" item_name="Professional Due" item_amt="%(amt3)d" bank_id="8" acct_num="2033492885" />
554<item_detail item_id="4" item_name="Prospectus" item_amt="%(amt4)d" bank_id="8" acct_num="2033492885" />
555<item_detail item_id="5" item_name="Practical Manual" item_amt="%(amt4)d" bank_id="8" acct_num="2033492885" />
556<item_detail item_id="6" item_name="Lab. Coat" item_amt="%(amt4)d" bank_id="8" acct_num="2033492885" />
557</item_details>
558</payment_item_detail>""" % xmldict
559
560        if self.context.p_category == 'slt_2':
561            self.pay_item_id = '163'
562            # amount_auth is being ignored. However, the sum of all split payments
563            # must coincide with the amount_auth configured in students/utils.py
564            xmldict['amt1'] = 100 * 500
565            xmldict['amt2'] = 100 * 500
566            xmldict['amt3'] = 100 * 3000
567            xmltext = """<payment_item_detail>
568<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
569<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="8" acct_num="2033492885" />
570<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="11" acct_num="0115800071" />
571<item_detail item_id="3" item_name="Practical Manual" item_amt="%(amt3)d" bank_id="8" acct_num="2033492885" />
572</item_details>
573</payment_item_detail>""" % xmldict
574
575        if self.context.p_category == 'lis':
576            self.pay_item_id = '164'
577            # amount_auth is being ignored. However, the sum of all split payments
578            # must coincide with the amount_auth configured in students/utils.py
579            xmldict['amt1'] = 100 * 500
580            xmldict['amt2'] = 100 * 500
581            xmltext = """<payment_item_detail>
582<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
583<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="" acct_num="0068264131" />
584<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="" acct_num="" />
585</item_details>
586</payment_item_detail>""" % xmldict
587
588        if self.context.p_category == 'htm':
589            self.pay_item_id = '165'
590            # amount_auth is being ignored. However, the sum of all split payments
591            # must coincide with the amount_auth configured in students/utils.py
592            xmldict['amt1'] = 100 * 500
593            xmldict['amt2'] = 100 * 500
594            xmltext = """<payment_item_detail>
595<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
596<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="" acct_num="0068264131" />
597<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="" acct_num="" />
598</item_details>
599</payment_item_detail>""" % xmldict
600
601
602        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
603        self.context.provider_amt = provider_amt
604        self.context.gateway_amt = GATEWAY_AMT
605        self.amount_auth = int(100 * self.context.amount_auth)
606        hashargs = (
607            self.context.p_id +
608            PRODUCT_ID +
609            self.pay_item_id +
610            str(int(self.amount_auth)) +
611            self.site_redirect_url +
612            self.mac)
613        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
614        return
615
616class CustomInterswitchPageApplicant(InterswitchPageApplicant):
617    """ View which sends a POST request to the Interswitch
618    CollegePAY payment gateway.
619    """
620    grok.context(ICustomApplicantOnlinePayment)
621    action = POST_ACTION
622    site_name = SITE_NAME
623    currency = CURRENCY
624    pay_item_id = '101' # must be provided by Interswitch
625    product_id = PRODUCT_ID
626    mac = MAC
627
628    def update(self):
629        error = self.init_update()
630        if error:
631            self.flash(error, type='danger')
632            self.redirect(self.url(self.context, '@@index'))
633            return
634        self.context.r_company = u'interswitch'
635        xmldict = {}
636        provider_amt = 500.0
637        gateway_amt = GATEWAY_AMT
638        xmldict['institution_acct'] = '00000000'
639        xmldict['institution_bank_id'] = '00'
640        if self.applicant.__parent__.application_category in ('ndft', 'hndft'):
641            xmldict['institution_acct'] = '0072223654'
642            xmldict['institution_bank_id'] = '121'
643        elif self.applicant.__parent__.application_category in (
644            'ndpt', 'hndpt', 'ndwe', 'hndwe'):
645            xmldict['institution_acct'] = '1015220292'
646            xmldict['institution_bank_id'] = '117'
647        elif self.applicant.__parent__.prefix in ('conv', 'hndfincl', 'ndfincl'):
648            xmldict['institution_acct'] = '1012808851'
649            xmldict['institution_bank_id'] = '117'
650            self.pay_item_id = '151'
651        elif self.applicant.applicant_id.startswith('special'):
652            if self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys():
653                self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0]
654                provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1]
655                xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2]
656                xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3]
657        if self.pay_item_id in ('122', '123', '132', '137', '141',
658                                '142', '143', '144', '146', '147',):
659                gateway_amt = round(0.015 * self.context.amount_auth, 2)
660        xmldict['detail_ref'] = self.context.p_id
661        xmldict['provider_amt'] = 100 * provider_amt
662        xmldict['provider_acct'] = PROVIDER_ACCT
663        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
664        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
665        xmldict['institution_amt'] = institution_amt = 100 * (
666            self.context.amount_auth - provider_amt - gateway_amt)
667        xmldict['institution_item_name'] = self.context.category
668        xmldict['institution_name'] = INSTITUTION_NAME
669        xmltext = """<payment_item_detail>
670<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
671<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" />
672<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" />
673</item_details>
674</payment_item_detail>""" % xmldict
675
676        # isouaba: All certificates in SPAT are part time thus any payments
677        # coming from those certificates (Application, Acceptance, school fees
678        # etc) 40% should be split to keystone account.
679        if self.applicant.__parent__.application_category in (
680            'ndpt', 'hndpt', 'ndwe', 'hndwe'):
681            xmldict['institution_amt_2'] = 0.4 * institution_amt
682            xmldict['institution_amt_1'] = 0.6 * institution_amt
683            xmltext = """<payment_item_detail>
684<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
685<item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
686<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
687<item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
688</item_details>
689</payment_item_detail>""" % xmldict
690
691        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
692        self.context.provider_amt = provider_amt
693        self.context.gateway_amt = GATEWAY_AMT
694        self.amount_auth = int(100 * self.context.amount_auth)
695        hashargs = (
696            self.context.p_id +
697            PRODUCT_ID +
698            self.pay_item_id +
699            str(int(self.amount_auth)) +
700            self.site_redirect_url +
701            self.mac)
702        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
703        return
704
705class CustomInterswitchPaymentRequestWebservicePageStudent(
706    InterswitchPaymentRequestWebservicePageStudent):
707    """Request webservice view for the CollegePAY gateway
708    """
709    grok.context(ICustomStudentOnlinePayment)
710    product_id = PRODUCT_ID
711    gateway_host = HOST
712    gateway_url = URL
713    mac = MAC
714
715class CustomInterswitchPaymentVerifyWebservicePageStudent(
716    InterswitchPaymentVerifyWebservicePageStudent):
717    """Payment verify view for the CollegePAY gateway
718    """
719    grok.context(ICustomStudentOnlinePayment)
720    product_id = PRODUCT_ID
721    gateway_host = HOST
722    gateway_url = URL
723    mac = MAC
724
725class CustomInterswitchPaymentRequestWebservicePageApplicant(
726    InterswitchPaymentRequestWebservicePageApplicant):
727    """Request webservice view for the CollegePAY gateway
728    """
729    grok.context(ICustomApplicantOnlinePayment)
730    product_id = PRODUCT_ID
731    gateway_host = HOST
732    gateway_url = URL
733    mac = MAC
734
735class CustomInterswitchPaymentVerifyWebservicePageApplicant(
736    InterswitchPaymentVerifyWebservicePageApplicant):
737    """Payment verify view for the CollegePAY gateway
738    """
739    grok.context(ICustomApplicantOnlinePayment)
740    product_id = PRODUCT_ID
741    gateway_host = HOST
742    gateway_url = URL
743    mac = MAC
Note: See TracBrowser for help on using the repository browser.