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

Last change on this file since 15842 was 15767, checked in by Henrik Bettermann, 5 years ago

Abraham Esene: No 1200 tech fee as well, this should not be too.

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