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

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

Add PAD Pack.

  • Property svn:keywords set to Id
File size: 39.8 KB
RevLine 
[10765]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
[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':
[16506]150                xmldict['institution_acct'] = '1556004203'
151                xmldict['institution_bank_id'] = '388'
[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'
[16563]231        elif self.context.p_category == 'pa':
232            self.pay_item_id = '166'
233            xmldict['institution_acct'] = '0160125880'
234            xmldict['institution_bank_id'] = '11'
[14862]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]
[10765]240        xmldict['provider_amt'] = 100 * provider_amt
[14961]241        xmldict['tech_fee'] = 100 * tech_fee
[16429]242        xmldict['microsoft_fee'] = 100 * microsoft_fee
[12511]243        xmldict['institution_item_name'] = self.context.category
[10765]244        xmldict['institution_name'] = INSTITUTION_NAME
[14889]245        xmldict['institution_amt'] = institution_amt = 100 * (
[16429]246            self.context.amount_auth - provider_amt - tech_fee - microsoft_fee - GATEWAY_AMT)
[14961]247
[10765]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
[14961]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
[16418]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
[10765]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" />
[15323]274<item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
[16418]275<item_detail item_id="4" item_name="Microsoft Academy Fee" item_amt="%(microsoft_fee)d" bank_id="8" acct_num="2011810360" />
[10765]276</item_details>
277</payment_item_detail>""" % xmldict
[14889]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.
[15311]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'):
[14889]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" />
[15707]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" />
[14889]292</item_details>
293</payment_item_detail>""" % xmldict
[14964]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" />
[15707]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" />
[14964]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
[14889]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" />
[15707]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" />
[14889]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" />
[15323]308<item_detail item_id="4" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="10" acct_num="0032256360" />
[14889]309</item_details>
310</payment_item_detail>""" % xmldict
[15255]311
312
313        # Some payments are treated completely separately. The following lines
[14921]314        # override the configuration above.
[15255]315
[14921]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
[14938]320            xmldict['amt1'] = 100 * 1000
[14921]321            xmldict['amt2'] = 100 * 500
322            xmldict['amt3'] = 100 * 900
323            xmldict['amt4'] = 100 * 500
[14938]324
[14940]325            xmltext = """<payment_item_detail>
[14921]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" />
[14938]330<item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
[14921]331</item_details>
332</payment_item_detail>""" % xmldict
[14940]333
[15255]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" />
[15298]413<item_detail item_id="3" item_name="NAPAS" item_amt="%(amt3)d" bank_id="8" acct_num="2008498661" />
[15255]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
[15603]456        if self.context.p_category == 'ndgrad':
457            self.pay_item_id = '152'
[15571]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">
[15959]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" />
[15571]468<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
[15604]469<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
[15571]470</item_details>
471</payment_item_detail>""" % xmldict
[15255]472
[15603]473        if self.context.p_category == 'hndgrad':
474            self.pay_item_id = '153'
[15571]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
[15603]477            xmldict['amt1'] = 100 * 5000
[15571]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">
[15959]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" />
[15571]485<item_detail item_id="3" item_name="Alumni" item_amt="%(amt3)d" bank_id="8" acct_num="2011810346" />
[15604]486<item_detail item_id="4" item_name="Convocation" item_amt="%(amt4)d" bank_id="8" acct_num="2006612782" />
[15571]487</item_details>
488</payment_item_detail>""" % xmldict
489
[16367]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
[10765]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
[15765]610        self.amount_auth = int(100 * self.context.amount_auth)
[12479]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()
[10765]619        return
620
[11638]621class CustomInterswitchPageApplicant(InterswitchPageApplicant):
[10765]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
[14729]629    pay_item_id = '101' # must be provided by Interswitch
[10765]630    product_id = PRODUCT_ID
[15021]631    mac = MAC
[10765]632
633    def update(self):
[12979]634        error = self.init_update()
635        if error:
636            self.flash(error, type='danger')
637            self.redirect(self.url(self.context, '@@index'))
638            return
[15764]639        self.context.r_company = u'interswitch'
[10765]640        xmldict = {}
[14731]641        provider_amt = 500.0
[14859]642        gateway_amt = GATEWAY_AMT
[15075]643        xmldict['institution_acct'] = '00000000'
644        xmldict['institution_bank_id'] = '00'
645        if self.applicant.__parent__.application_category in ('ndft', 'hndft'):
[15474]646            xmldict['institution_acct'] = '0072223654'
647            xmldict['institution_bank_id'] = '121'
[15075]648        elif self.applicant.__parent__.application_category in (
649            'ndpt', 'hndpt', 'ndwe', 'hndwe'):
[15098]650            xmldict['institution_acct'] = '1015220292'
651            xmldict['institution_bank_id'] = '117'
[16026]652        elif self.applicant.__parent__.prefix in ('conv', 'hndfincl', 'ndfincl'):
[15959]653            xmldict['institution_acct'] = '1012808851'
[15577]654            xmldict['institution_bank_id'] = '117'
655            self.pay_item_id = '151'
[15075]656        elif self.applicant.applicant_id.startswith('special'):
[14859]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)
[10765]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
[14889]670        xmldict['institution_amt'] = institution_amt = 100 * (
671            self.context.amount_auth - provider_amt - gateway_amt)
[12511]672        xmldict['institution_item_name'] = self.context.category
[10765]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
[14889]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" />
[15707]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" />
[14889]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
[10765]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
[15765]699        self.amount_auth = int(100 * self.context.amount_auth)
[12479]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()
[10765]708        return
709
[11638]710class CustomInterswitchPaymentRequestWebservicePageStudent(
[10765]711    InterswitchPaymentRequestWebservicePageStudent):
[13587]712    """Request webservice view for the CollegePAY gateway
[10765]713    """
714    grok.context(ICustomStudentOnlinePayment)
715    product_id = PRODUCT_ID
716    gateway_host = HOST
717    gateway_url = URL
[15021]718    mac = MAC
[10765]719
[13587]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
[15021]728    mac = MAC
[13587]729
[11638]730class CustomInterswitchPaymentRequestWebservicePageApplicant(
[10765]731    InterswitchPaymentRequestWebservicePageApplicant):
[13587]732    """Request webservice view for the CollegePAY gateway
[10765]733    """
734    grok.context(ICustomApplicantOnlinePayment)
735    product_id = PRODUCT_ID
736    gateway_host = HOST
[12479]737    gateway_url = URL
[15021]738    mac = MAC
[13587]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
[14722]747    gateway_url = URL
[15021]748    mac = MAC
Note: See TracBrowser for help on using the repository browser.