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

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

Change bank account.

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