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