[17431] | 1 | # -*- coding: utf-8 -*- |
---|
| 2 | ## $Id: browser.py 17429 2023-06-05 04:34:30Z henrik $ |
---|
| 3 | ## |
---|
| 4 | ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann |
---|
| 5 | ## This program is free software; you can redistribute it and/or modify |
---|
| 6 | ## it under the terms of the GNU General Public License as published by |
---|
| 7 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 8 | ## (at your option) any later version. |
---|
| 9 | ## |
---|
| 10 | ## This program is distributed in the hope that it will be useful, |
---|
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty ofself.context.amount_auth |
---|
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | ## GNU General Public License for more details. |
---|
| 14 | ## |
---|
| 15 | ## You should have received a copy of the GNU General Public License |
---|
| 16 | ## along with this program; if not, write to the Free Software |
---|
| 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 18 | ## |
---|
| 19 | import httplib |
---|
| 20 | import hashlib |
---|
| 21 | import grok |
---|
| 22 | import os |
---|
| 23 | import csv |
---|
| 24 | from xml.dom import minidom |
---|
| 25 | from zope.interface import Interface |
---|
| 26 | from zope.component import queryAdapter |
---|
| 27 | from waeup.kofa.interfaces import CLEARED |
---|
| 28 | from kofacustom.nigeria.interswitch.browser import ( |
---|
| 29 | InterswitchPaymentRequestWebservicePageStudent, |
---|
| 30 | InterswitchPaymentRequestWebservicePageApplicant, |
---|
| 31 | InterswitchPaymentVerifyWebservicePageApplicant, |
---|
| 32 | InterswitchPaymentVerifyWebservicePageStudent, |
---|
| 33 | InterswitchPageStudent, InterswitchPageApplicant, |
---|
| 34 | module_activated, |
---|
| 35 | ) |
---|
| 36 | from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment |
---|
| 37 | from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
[17447] | 38 | from waeup.aaue.students.utils import SFEECHANGES |
---|
[17431] | 39 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
| 40 | |
---|
| 41 | PRODUCT_ID = '5845' |
---|
| 42 | SITE_NAME = 'aaue.waeup.org' |
---|
| 43 | PROVIDER_ACCT = '0200244434' |
---|
| 44 | PROVIDER_BANK_ID = '11' |
---|
[17441] | 45 | PROVIDER_ITEM_NAME = 'WAeAC Portal Fee' |
---|
[17431] | 46 | INSTITUTION_NAME = 'AAU Ekpoma' |
---|
| 47 | CURRENCY = '566' |
---|
[18087] | 48 | GATEWAY_AMT = 300.0 |
---|
[17431] | 49 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' |
---|
| 50 | |
---|
| 51 | HOST = 'webpay.interswitchng.com' |
---|
| 52 | URL = '/paydirect/api/v1/gettransaction.json' |
---|
| 53 | HTTPS = True |
---|
| 54 | MAC = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023' |
---|
| 55 | |
---|
| 56 | httplib.HTTPSConnection.debuglevel = 0 |
---|
| 57 | |
---|
| 58 | BANK_ACCOUNTS = { |
---|
[17656] | 59 | 'edohis': ('2043582455', '8'), |
---|
[17514] | 60 | 'union': ('1019763348', '7'), |
---|
[17515] | 61 | 'union_pt': ('0051005007', '31'), |
---|
[17514] | 62 | 'sport': ('1021941220', '7'), |
---|
| 63 | 'access': ('1012688013', '123'), |
---|
| 64 | 'notebook': ('4011210501', '51'), |
---|
| 65 | 'accredit': ('5060023412', '51'), |
---|
| 66 | 'library': ('2000122995', '8'), |
---|
| 67 | 'fac1': ('1022438743', '7'), |
---|
| 68 | 'fac2': ('2000249757', '8'), |
---|
| 69 | 'fac3': ('1012678566', '123'), |
---|
| 70 | 'matricgown':('2000249757', '8'), |
---|
| 71 | 'lapel': ('2000249757', '8'), |
---|
| 72 | 'lmsplus': ('5060023429', '51'), |
---|
[17456] | 73 | |
---|
[17657] | 74 | 'acceptance': ('2043582644', '8'), |
---|
[17518] | 75 | 'parttime': ('1012678566', '123'), |
---|
[17468] | 76 | |
---|
[17582] | 77 | 'ijmb': ('1012278272', '123'), |
---|
[17699] | 78 | 'exam': ('1012278272', '123'), |
---|
[17582] | 79 | |
---|
[17699] | 80 | |
---|
[17456] | 81 | 'hostel_maintenance': ('1006406795', '123'), |
---|
[18045] | 82 | 'hostel_balance': ('1006406795', '123'), |
---|
[18033] | 83 | 'bed_allocation': ('1012327077', '123'), |
---|
[17456] | 84 | 'late_registration': ('5210006575', '51'), |
---|
| 85 | 'ent_combined': ('6220029828', '51'), |
---|
| 86 | 'ent_registration_0': ('6220029828', '51'), |
---|
| 87 | 'ent_registration_1': ('6220029828', '51'), |
---|
| 88 | 'ent_registration_2': ('6220029828', '51'), |
---|
| 89 | 'ent_text_book_0': ('6220029828', '51'), |
---|
| 90 | 'ent_text_book_1': ('6220029828', '51'), |
---|
| 91 | 'ent_text_book_2': ('6220029828', '51'), |
---|
| 92 | 'gst_registration_1': ('1010893123', '117'), |
---|
| 93 | 'gst_registration_2': ('1010893123', '117'), |
---|
| 94 | 'gst_text_book_0': ('1010893123', '117'), |
---|
| 95 | 'gst_text_book_1': ('1010893123', '117'), |
---|
| 96 | 'gst_text_book_2': ('1010893123', '117'), |
---|
| 97 | 'gst_text_book_3': ('1010893123', '117'), |
---|
[17468] | 98 | |
---|
| 99 | 'postgrad': ('1010827641', '117'), |
---|
[17431] | 100 | } |
---|
| 101 | |
---|
[17437] | 102 | FEE_NAMES = { |
---|
| 103 | 'edohis': 'Edo State Health Insurance Scheme', |
---|
| 104 | 'union': 'Student Union Dues', |
---|
[17515] | 105 | 'union_pt': 'Student Union Dues Part-Time', |
---|
[17437] | 106 | 'sport': 'Sport Development Fee', |
---|
| 107 | 'access': 'Access Card Fee', |
---|
| 108 | 'notebook': 'Branded Notebook', |
---|
[17490] | 109 | 'accredit': 'Accreditation Fee', |
---|
[17437] | 110 | 'library': 'Library Development Fee', |
---|
| 111 | 'tuition': 'Tuition', |
---|
| 112 | 'acceptance': 'Acceptance Fee', |
---|
| 113 | 'matricgown': 'Matriculation Gown Fee', |
---|
[17439] | 114 | 'lapel': 'File/Lapel Fee', |
---|
[17495] | 115 | 'lmsplus': 'LMS Plus Fee', |
---|
[17437] | 116 | 'nuga': 'NUGA Fee', |
---|
| 117 | } |
---|
| 118 | |
---|
[17431] | 119 | |
---|
[17447] | 120 | SCHOOLFEES = dict() |
---|
[17444] | 121 | |
---|
[17447] | 122 | for year in SFEECHANGES: |
---|
| 123 | schoolfees_path = os.path.join( |
---|
| 124 | os.path.dirname(__file__), '../students/schoolfees_%s.csv' %year) |
---|
| 125 | reader = csv.DictReader(open(schoolfees_path, 'rb')) |
---|
| 126 | SCHOOLFEES[year] = {item['code']:item for item in reader} |
---|
[17445] | 127 | |
---|
[17431] | 128 | acceptancefees_path = os.path.join( |
---|
| 129 | os.path.dirname(__file__), '../students/acceptancefees.csv') |
---|
| 130 | reader = csv.DictReader(open(acceptancefees_path, 'rb')) |
---|
| 131 | ACCEPTANCEFEES = {item['code']:item for item in reader} |
---|
| 132 | |
---|
| 133 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
| 134 | """ View which sends a POST request to the Interswitch |
---|
| 135 | CollegePAY payment gateway. |
---|
| 136 | |
---|
| 137 | So far only PT application has been configured. |
---|
| 138 | """ |
---|
| 139 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 140 | action = POST_ACTION |
---|
| 141 | site_name = SITE_NAME |
---|
| 142 | currency = CURRENCY |
---|
| 143 | provider_bank_id = PROVIDER_BANK_ID |
---|
| 144 | provider_acct = PROVIDER_ACCT |
---|
| 145 | pay_item_id = '101' |
---|
[17433] | 146 | product_id = PRODUCT_ID |
---|
[17431] | 147 | |
---|
| 148 | def update(self): |
---|
| 149 | if not module_activated( |
---|
| 150 | self.context.__parent__.__parent__.year, self.context): |
---|
| 151 | self.flash(_('Forbidden'), type='danger') |
---|
| 152 | self.redirect(self.url(self.context, '@@index')) |
---|
| 153 | return |
---|
| 154 | error = self.init_update() |
---|
| 155 | if error: |
---|
| 156 | self.flash(error, type='danger') |
---|
| 157 | self.redirect(self.url(self.context, '@@index')) |
---|
| 158 | return |
---|
| 159 | # Already now it becomes an Interswitch payment. We set the net amount |
---|
| 160 | # and add the gateway amount. |
---|
| 161 | if not self.context.r_company: |
---|
| 162 | self.context.net_amt = self.context.amount_auth |
---|
| 163 | self.context.amount_auth += GATEWAY_AMT |
---|
| 164 | self.context.gateway_amt = GATEWAY_AMT |
---|
| 165 | self.context.r_company = u'interswitch' |
---|
| 166 | xmldict = {} |
---|
[17477] | 167 | provider_amt = 2000.0 |
---|
[17719] | 168 | xmldict['institution_acct'] = '2043582644' |
---|
| 169 | xmldict['institution_bank_id'] = '8' |
---|
| 170 | if self.applicant.__parent__.code in ('ver2019', 'send2019', 'res2024'): |
---|
| 171 | provider_amt = 3000.0 |
---|
| 172 | xmldict['institution_acct'] = '2043583005' |
---|
| 173 | xmldict['institution_bank_id'] = '8' |
---|
[17477] | 174 | elif self.applicant.__parent__.code.startswith('cert'): |
---|
| 175 | provider_amt = 3000.0 |
---|
| 176 | elif self.applicant.__parent__.code.startswith('trans'): |
---|
| 177 | provider_amt = 3000.0 |
---|
[17468] | 178 | if self.applicant.applicant_id.startswith('dsh'): |
---|
[17781] | 179 | xmldict['institution_acct'] = '2043582644' |
---|
[17779] | 180 | xmldict['institution_bank_id'] = '8' |
---|
[17657] | 181 | elif self.applicant.applicant_id.startswith('ijmbe'): |
---|
[17901] | 182 | xmldict['institution_acct'] = '2043582644' |
---|
[17873] | 183 | xmldict['institution_bank_id'] = '8' |
---|
[17657] | 184 | elif 'alumni' in self.application_url(): |
---|
| 185 | xmldict['institution_acct'] = '2043583005' |
---|
[17431] | 186 | xmldict['detail_ref'] = self.context.p_id |
---|
| 187 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 188 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 189 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
[17490] | 190 | if 'alumni' in self.application_url(): |
---|
| 191 | xmldict['provider_acct'] = '0427773399' |
---|
| 192 | xmldict['provider_bank_id'] = '10' |
---|
[17431] | 193 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 194 | xmldict['institution_item_name'] = self.context.category |
---|
| 195 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
| 196 | xmldict['institution_amt'] = 100 * self.context.net_amt |
---|
| 197 | if not self.context.provider_amt: |
---|
| 198 | self.context.provider_amt = provider_amt |
---|
| 199 | self.context.amount_auth += provider_amt |
---|
[17469] | 200 | if provider_amt: |
---|
| 201 | xmltext = """<payment_item_detail> |
---|
[17431] | 202 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 203 | <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" /> |
---|
| 204 | <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" /> |
---|
| 205 | </item_details> |
---|
| 206 | </payment_item_detail>""" % xmldict |
---|
[17469] | 207 | else: |
---|
| 208 | xmltext = """<payment_item_detail> |
---|
| 209 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)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_details> |
---|
| 212 | </payment_item_detail>""" % xmldict |
---|
[17485] | 213 | |
---|
| 214 | # Overwrite above configuration |
---|
| 215 | if self.applicant.__parent__.code in ('cert1', 'cert2', 'cert6', 'cert9'): |
---|
| 216 | xmldict['institution_amt'] = 100 * self.context.net_amt - 100000 |
---|
| 217 | xmltext = """<payment_item_detail> |
---|
| 218 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)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_detail item_id="3" item_name="Ambrose Alli Foundation" item_amt="100000" bank_id="117" acct_num="1015567975" /> |
---|
| 222 | </item_details> |
---|
| 223 | </payment_item_detail>""" % xmldict |
---|
| 224 | |
---|
[17431] | 225 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 226 | xmlitems = '' |
---|
| 227 | xmldoc = minidom.parseString(xmltext) |
---|
| 228 | itemlist = xmldoc.getElementsByTagName('item_detail') |
---|
| 229 | for s in itemlist: |
---|
[17442] | 230 | xmlitems += "%s (%s %s, %s (%s)), " % ( |
---|
[17431] | 231 | s.attributes['item_name'].value, |
---|
[17442] | 232 | u'\u20a6', |
---|
[17431] | 233 | int(s.attributes['item_amt'].value)/100, |
---|
| 234 | s.attributes['acct_num'].value, |
---|
| 235 | s.attributes['bank_id'].value, |
---|
| 236 | ) |
---|
| 237 | self.context.p_split_data = xmlitems |
---|
| 238 | self.amount_auth = int(100 * self.context.amount_auth) |
---|
| 239 | hashargs = ( |
---|
| 240 | self.context.p_id + |
---|
| 241 | PRODUCT_ID + |
---|
| 242 | self.pay_item_id + |
---|
| 243 | str(int(self.amount_auth)) + |
---|
| 244 | self.site_redirect_url + |
---|
| 245 | MAC) |
---|
| 246 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 247 | return |
---|
| 248 | |
---|
| 249 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
| 250 | """ View which sends a POST request to the Interswitch |
---|
| 251 | CollegePAY payment gateway. |
---|
| 252 | """ |
---|
| 253 | grok.context(ICustomStudentOnlinePayment) |
---|
| 254 | action = POST_ACTION |
---|
| 255 | site_name = SITE_NAME |
---|
| 256 | currency = CURRENCY |
---|
| 257 | pay_item_id = '101' |
---|
[17433] | 258 | product_id = PRODUCT_ID |
---|
[17431] | 259 | |
---|
| 260 | def update(self): |
---|
| 261 | if not module_activated( |
---|
| 262 | self.context.student.current_session, self.context): |
---|
| 263 | self.flash(_('Forbidden'), type='danger') |
---|
| 264 | self.redirect(self.url(self.context, '@@index')) |
---|
| 265 | return |
---|
| 266 | error = self.init_update() |
---|
| 267 | if error: |
---|
| 268 | self.flash(error, type='danger') |
---|
| 269 | self.redirect(self.url(self.context, '@@index')) |
---|
| 270 | return |
---|
[17434] | 271 | student = self.student |
---|
[17431] | 272 | category = self.context.p_category |
---|
[17434] | 273 | # To guarantee that cleared students pay both acceptance fee |
---|
| 274 | # and school fees, the page can only be accessed |
---|
| 275 | # for school fee payments if acceptance/clearance fee has |
---|
| 276 | # been successfully queried/paid beforehand. This |
---|
| 277 | # requirement applies to students in state 'cleared' and |
---|
| 278 | # entry_session greater than 2012 only. |
---|
| 279 | if self.context.p_category.startswith('schoolfee') and \ |
---|
| 280 | student.state == CLEARED and \ |
---|
| 281 | student.entry_session > 2012: |
---|
| 282 | acceptance_fee_paid = False |
---|
| 283 | for ticket in student['payments'].values(): |
---|
| 284 | if ticket.p_state == 'paid' and \ |
---|
| 285 | ticket.p_category.startswith('clearance'): |
---|
| 286 | acceptance_fee_paid = True |
---|
| 287 | break |
---|
| 288 | if not acceptance_fee_paid: |
---|
| 289 | self.flash( |
---|
| 290 | _('Please pay acceptance fee first.'), type="danger") |
---|
| 291 | self.redirect(self.url(self.context, '@@index')) |
---|
| 292 | return |
---|
[17431] | 293 | # Already now it becomes an Interswitch payment. We set the net amount |
---|
| 294 | # and add the gateway amount. |
---|
| 295 | if not self.context.r_company: |
---|
| 296 | self.context.net_amt = self.context.amount_auth |
---|
| 297 | self.context.amount_auth += GATEWAY_AMT |
---|
| 298 | self.context.gateway_amt = GATEWAY_AMT |
---|
| 299 | self.context.r_company = u'interswitch' |
---|
| 300 | xmldict = self.xmldict |
---|
| 301 | # Provider data |
---|
| 302 | xmldict['detail_ref'] = self.context.p_id |
---|
| 303 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 304 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 305 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 306 | # Institution data |
---|
| 307 | xmldict['institution_acct'] = '00000000' |
---|
| 308 | xmldict['institution_bank_id'] = '00' |
---|
| 309 | provider_amt = 0.0 |
---|
| 310 | if category.startswith('clearance'): |
---|
| 311 | provider_amt = 1500.0 |
---|
| 312 | elif category.startswith('hostel_maintenance'): |
---|
| 313 | provider_amt = 1000.0 |
---|
| 314 | elif category in ('schoolfee', 'schoolfee_1', 'schoolfee_incl'): |
---|
| 315 | provider_amt = 2500.0 |
---|
| 316 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 317 | xmldict['institution_item_name'] = self.context.category |
---|
| 318 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
| 319 | xmldict['institution_amt'] = 100 * self.context.net_amt |
---|
| 320 | if not self.context.provider_amt: |
---|
| 321 | self.context.provider_amt = provider_amt |
---|
| 322 | self.context.amount_auth += provider_amt |
---|
| 323 | xmltext = '' |
---|
| 324 | |
---|
| 325 | # School fee |
---|
| 326 | if category.startswith('schoolfee'): |
---|
| 327 | # collect additional fees |
---|
| 328 | if self.context.p_category in ('schoolfee_1', 'schoolfee_incl'): |
---|
| 329 | xmltext = """<payment_item_detail> |
---|
| 330 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">""" % xmldict |
---|
| 331 | item_id = 1 |
---|
[17446] | 332 | |
---|
| 333 | if student.entry_session < 2013: |
---|
[17447] | 334 | sorted_items = SCHOOLFEES[12][student.certcode].items() |
---|
[17446] | 335 | elif student.entry_session < 2014: |
---|
[17447] | 336 | sorted_items = SCHOOLFEES[13][student.certcode].items() |
---|
[17455] | 337 | elif student.entry_session < 2015: |
---|
[17447] | 338 | sorted_items = SCHOOLFEES[14][student.certcode].items() |
---|
[17446] | 339 | elif student.entry_session < 2020: |
---|
[17455] | 340 | sorted_items = SCHOOLFEES[15][student.certcode].items() |
---|
[17445] | 341 | elif student.entry_session < 2021: |
---|
[17447] | 342 | sorted_items = SCHOOLFEES[20][student.certcode].items() |
---|
[17445] | 343 | elif student.entry_session < 2022: |
---|
[17447] | 344 | sorted_items = SCHOOLFEES[21][student.certcode].items() |
---|
[17580] | 345 | elif student.entry_session < 2023: |
---|
| 346 | sorted_items = SCHOOLFEES[22][student.certcode].items() |
---|
[17948] | 347 | elif student.entry_session < 2024: |
---|
| 348 | sorted_items = SCHOOLFEES[23][student.certcode].items() |
---|
[17444] | 349 | else: |
---|
[17948] | 350 | sorted_items = SCHOOLFEES[24][student.certcode].items() |
---|
[17529] | 351 | # Move tuition. We expect that tuition is the fourth element |
---|
[17523] | 352 | sorted_items.insert(0, sorted_items.pop(3)) |
---|
[17439] | 353 | for item in sorted_items: |
---|
[17431] | 354 | try: |
---|
[17508] | 355 | if item[1].startswith('100_') and student.state == CLEARED: |
---|
[17494] | 356 | # first year payment only |
---|
[17529] | 357 | item_amt = int(item[1].split('_')[1]) |
---|
[17494] | 358 | else: |
---|
[17529] | 359 | item_amt = int(item[1]) |
---|
[17431] | 360 | if self.context.p_category == 'schoolfee_1' and item[0] == 'tuition': |
---|
| 361 | item_amt /= 2 |
---|
[17529] | 362 | # Add non-indigenous fee and session specific penalty fees |
---|
| 363 | try: |
---|
| 364 | academic_session = grok.getSite()['configuration'][str(self.context.p_session)] |
---|
| 365 | except KeyError: |
---|
| 366 | self.flash( |
---|
| 367 | _('Session configuration object is missing.'), type="danger") |
---|
| 368 | self.redirect(self.url(self.context, '@@index')) |
---|
| 369 | return |
---|
| 370 | if student.is_postgrad and item[0] == 'tuition': |
---|
| 371 | item_amt += academic_session.penalty_pg |
---|
| 372 | if student.lga and not student.lga.startswith('edo') \ |
---|
| 373 | and student.entry_session < 2022: |
---|
| 374 | item_amt += 20000.0 |
---|
[17948] | 375 | elif item[0] == 'tuition': |
---|
[17529] | 376 | item_amt += academic_session.penalty_ug |
---|
| 377 | item_amt *= 100 |
---|
[17431] | 378 | acct_num = '' |
---|
| 379 | bank_id = '' |
---|
| 380 | item_name = '' |
---|
| 381 | # Find appropriate bank |
---|
[17694] | 382 | bank = None |
---|
[17431] | 383 | try: |
---|
| 384 | bank = BANK_ACCOUNTS[item[0]] |
---|
| 385 | except: # transfer to faculty account |
---|
[17516] | 386 | if student.is_postgrad: |
---|
| 387 | bank = BANK_ACCOUNTS['postgrad'] |
---|
[17518] | 388 | elif student.current_mode in ( |
---|
[17702] | 389 | 'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh', 'dp_ft'): |
---|
[17523] | 390 | bank = BANK_ACCOUNTS['parttime'] |
---|
[17516] | 391 | elif student.faccode in ('FAG', 'FAT', 'FBM', 'FMLS', 'fac1'): |
---|
[17431] | 392 | bank = BANK_ACCOUNTS['fac1'] |
---|
| 393 | elif student.faccode in ('FCS', 'FED', 'FES', 'FET'): |
---|
| 394 | bank = BANK_ACCOUNTS['fac2'] |
---|
| 395 | elif student.faccode in ('FLS', 'FLW', 'FMS', 'FPS', 'FSS'): |
---|
| 396 | bank = BANK_ACCOUNTS['fac3'] |
---|
[17582] | 397 | elif student.faccode in ('FP',): |
---|
| 398 | bank = BANK_ACCOUNTS['ijmb'] |
---|
[17694] | 399 | if not bank: |
---|
| 400 | self.flash( |
---|
[17695] | 401 | 'Bank account not set (%s).' % item[0], type="danger") |
---|
[17694] | 402 | self.redirect(self.url(self.context, '@@index')) |
---|
| 403 | return |
---|
[17431] | 404 | acct_num = bank[0] |
---|
| 405 | bank_id = bank[1] |
---|
[17437] | 406 | item_name = FEE_NAMES[item[0]] |
---|
[17431] | 407 | xmltext += """ |
---|
| 408 | <item_detail item_id="%s" item_name="%s" item_amt="%d" bank_id="%s" acct_num="%s" />""" % (item_id, item_name, item_amt, bank_id, acct_num) |
---|
| 409 | item_id += 1 |
---|
| 410 | except: |
---|
| 411 | pass |
---|
| 412 | xmldict['item_id'] = item_id |
---|
| 413 | xmltext += """ |
---|
| 414 | <item_detail item_id="%(item_id)d" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
| 415 | </item_details> |
---|
| 416 | </payment_item_detail>""" % xmldict |
---|
| 417 | # no additional charges, determine faculty bank only |
---|
| 418 | else: |
---|
[17694] | 419 | bank = None |
---|
[17468] | 420 | if student.is_postgrad: |
---|
| 421 | bank = BANK_ACCOUNTS['postgrad'] |
---|
[17643] | 422 | elif student.current_mode in ( |
---|
[17702] | 423 | 'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh', 'dp_ft'): |
---|
[17643] | 424 | bank = BANK_ACCOUNTS['parttime'] |
---|
[17468] | 425 | elif student.faccode in ('FAG', 'FAT', 'FBM', 'FMLS', 'fac1'): |
---|
[17431] | 426 | bank = BANK_ACCOUNTS['fac1'] |
---|
| 427 | elif student.faccode in ('FCS', 'FED', 'FES', 'FET'): |
---|
| 428 | bank = BANK_ACCOUNTS['fac2'] |
---|
| 429 | elif student.faccode in ('FLS', 'FLW', 'FMS', 'FPS', 'FSS'): |
---|
| 430 | bank = BANK_ACCOUNTS['fac3'] |
---|
[17583] | 431 | elif student.faccode in ('FP',): |
---|
| 432 | bank = BANK_ACCOUNTS['ijmb'] |
---|
[17694] | 433 | if not bank: |
---|
| 434 | self.flash('Bank account not set.', type="danger") |
---|
| 435 | self.redirect(self.url(self.context, '@@index')) |
---|
| 436 | return |
---|
[17431] | 437 | xmldict['institution_acct'] = bank[0] |
---|
| 438 | xmldict['institution_bank_id'] = bank[1] |
---|
| 439 | |
---|
| 440 | # Clearance (acceptance) fee |
---|
| 441 | |
---|
[17456] | 442 | elif category.startswith('clearance'): |
---|
[17431] | 443 | # collect additional fees |
---|
| 444 | if self.context.p_category == 'clearance_incl': |
---|
| 445 | xmltext = """<payment_item_detail> |
---|
| 446 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">""" % xmldict |
---|
| 447 | item_id = 1 |
---|
| 448 | for item in ACCEPTANCEFEES[student.certcode].items(): |
---|
| 449 | try: |
---|
| 450 | item_amt = 100 * int(item[1]) |
---|
| 451 | bank = BANK_ACCOUNTS[item[0]] |
---|
| 452 | acct_num = bank[0] |
---|
| 453 | bank_id = bank[1] |
---|
[17437] | 454 | item_name = FEE_NAMES[item[0]] |
---|
[17431] | 455 | xmltext += """ |
---|
| 456 | <item_detail item_id="%s" item_name="%s" item_amt="%d" bank_id="%s" acct_num="%s" />""" % (item_id, item_name, item_amt, bank_id, acct_num) |
---|
| 457 | item_id += 1 |
---|
| 458 | except: |
---|
| 459 | pass |
---|
| 460 | xmldict['item_id'] = item_id |
---|
| 461 | xmltext += """ |
---|
| 462 | <item_detail item_id="%(item_id)d" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
| 463 | </item_details> |
---|
| 464 | </payment_item_detail>""" % xmldict |
---|
| 465 | # no additional charges, determine faculty bank only |
---|
| 466 | else: |
---|
[17468] | 467 | if student.is_postgrad: |
---|
| 468 | bank = BANK_ACCOUNTS['postgrad'] |
---|
| 469 | else: |
---|
| 470 | bank = BANK_ACCOUNTS['acceptance'] |
---|
[17431] | 471 | xmldict['institution_acct'] = bank[0] |
---|
| 472 | xmldict['institution_bank_id'] = bank[1] |
---|
| 473 | |
---|
[17491] | 474 | # Hostel Maintenance |
---|
| 475 | |
---|
| 476 | elif category == 'hostel_maintenance': |
---|
| 477 | xmldict['institution_amt'] = 100 * self.context.net_amt - 1000000 |
---|
| 478 | bank = BANK_ACCOUNTS[category] |
---|
| 479 | xmldict['institution_acct'] = bank[0] |
---|
| 480 | xmldict['institution_bank_id'] = bank[1] |
---|
| 481 | xmltext = """<payment_item_detail> |
---|
| 482 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 483 | <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" /> |
---|
| 484 | <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" /> |
---|
| 485 | <item_detail item_id="3" item_name="Hostel Consumable Fee" item_amt="1000000" bank_id="123" acct_num="1012332141" /> |
---|
| 486 | </item_details> |
---|
| 487 | </payment_item_detail>""" % xmldict |
---|
| 488 | |
---|
[17431] | 489 | # Other fees |
---|
[17491] | 490 | |
---|
[17456] | 491 | elif category in BANK_ACCOUNTS.keys(): |
---|
| 492 | bank = BANK_ACCOUNTS[category] |
---|
| 493 | xmldict['institution_acct'] = bank[0] |
---|
| 494 | xmldict['institution_bank_id'] = bank[1] |
---|
[17431] | 495 | |
---|
| 496 | if not xmltext and provider_amt == 0: |
---|
| 497 | xmltext = """<payment_item_detail> |
---|
| 498 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 499 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 500 | </item_details> |
---|
| 501 | </payment_item_detail>""" % xmldict |
---|
| 502 | elif not xmltext: |
---|
| 503 | xmltext = """<payment_item_detail> |
---|
| 504 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 505 | <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" /> |
---|
| 506 | <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" /> |
---|
| 507 | </item_details> |
---|
| 508 | </payment_item_detail>""" % xmldict |
---|
| 509 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 510 | xmlitems = '' |
---|
| 511 | xmldoc = minidom.parseString(xmltext) |
---|
| 512 | itemlist = xmldoc.getElementsByTagName('item_detail') |
---|
| 513 | for s in itemlist: |
---|
[17442] | 514 | xmlitems += "%s (%s %s, %s (%s)), " % ( |
---|
[17431] | 515 | s.attributes['item_name'].value, |
---|
| 516 | u'\u20a6', |
---|
| 517 | int(s.attributes['item_amt'].value)/100, |
---|
| 518 | s.attributes['acct_num'].value, |
---|
| 519 | s.attributes['bank_id'].value, |
---|
| 520 | ) |
---|
| 521 | self.context.p_split_data = xmlitems |
---|
| 522 | self.context.provider_amt = provider_amt |
---|
| 523 | self.amount_auth = int(100 * self.context.amount_auth) |
---|
| 524 | hashargs = ( |
---|
| 525 | self.context.p_id + |
---|
| 526 | PRODUCT_ID + |
---|
| 527 | self.pay_item_id + |
---|
| 528 | str(int(self.amount_auth)) + |
---|
| 529 | self.site_redirect_url + |
---|
| 530 | MAC) |
---|
| 531 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 532 | return |
---|
| 533 | |
---|
| 534 | |
---|
| 535 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
| 536 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
| 537 | """Request webservice view for the CollegePAY gateway |
---|
| 538 | """ |
---|
| 539 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 540 | gateway_host = HOST |
---|
| 541 | gateway_url = URL |
---|
| 542 | https = HTTPS |
---|
[17480] | 543 | mac = MAC |
---|
| 544 | product_id = PRODUCT_ID |
---|
[17431] | 545 | |
---|
| 546 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
| 547 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
| 548 | """Payment verify view for the CollegePAY gateway |
---|
| 549 | """ |
---|
| 550 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 551 | gateway_host = HOST |
---|
| 552 | gateway_url = URL |
---|
| 553 | https = HTTPS |
---|
| 554 | mac = MAC |
---|
| 555 | product_id = PRODUCT_ID |
---|
| 556 | |
---|
| 557 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
| 558 | InterswitchPaymentRequestWebservicePageStudent): |
---|
| 559 | """Request webservice view for the CollegePAY gateway |
---|
| 560 | """ |
---|
| 561 | grok.context(ICustomStudentOnlinePayment) |
---|
| 562 | gateway_host = HOST |
---|
| 563 | gateway_url = URL |
---|
| 564 | https = HTTPS |
---|
| 565 | mac = MAC |
---|
| 566 | product_id = PRODUCT_ID |
---|
| 567 | |
---|
| 568 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
| 569 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
| 570 | """Payment verify view for the CollegePAY gateway |
---|
| 571 | """ |
---|
| 572 | grok.context(ICustomStudentOnlinePayment) |
---|
| 573 | gateway_host = HOST |
---|
| 574 | gateway_url = URL |
---|
| 575 | https = HTTPS |
---|
| 576 | mac = MAC |
---|
| 577 | product_id = PRODUCT_ID |
---|