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

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

Change SPAT bank account.

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