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