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

Last change on this file since 15333 was 15323, checked in by Henrik Bettermann, 6 years ago

Change tech_fee bank account.

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