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
RevLine 
[10765]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
[12479]19import hashlib
[10765]20import grok
[16418]21from waeup.kofa.interfaces import CLEARED, RETURNING
[10765]22from kofacustom.nigeria.interswitch.browser import (
23    InterswitchPaymentRequestWebservicePageApplicant,
[11638]24    InterswitchPaymentRequestWebservicePageStudent,
[13587]25    InterswitchPaymentVerifyWebservicePageApplicant,
26    InterswitchPaymentVerifyWebservicePageStudent,
[11638]27    InterswitchPageStudent, InterswitchPageApplicant,
[10765]28    )
[14716]29from kofacustom.dspg.students.interfaces import ICustomStudentOnlinePayment
30from kofacustom.dspg.applicants.interfaces import ICustomApplicantOnlinePayment
31from kofacustom.dspg.interfaces import MessageFactory as _
[16421]32from kofacustom.dspg.students.utils import MICROSOFT_FEE
[10765]33
[14726]34PRODUCT_ID = '7269' # must be provided by Interswitch
[14749]35SITE_NAME = 'dspg.waeup.org'
[14879]36PROVIDER_ACCT = '2028964403'
37PROVIDER_BANK_ID = '8'
[15248]38PROVIDER_ITEM_NAME = 'WAEAC'
[14722]39INSTITUTION_NAME = 'Delta State Polytechnic Ogwashi-Uku'
[10765]40CURRENCY = '566'
[14727]41GATEWAY_AMT = 250.0
[15021]42MAC = 'D43ED93B7A307B152C7111D04E1F384428057CD1E75428D3A4C5631C28ACB9C8C822A88CA76DEDC5F9A520CF4BFDB2824FF8B207AAFC667DF3CBB13685B66627'
[10765]43
[14726]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'
[14276]50
[12479]51httplib.HTTPSConnection.debuglevel = 0
52HTTPS = True
[10765]53
[14859]54SPECIAL_PAYMENT_PARAMS = {
[14864]55
[16411]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'),
[14864]67
[15959]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'),
[14859]103    }
104
[14862]105
[14875]106# Not yet readily configured. Bank account numbers are
[14862]107# contradictory. pay_item_ids are not yet assigned.
108
[11638]109class CustomInterswitchPageStudent(InterswitchPageStudent):
[10765]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
[15021]118    mac = MAC
[14875]119    pay_item_id = '000'
[10765]120
121    def update(self):
[12979]122        error = self.init_update()
123        if error:
124            self.flash(error, type='danger')
125            self.redirect(self.url(self.context, '@@index'))
126            return
[15764]127        self.context.r_company = u'interswitch'
[11647]128        student = self.student
129        xmldict = self.xmldict
[10765]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
[14875]136        xmldict['institution_acct'] = '00000000'
137        xmldict['institution_bank_id'] = '00'
[10765]138        xmldict['institution_amt'] = '0.0'
[14875]139        provider_amt = 0.0
[14961]140        tech_fee = 0.0
[16418]141        microsoft_fee = 0.0
[14862]142        if self.context.p_category.startswith('schoolfee'):
143            self.pay_item_id = '102'
[15764]144            if self.context.p_item != 'Balance':
145                provider_amt = 2800.0
[15767]146                tech_fee = 1200.0
[16418]147                if student.state == RETURNING:
[16421]148                    microsoft_fee = MICROSOFT_FEE
[14889]149            if student.faccode == 'SPAT':
[15214]150                xmldict['institution_acct'] = '1015220292'
[14875]151                xmldict['institution_bank_id'] = '117'
[14889]152            elif student.current_mode in ('nd_ft', 'hnd_ft'):
[16356]153                xmldict['institution_acct'] = '2004145840'
154                xmldict['institution_bank_id'] = '8'
[14862]155        elif self.context.p_category == 'clearance':
156            self.pay_item_id = '103'
[15764]157            if self.context.p_item != 'Balance':
158                provider_amt = 500.0
[14889]159            if student.faccode == 'SPAT':
[15227]160                xmldict['institution_acct'] = '1015220292'
[14875]161                xmldict['institution_bank_id'] = '117'
[15179]162            elif student.current_mode in ('nd_ft', 'hnd_ft'):
[15608]163                xmldict['institution_acct'] = '0072223654'
164                xmldict['institution_bank_id'] = '121'
[14942]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'
[15021]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'
[15466]175            xmldict['institution_acct'] = '0080527351'
176            xmldict['institution_bank_id'] = '11'
[15022]177        elif self.context.p_category == 'eed_1':
[15021]178            self.pay_item_id = '112'
179            xmldict['institution_acct'] = '0039782431'
180            xmldict['institution_bank_id'] = '11'
[15022]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'
[16323]185        elif self.context.p_category == 'eed_extra':
[16335]186            self.pay_item_id = '157'
[16323]187            xmldict['institution_acct'] = '0039782431'
188            xmldict['institution_bank_id'] = '11'
[15022]189        elif self.context.p_category == 'olevel_results_1':
[15021]190            self.pay_item_id = '113'
191            xmldict['institution_acct'] = '2015327204'
192            xmldict['institution_bank_id'] = '8'
[15022]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'
[16309]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'
[15219]205        elif self.context.p_category == 'hostel_maintenance':
[15764]206            if self.context.p_item != 'Balance':
207                provider_amt = 500.0
[15219]208            self.pay_item_id = '117'
[16384]209            xmldict['institution_acct'] = '1012808851'
210            xmldict['institution_bank_id'] = '117'
[15350]211        elif self.context.p_category == 'lsfp_penalty':
212            self.pay_item_id = '102'
[15959]213            xmldict['institution_acct'] = '1012808851'
[15350]214            xmldict['institution_bank_id'] = '117'
[16323]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':
[16336]228            self.pay_item_id = '156'
[16323]229            xmldict['institution_acct'] = '1012808851'
230            xmldict['institution_bank_id'] = '117'
[14862]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]
[10765]236        xmldict['provider_amt'] = 100 * provider_amt
[14961]237        xmldict['tech_fee'] = 100 * tech_fee
[12511]238        xmldict['institution_item_name'] = self.context.category
[10765]239        xmldict['institution_name'] = INSTITUTION_NAME
[14889]240        xmldict['institution_amt'] = institution_amt = 100 * (
[14961]241            self.context.amount_auth - provider_amt - tech_fee - GATEWAY_AMT)
242
[10765]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
[14961]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
[16418]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
[10765]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" />
[15323]269<item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
[16418]270<item_detail item_id="4" item_name="Microsoft Academy Fee" item_amt="%(microsoft_fee)d" bank_id="8" acct_num="2011810360" />
[10765]271</item_details>
272</payment_item_detail>""" % xmldict
[14889]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.
[15311]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'):
[14889]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" />
[15707]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" />
[14889]287</item_details>
288</payment_item_detail>""" % xmldict
[14964]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" />
[15707]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" />
[14964]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
[14889]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" />
[15707]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" />
[14889]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" />
[15323]303<item_detail item_id="4" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
[14889]304</item_details>
305</payment_item_detail>""" % xmldict
[15255]306
307
308        # Some payments are treated completely separately. The following lines
[14921]309        # override the configuration above.
[15255]310
[14921]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
[14938]315            xmldict['amt1'] = 100 * 1000
[14921]316            xmldict['amt2'] = 100 * 500
317            xmldict['amt3'] = 100 * 900
318            xmldict['amt4'] = 100 * 500
[14938]319
[14940]320            xmltext = """<payment_item_detail>
[14921]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" />
[14938]325<item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
[14921]326</item_details>
327</payment_item_detail>""" % xmldict
[14940]328
[15255]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" />
[15298]408<item_detail item_id="3" item_name="NAPAS" item_amt="%(amt3)d" bank_id="8" acct_num="2008498661" />
[15255]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
[15603]451        if self.context.p_category == 'ndgrad':
452            self.pay_item_id = '152'
[15571]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">
[15959]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" />
[15571]463<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
[15604]464<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
[15571]465</item_details>
466</payment_item_detail>""" % xmldict
[15255]467
[15603]468        if self.context.p_category == 'hndgrad':
469            self.pay_item_id = '153'
[15571]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
[15603]472            xmldict['amt1'] = 100 * 5000
[15571]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">
[15959]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" />
[15571]480<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
[15604]481<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
[15571]482</item_details>
483</payment_item_detail>""" % xmldict
484
[16367]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
[10765]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
[15765]605        self.amount_auth = int(100 * self.context.amount_auth)
[12479]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()
[10765]614        return
615
[11638]616class CustomInterswitchPageApplicant(InterswitchPageApplicant):
[10765]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
[14729]624    pay_item_id = '101' # must be provided by Interswitch
[10765]625    product_id = PRODUCT_ID
[15021]626    mac = MAC
[10765]627
628    def update(self):
[12979]629        error = self.init_update()
630        if error:
631            self.flash(error, type='danger')
632            self.redirect(self.url(self.context, '@@index'))
633            return
[15764]634        self.context.r_company = u'interswitch'
[10765]635        xmldict = {}
[14731]636        provider_amt = 500.0
[14859]637        gateway_amt = GATEWAY_AMT
[15075]638        xmldict['institution_acct'] = '00000000'
639        xmldict['institution_bank_id'] = '00'
640        if self.applicant.__parent__.application_category in ('ndft', 'hndft'):
[15474]641            xmldict['institution_acct'] = '0072223654'
642            xmldict['institution_bank_id'] = '121'
[15075]643        elif self.applicant.__parent__.application_category in (
644            'ndpt', 'hndpt', 'ndwe', 'hndwe'):
[15098]645            xmldict['institution_acct'] = '1015220292'
646            xmldict['institution_bank_id'] = '117'
[16026]647        elif self.applicant.__parent__.prefix in ('conv', 'hndfincl', 'ndfincl'):
[15959]648            xmldict['institution_acct'] = '1012808851'
[15577]649            xmldict['institution_bank_id'] = '117'
650            self.pay_item_id = '151'
[15075]651        elif self.applicant.applicant_id.startswith('special'):
[14859]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)
[10765]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
[14889]665        xmldict['institution_amt'] = institution_amt = 100 * (
666            self.context.amount_auth - provider_amt - gateway_amt)
[12511]667        xmldict['institution_item_name'] = self.context.category
[10765]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
[14889]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" />
[15707]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" />
[14889]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
[10765]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
[15765]694        self.amount_auth = int(100 * self.context.amount_auth)
[12479]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()
[10765]703        return
704
[11638]705class CustomInterswitchPaymentRequestWebservicePageStudent(
[10765]706    InterswitchPaymentRequestWebservicePageStudent):
[13587]707    """Request webservice view for the CollegePAY gateway
[10765]708    """
709    grok.context(ICustomStudentOnlinePayment)
710    product_id = PRODUCT_ID
711    gateway_host = HOST
712    gateway_url = URL
[15021]713    mac = MAC
[10765]714
[13587]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
[15021]723    mac = MAC
[13587]724
[11638]725class CustomInterswitchPaymentRequestWebservicePageApplicant(
[10765]726    InterswitchPaymentRequestWebservicePageApplicant):
[13587]727    """Request webservice view for the CollegePAY gateway
[10765]728    """
729    grok.context(ICustomApplicantOnlinePayment)
730    product_id = PRODUCT_ID
731    gateway_host = HOST
[12479]732    gateway_url = URL
[15021]733    mac = MAC
[13587]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
[14722]742    gateway_url = URL
[15021]743    mac = MAC
Note: See TracBrowser for help on using the repository browser.