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

Last change on this file since 16690 was 16563, checked in by Henrik Bettermann, 3 years ago

Add PAD Pack.

  • Property svn:keywords set to Id
File size: 39.8 KB
Line 
1## $Id: browser.py 16563 2021-08-03 09:13:52Z 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'] = '1556004203'
151                xmldict['institution_bank_id'] = '388'
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 == 'pa':
232            self.pay_item_id = '166'
233            xmldict['institution_acct'] = '0160125880'
234            xmldict['institution_bank_id'] = '11'
235        elif self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys():
236            self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0]
237            provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1]
238            xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2]
239            xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3]
240        xmldict['provider_amt'] = 100 * provider_amt
241        xmldict['tech_fee'] = 100 * tech_fee
242        xmldict['microsoft_fee'] = 100 * microsoft_fee
243        xmldict['institution_item_name'] = self.context.category
244        xmldict['institution_name'] = INSTITUTION_NAME
245        xmldict['institution_amt'] = institution_amt = 100 * (
246            self.context.amount_auth - provider_amt - tech_fee - microsoft_fee - GATEWAY_AMT)
247
248        if provider_amt == 0:
249            xmltext = """<payment_item_detail>
250<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
251<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" />
252</item_details>
253</payment_item_detail>""" % xmldict
254        elif tech_fee == 0:
255            xmltext = """<payment_item_detail>
256<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
257<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" />
258<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" />
259</item_details>
260</payment_item_detail>""" % xmldict
261        elif microsoft_fee == 0:
262            xmltext = """<payment_item_detail>
263<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
264<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" />
265<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" />
266<item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
267</item_details>
268</payment_item_detail>""" % xmldict
269        else:
270            xmltext = """<payment_item_detail>
271<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
272<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" />
273<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" />
274<item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
275<item_detail item_id="4" item_name="Microsoft Academy Fee" item_amt="%(microsoft_fee)d" bank_id="8" acct_num="2011810360" />
276</item_details>
277</payment_item_detail>""" % xmldict
278
279        # isouaba: All certificates in SPAT are part time thus any payments
280        # coming from those certificates (Application, Acceptance, school fees
281        # etc) 40% should be split to keystone account.
282        # abraham: Please, kindly exclude the 40% going to Keystone bank for school of part-
283        # time (SPAT) O'level Results Verification payment.
284        if student.faccode == 'SPAT' and not self.context.p_category.startswith('olevel_results'):
285            xmldict['institution_amt_2'] = 0.4 * institution_amt
286            xmldict['institution_amt_1'] = 0.6 * institution_amt
287            if provider_amt == 0:
288                xmltext = """<payment_item_detail>
289<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
290<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" />
291<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
292</item_details>
293</payment_item_detail>""" % xmldict
294            elif tech_fee == 0:
295                xmltext = """<payment_item_detail>
296<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
297<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" />
298<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
299<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" />
300</item_details>
301</payment_item_detail>""" % xmldict
302            else:
303                xmltext = """<payment_item_detail>
304<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
305<item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
306<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
307<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" />
308<item_detail item_id="4" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
309</item_details>
310</payment_item_detail>""" % xmldict
311
312
313        # Some payments are treated completely separately. The following lines
314        # override the configuration above.
315
316        if self.context.p_category == 'dep_sug':
317            self.pay_item_id = '102' # We use school fee item id
318            # amount_auth is being ignored. However, the sum of all split payments
319            # must coincide with the amount_auth configured in students/utils.py
320            xmldict['amt1'] = 100 * 1000
321            xmldict['amt2'] = 100 * 500
322            xmldict['amt3'] = 100 * 900
323            xmldict['amt4'] = 100 * 500
324
325            xmltext = """<payment_item_detail>
326<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
327<item_detail item_id="1" item_name="SUG" item_amt="%(amt1)d" bank_id="11" acct_num="0038079930" />
328<item_detail item_id="2" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" />
329<item_detail item_id="3" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" />
330<item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
331</item_details>
332</payment_item_detail>""" % xmldict
333
334        if self.context.p_category == 'sbs_1':
335            self.pay_item_id = '120'
336            # amount_auth is being ignored. However, the sum of all split payments
337            # must coincide with the amount_auth configured in students/utils.py
338            xmldict['amt1'] = 100 * 800
339            xmldict['amt2'] = 100 * 1000
340            xmldict['amt3'] = 100 * 500
341
342            xmltext = """<payment_item_detail>
343<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
344<item_detail item_id="1" item_name="SBS Dues I" item_amt="%(amt1)d" bank_id="11" acct_num="0010772626" />
345<item_detail item_id="2" item_name="Journal fee" item_amt="%(amt2)d" bank_id="11" acct_num="0010772626" />
346<item_detail item_id="3" item_name="ABSOBS" item_amt="%(amt3)d" bank_id="8" acct_num="2008185712" />
347</item_details>
348</payment_item_detail>""" % xmldict
349
350        if self.context.p_category == 'sbs_2':
351            self.pay_item_id = '123'
352            # amount_auth is being ignored. However, the sum of all split payments
353            # must coincide with the amount_auth configured in students/utils.py
354            xmldict['amt1'] = 100 * 300
355            xmldict['amt2'] = 100 * 500
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="SBS Dues II" item_amt="%(amt1)d" bank_id="11" acct_num="0010772626" />
359<item_detail item_id="2" item_name="ABSOBS" item_amt="%(amt2)d" bank_id="8" acct_num="2008185712" />
360</item_details>
361</payment_item_detail>""" % xmldict
362
363        if self.context.p_category == 'mkt':
364            self.pay_item_id = '127'
365            # amount_auth is being ignored. However, the sum of all split payments
366            # must coincide with the amount_auth configured in students/utils.py
367            xmldict['amt1'] = 100 * 500
368            xmldict['amt2'] = 100 * 500
369            xmltext = """<payment_item_detail>
370<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
371<item_detail item_id="1" item_name="MKT Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0048297823" />
372<item_detail item_id="2" item_name="NAMS" item_amt="%(amt2)d" bank_id="8" acct_num="2032309812" />
373</item_details>
374</payment_item_detail>""" % xmldict
375
376        if self.context.p_category == 'mcn':
377            self.pay_item_id = '129'
378            # amount_auth is being ignored. However, the sum of all split payments
379            # must coincide with the amount_auth configured in students/utils.py
380            xmldict['amt1'] = 100 * 500
381            xmldict['amt2'] = 100 * 500
382            xmltext = """<payment_item_detail>
383<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
384<item_detail item_id="1" item_name="MCN Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0010789213" />
385<item_detail item_id="2" item_name="AMCOS" item_amt="%(amt2)d" bank_id="8" acct_num="3020253234" />
386</item_details>
387</payment_item_detail>""" % xmldict
388
389        if self.context.p_category == 'otm':
390            self.pay_item_id = '131'
391            # amount_auth is being ignored. However, the sum of all split payments
392            # must coincide with the amount_auth configured in students/utils.py
393            xmldict['amt1'] = 100 * 500
394            xmldict['amt2'] = 100 * 500
395            xmltext = """<payment_item_detail>
396<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
397<item_detail item_id="1" item_name="OTM Dues" item_amt="%(amt1)d" bank_id="8" acct_num="3068446702" />
398<item_detail item_id="2" item_name="NAOTM" item_amt="%(amt2)d" bank_id="11" acct_num="0036652027" />
399</item_details>
400</payment_item_detail>""" % xmldict
401
402        if self.context.p_category == 'acct':
403            self.pay_item_id = '134'
404            # amount_auth is being ignored. However, the sum of all split payments
405            # must coincide with the amount_auth configured in students/utils.py
406            xmldict['amt1'] = 100 * 3000
407            xmldict['amt2'] = 100 * 500
408            xmldict['amt3'] = 100 * 500
409            xmltext = """<payment_item_detail>
410<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
411<item_detail item_id="1" item_name="Profession Accreditation" item_amt="%(amt1)d" bank_id="11" acct_num="0040285084" />
412<item_detail item_id="2" item_name="ACCT Dues" item_amt="%(amt2)d" bank_id="11" acct_num="0036184955" />
413<item_detail item_id="3" item_name="NAPAS" item_amt="%(amt3)d" bank_id="8" acct_num="2008498661" />
414</item_details>
415</payment_item_detail>""" % xmldict
416
417        if self.context.p_category == 'bam':
418            self.pay_item_id = '136'
419            # amount_auth is being ignored. However, the sum of all split payments
420            # must coincide with the amount_auth configured in students/utils.py
421            xmldict['amt1'] = 100 * 500
422            xmldict['amt2'] = 100 * 500
423            xmltext = """<payment_item_detail>
424<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
425<item_detail item_id="1" item_name="BAM Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0010788058" />
426<item_detail item_id="2" item_name="NABAS" item_amt="%(amt2)d" bank_id="8" acct_num="2006936848" />
427</item_details>
428</payment_item_detail>""" % xmldict
429
430        if self.context.p_category == 'pom':
431            self.pay_item_id = '138'
432            # amount_auth is being ignored. However, the sum of all split payments
433            # must coincide with the amount_auth configured in students/utils.py
434            xmldict['amt1'] = 100 * 500
435            xmldict['amt2'] = 100 * 500
436            xmltext = """<payment_item_detail>
437<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
438<item_detail item_id="1" item_name="POM Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0096851444" />
439<item_detail item_id="2" item_name="NAMS" item_amt="%(amt2)d" bank_id="8" acct_num="2033423003" />
440</item_details>
441</payment_item_detail>""" % xmldict
442
443        if self.context.p_category == 'hrm':
444            self.pay_item_id = '140'
445            # amount_auth is being ignored. However, the sum of all split payments
446            # must coincide with the amount_auth configured in students/utils.py
447            xmldict['amt1'] = 100 * 500
448            xmldict['amt2'] = 100 * 500
449            xmltext = """<payment_item_detail>
450<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
451<item_detail item_id="1" item_name="HRM Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0096858546" />
452<item_detail item_id="2" item_name="NAMS" item_amt="%(amt2)d" bank_id="8" acct_num="2033423003" />
453</item_details>
454</payment_item_detail>""" % xmldict
455
456        if self.context.p_category == 'ndgrad':
457            self.pay_item_id = '152'
458            # amount_auth is being ignored. However, the sum of all split payments
459            # must coincide with the amount_auth configured in students/utils.py
460            xmldict['amt1'] = 100 * 3000
461            xmldict['amt2'] = 100 * 5000
462            xmldict['amt3'] = 100 * 1000
463            xmldict['amt4'] = 100 * 3500
464            xmltext = """<payment_item_detail>
465<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
466<item_detail item_id="1" item_name="Collection of Results" item_amt="%(amt1)d" bank_id="117" acct_num="1012808851" />
467<item_detail item_id="2" item_name="Collection of Certificate" item_amt="%(amt2)d" bank_id="117" acct_num="1012808851" />
468<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
469<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
470</item_details>
471</payment_item_detail>""" % xmldict
472
473        if self.context.p_category == 'hndgrad':
474            self.pay_item_id = '153'
475            # amount_auth is being ignored. However, the sum of all split payments
476            # must coincide with the amount_auth configured in students/utils.py
477            xmldict['amt1'] = 100 * 5000
478            xmldict['amt2'] = 100 * 7500
479            xmldict['amt3'] = 100 * 1000
480            xmldict['amt4'] = 100 * 3500
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="Collection of Results" item_amt="%(amt1)d" bank_id="117" acct_num="1012808851" />
484<item_detail item_id="2" item_name="Collection of Certificate" item_amt="%(amt2)d" bank_id="117" acct_num="1012808851" />
485<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
486<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
487</item_details>
488</payment_item_detail>""" % xmldict
489
490        if self.context.p_category == 'sas_1':
491            self.pay_item_id = '158'
492            # amount_auth is being ignored. However, the sum of all split payments
493            # must coincide with the amount_auth configured in students/utils.py
494            xmldict['amt1'] = 100 * 500
495            xmldict['amt2'] = 100 * 500
496            xmldict['amt3'] = 100 * 500
497            xmltext = """<payment_item_detail>
498<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
499<item_detail item_id="1" item_name="SAS Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0038956822" />
500<item_detail item_id="2" item_name="Handbook Fee" item_amt="%(amt2)d" bank_id="11" acct_num="0010772626" />
501<item_detail item_id="3" item_name="Association Due" item_amt="%(amt3)d" bank_id="8" acct_num="3069091989" />
502</item_details>
503</payment_item_detail>""" % xmldict
504
505        if self.context.p_category == 'sas_2':
506            self.pay_item_id = '159'
507            # amount_auth is being ignored. However, the sum of all split payments
508            # must coincide with the amount_auth configured in students/utils.py
509            xmldict['amt1'] = 100 * 500
510            xmldict['amt2'] = 100 * 500
511            xmltext = """<payment_item_detail>
512<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
513<item_detail item_id="1" item_name="SAS Dues" item_amt="%(amt1)d" bank_id="11" acct_num="0038956822" />
514<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="8" acct_num="3069091989" />
515</item_details>
516</payment_item_detail>""" % xmldict
517
518        if self.context.p_category == 'com':
519            self.pay_item_id = '160'
520            # amount_auth is being ignored. However, the sum of all split payments
521            # must coincide with the amount_auth configured in students/utils.py
522            xmldict['amt1'] = 100 * 500
523            xmldict['amt2'] = 100 * 500
524            xmltext = """<payment_item_detail>
525<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
526<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="11" acct_num="0010787594" />
527<item_detail item_id="2" item_name="NACOS " item_amt="%(amt2)d" bank_id="8" acct_num="3047146881" />
528</item_details>
529</payment_item_detail>""" % xmldict
530
531        if self.context.p_category == 'sta':
532            self.pay_item_id = '161'
533            # amount_auth is being ignored. However, the sum of all split payments
534            # must coincide with the amount_auth configured in students/utils.py
535            xmldict['amt1'] = 100 * 500
536            xmldict['amt2'] = 100 * 500
537            xmltext = """<payment_item_detail>
538<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
539<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="11" acct_num="0048794281" />
540<item_detail item_id="2" item_name="NASS " item_amt="%(amt2)d" bank_id="8" acct_num="203000173" />
541</item_details>
542</payment_item_detail>""" % xmldict
543
544        if self.context.p_category == 'slt_1':
545            self.pay_item_id = '162'
546            # amount_auth is being ignored. However, the sum of all split payments
547            # must coincide with the amount_auth configured in students/utils.py
548            xmldict['amt1'] = 100 * 500
549            xmldict['amt2'] = 100 * 500
550            xmldict['amt3'] = 100 * 3000
551            xmldict['amt4'] = 100 * 500
552            xmldict['amt5'] = 100 * 3000
553            xmldict['amt6'] = 100 * 2000
554            xmltext = """<payment_item_detail>
555<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
556<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="8" acct_num="2033492885" />
557<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="11" acct_num="0115800071" />
558<item_detail item_id="3" item_name="Professional Due" item_amt="%(amt3)d" bank_id="8" acct_num="2033492885" />
559<item_detail item_id="4" item_name="Prospectus" item_amt="%(amt4)d" bank_id="8" acct_num="2033492885" />
560<item_detail item_id="5" item_name="Practical Manual" item_amt="%(amt4)d" bank_id="8" acct_num="2033492885" />
561<item_detail item_id="6" item_name="Lab. Coat" item_amt="%(amt4)d" bank_id="8" acct_num="2033492885" />
562</item_details>
563</payment_item_detail>""" % xmldict
564
565        if self.context.p_category == 'slt_2':
566            self.pay_item_id = '163'
567            # amount_auth is being ignored. However, the sum of all split payments
568            # must coincide with the amount_auth configured in students/utils.py
569            xmldict['amt1'] = 100 * 500
570            xmldict['amt2'] = 100 * 500
571            xmldict['amt3'] = 100 * 3000
572            xmltext = """<payment_item_detail>
573<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
574<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="8" acct_num="2033492885" />
575<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="11" acct_num="0115800071" />
576<item_detail item_id="3" item_name="Practical Manual" item_amt="%(amt3)d" bank_id="8" acct_num="2033492885" />
577</item_details>
578</payment_item_detail>""" % xmldict
579
580        if self.context.p_category == 'lis':
581            self.pay_item_id = '164'
582            # amount_auth is being ignored. However, the sum of all split payments
583            # must coincide with the amount_auth configured in students/utils.py
584            xmldict['amt1'] = 100 * 500
585            xmldict['amt2'] = 100 * 500
586            xmltext = """<payment_item_detail>
587<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
588<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="" acct_num="0068264131" />
589<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="" acct_num="" />
590</item_details>
591</payment_item_detail>""" % xmldict
592
593        if self.context.p_category == 'htm':
594            self.pay_item_id = '165'
595            # amount_auth is being ignored. However, the sum of all split payments
596            # must coincide with the amount_auth configured in students/utils.py
597            xmldict['amt1'] = 100 * 500
598            xmldict['amt2'] = 100 * 500
599            xmltext = """<payment_item_detail>
600<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
601<item_detail item_id="1" item_name="Departmental Due" item_amt="%(amt1)d" bank_id="" acct_num="0068264131" />
602<item_detail item_id="2" item_name="Association Due" item_amt="%(amt2)d" bank_id="" acct_num="" />
603</item_details>
604</payment_item_detail>""" % xmldict
605
606
607        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
608        self.context.provider_amt = provider_amt
609        self.context.gateway_amt = GATEWAY_AMT
610        self.amount_auth = int(100 * self.context.amount_auth)
611        hashargs = (
612            self.context.p_id +
613            PRODUCT_ID +
614            self.pay_item_id +
615            str(int(self.amount_auth)) +
616            self.site_redirect_url +
617            self.mac)
618        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
619        return
620
621class CustomInterswitchPageApplicant(InterswitchPageApplicant):
622    """ View which sends a POST request to the Interswitch
623    CollegePAY payment gateway.
624    """
625    grok.context(ICustomApplicantOnlinePayment)
626    action = POST_ACTION
627    site_name = SITE_NAME
628    currency = CURRENCY
629    pay_item_id = '101' # must be provided by Interswitch
630    product_id = PRODUCT_ID
631    mac = MAC
632
633    def update(self):
634        error = self.init_update()
635        if error:
636            self.flash(error, type='danger')
637            self.redirect(self.url(self.context, '@@index'))
638            return
639        self.context.r_company = u'interswitch'
640        xmldict = {}
641        provider_amt = 500.0
642        gateway_amt = GATEWAY_AMT
643        xmldict['institution_acct'] = '00000000'
644        xmldict['institution_bank_id'] = '00'
645        if self.applicant.__parent__.application_category in ('ndft', 'hndft'):
646            xmldict['institution_acct'] = '0072223654'
647            xmldict['institution_bank_id'] = '121'
648        elif self.applicant.__parent__.application_category in (
649            'ndpt', 'hndpt', 'ndwe', 'hndwe'):
650            xmldict['institution_acct'] = '1015220292'
651            xmldict['institution_bank_id'] = '117'
652        elif self.applicant.__parent__.prefix in ('conv', 'hndfincl', 'ndfincl'):
653            xmldict['institution_acct'] = '1012808851'
654            xmldict['institution_bank_id'] = '117'
655            self.pay_item_id = '151'
656        elif self.applicant.applicant_id.startswith('special'):
657            if self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys():
658                self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0]
659                provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1]
660                xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2]
661                xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3]
662        if self.pay_item_id in ('122', '123', '132', '137', '141',
663                                '142', '143', '144', '146', '147',):
664                gateway_amt = round(0.015 * self.context.amount_auth, 2)
665        xmldict['detail_ref'] = self.context.p_id
666        xmldict['provider_amt'] = 100 * provider_amt
667        xmldict['provider_acct'] = PROVIDER_ACCT
668        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
669        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
670        xmldict['institution_amt'] = institution_amt = 100 * (
671            self.context.amount_auth - provider_amt - gateway_amt)
672        xmldict['institution_item_name'] = self.context.category
673        xmldict['institution_name'] = INSTITUTION_NAME
674        xmltext = """<payment_item_detail>
675<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
676<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" />
677<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" />
678</item_details>
679</payment_item_detail>""" % xmldict
680
681        # isouaba: All certificates in SPAT are part time thus any payments
682        # coming from those certificates (Application, Acceptance, school fees
683        # etc) 40% should be split to keystone account.
684        if self.applicant.__parent__.application_category in (
685            'ndpt', 'hndpt', 'ndwe', 'hndwe'):
686            xmldict['institution_amt_2'] = 0.4 * institution_amt
687            xmldict['institution_amt_1'] = 0.6 * institution_amt
688            xmltext = """<payment_item_detail>
689<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
690<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" />
691<item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="8" acct_num="2034761924" />
692<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" />
693</item_details>
694</payment_item_detail>""" % xmldict
695
696        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
697        self.context.provider_amt = provider_amt
698        self.context.gateway_amt = GATEWAY_AMT
699        self.amount_auth = int(100 * self.context.amount_auth)
700        hashargs = (
701            self.context.p_id +
702            PRODUCT_ID +
703            self.pay_item_id +
704            str(int(self.amount_auth)) +
705            self.site_redirect_url +
706            self.mac)
707        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
708        return
709
710class CustomInterswitchPaymentRequestWebservicePageStudent(
711    InterswitchPaymentRequestWebservicePageStudent):
712    """Request webservice view for the CollegePAY gateway
713    """
714    grok.context(ICustomStudentOnlinePayment)
715    product_id = PRODUCT_ID
716    gateway_host = HOST
717    gateway_url = URL
718    mac = MAC
719
720class CustomInterswitchPaymentVerifyWebservicePageStudent(
721    InterswitchPaymentVerifyWebservicePageStudent):
722    """Payment verify view for the CollegePAY gateway
723    """
724    grok.context(ICustomStudentOnlinePayment)
725    product_id = PRODUCT_ID
726    gateway_host = HOST
727    gateway_url = URL
728    mac = MAC
729
730class CustomInterswitchPaymentRequestWebservicePageApplicant(
731    InterswitchPaymentRequestWebservicePageApplicant):
732    """Request webservice view for the CollegePAY gateway
733    """
734    grok.context(ICustomApplicantOnlinePayment)
735    product_id = PRODUCT_ID
736    gateway_host = HOST
737    gateway_url = URL
738    mac = MAC
739
740class CustomInterswitchPaymentVerifyWebservicePageApplicant(
741    InterswitchPaymentVerifyWebservicePageApplicant):
742    """Payment verify view for the CollegePAY gateway
743    """
744    grok.context(ICustomApplicantOnlinePayment)
745    product_id = PRODUCT_ID
746    gateway_host = HOST
747    gateway_url = URL
748    mac = MAC
Note: See TracBrowser for help on using the repository browser.