[12730] | 1 | ## $Id: browser.py 15467 2019-06-20 12:45:11Z henrik $ |
---|
[11846] | 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 | ## |
---|
| 18 | import httplib |
---|
| 19 | import hashlib |
---|
| 20 | import grok |
---|
| 21 | from zope.interface import Interface |
---|
| 22 | from zope.component import queryAdapter |
---|
[12975] | 23 | from waeup.kofa.interfaces import CLEARED |
---|
[11846] | 24 | from kofacustom.nigeria.interswitch.browser import ( |
---|
| 25 | InterswitchPaymentRequestWebservicePageStudent, |
---|
| 26 | InterswitchPaymentRequestWebservicePageApplicant, |
---|
[13586] | 27 | InterswitchPaymentVerifyWebservicePageApplicant, |
---|
| 28 | InterswitchPaymentVerifyWebservicePageStudent, |
---|
[11846] | 29 | InterswitchPageStudent, InterswitchPageApplicant, |
---|
| 30 | ) |
---|
| 31 | from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment |
---|
| 32 | from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
| 33 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
| 34 | |
---|
[13379] | 35 | PRODUCT_ID_PT = '5040' |
---|
| 36 | PRODUCT_ID_REGULAR = '5845' |
---|
[11846] | 37 | SITE_NAME = 'aaue.waeup.org' |
---|
[14823] | 38 | PROVIDER_ACCT = '1014261520' |
---|
[14232] | 39 | PROVIDER_BANK_ID = '117' |
---|
[14823] | 40 | PROVIDER_ITEM_NAME = 'WAeAC' |
---|
[11846] | 41 | INSTITUTION_NAME = 'AAU Ekpoma' |
---|
| 42 | CURRENCY = '566' |
---|
[11934] | 43 | GATEWAY_AMT = 250.0 |
---|
[11933] | 44 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' |
---|
[11846] | 45 | |
---|
[11933] | 46 | HOST = 'webpay.interswitchng.com' |
---|
[13586] | 47 | URL = '/paydirect/api/v1/gettransaction.json' |
---|
[11916] | 48 | HTTPS = True |
---|
[13606] | 49 | MAC_REGULAR = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023' |
---|
| 50 | MAC_PT = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3' |
---|
[11846] | 51 | |
---|
[11917] | 52 | httplib.HTTPSConnection.debuglevel = 0 |
---|
[11846] | 53 | |
---|
[13379] | 54 | |
---|
[13414] | 55 | def gateway_net_amt(fee): |
---|
[13438] | 56 | if fee > GATEWAY_AMT: |
---|
[13414] | 57 | return fee - GATEWAY_AMT |
---|
[13438] | 58 | return 0.0 |
---|
[13406] | 59 | |
---|
[13532] | 60 | def contr_agreement_applicant(applicant): |
---|
[15396] | 61 | if applicant.__parent__ in ( |
---|
| 62 | 'fp', |
---|
| 63 | 'ptee', |
---|
| 64 | 'dsh', |
---|
| 65 | 'bridge', |
---|
| 66 | 'ijmbe', |
---|
| 67 | ): |
---|
[13532] | 68 | return 'first' |
---|
| 69 | return 'second' |
---|
| 70 | |
---|
| 71 | def contr_agreement_student(student): |
---|
[15382] | 72 | if student.current_mode in ( |
---|
[15387] | 73 | 'found', |
---|
| 74 | 'bridge', |
---|
| 75 | 'ug_dsh', |
---|
| 76 | 'de_dsh', |
---|
| 77 | 'ug_pt', |
---|
| 78 | 'de_pt', |
---|
[15396] | 79 | 'dp_pt', |
---|
| 80 | 'ijmbe', |
---|
| 81 | ): |
---|
[13403] | 82 | return 'first' |
---|
| 83 | return 'second' |
---|
[13379] | 84 | |
---|
[11846] | 85 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
| 86 | """ View which sends a POST request to the Interswitch |
---|
| 87 | CollegePAY payment gateway. |
---|
[13379] | 88 | |
---|
| 89 | So far only PT application has been configured. |
---|
[11846] | 90 | """ |
---|
| 91 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 92 | action = POST_ACTION |
---|
| 93 | site_name = SITE_NAME |
---|
| 94 | currency = CURRENCY |
---|
[15135] | 95 | provider_bank_id = PROVIDER_BANK_ID |
---|
| 96 | provider_acct = PROVIDER_ACCT |
---|
[15224] | 97 | institution_acct = '1010835352' |
---|
| 98 | institution_bank_id = '117' |
---|
[11846] | 99 | |
---|
| 100 | def update(self): |
---|
| 101 | |
---|
[12975] | 102 | error = self.init_update() |
---|
| 103 | if error: |
---|
| 104 | self.flash(error, type='danger') |
---|
| 105 | self.redirect(self.url(self.context, '@@index')) |
---|
| 106 | return |
---|
[15260] | 107 | provider_amt = 2000.0 |
---|
[13532] | 108 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 109 | self.product_id = PRODUCT_ID_PT |
---|
| 110 | self.pay_item_id = '101' |
---|
[13606] | 111 | self.mac = MAC_PT |
---|
[13532] | 112 | else: |
---|
| 113 | self.product_id = PRODUCT_ID_REGULAR |
---|
| 114 | self.pay_item_id = '109' |
---|
[13606] | 115 | self.mac = MAC_REGULAR |
---|
[15464] | 116 | if self.applicant.__parent__.prefix in ('utme', 'ude'): |
---|
| 117 | provider_amt = 1000.0 |
---|
[15121] | 118 | if self.applicant.__parent__.prefix in ('trans', 'cert'): |
---|
[15135] | 119 | self.provider_bank_id = '10' |
---|
| 120 | self.provider_acct = '0427773399' |
---|
[15224] | 121 | elif self.applicant.applicant_id.startswith('bridge',): # easier to test |
---|
| 122 | self.institution_acct = '1014847058' |
---|
| 123 | self.institution_bank_id = '7' |
---|
| 124 | |
---|
[11846] | 125 | xmldict = {} |
---|
| 126 | xmldict['detail_ref'] = self.context.p_id |
---|
| 127 | xmldict['provider_amt'] = 100 * provider_amt |
---|
[15135] | 128 | xmldict['provider_acct'] = self.provider_acct |
---|
| 129 | xmldict['provider_bank_id'] = self.provider_bank_id |
---|
[11846] | 130 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
[15224] | 131 | xmldict['institution_acct'] = self.institution_acct |
---|
| 132 | xmldict['institution_bank_id'] = self.institution_bank_id |
---|
[13532] | 133 | xmldict['institution_item_name'] = self.category |
---|
[11846] | 134 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
[15224] | 135 | xmldict['institution_amt'] = 100 * ( |
---|
| 136 | self.context.amount_auth - provider_amt - GATEWAY_AMT) |
---|
| 137 | xmltext = """<payment_item_detail> |
---|
| 138 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 139 | <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" /> |
---|
| 140 | <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" /> |
---|
| 141 | </item_details> |
---|
| 142 | </payment_item_detail>""" % xmldict |
---|
[14121] | 143 | |
---|
| 144 | if self.applicant.applicant_id.startswith('pg'): |
---|
| 145 | handbook_amount = 2000.0 |
---|
| 146 | xmldict['handbook_amount'] = 100 * handbook_amount |
---|
| 147 | xmldict['institution_amt'] = 100 * ( |
---|
| 148 | self.context.amount_auth - provider_amt - handbook_amount -GATEWAY_AMT) |
---|
| 149 | xmltext = """<payment_item_detail> |
---|
[11846] | 150 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 151 | <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" /> |
---|
| 152 | <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" /> |
---|
[14945] | 153 | <item_detail item_id="3" item_name="PG Handbook" item_amt="%(handbook_amount)d" bank_id="117" acct_num="1010827641" /> |
---|
[11846] | 154 | </item_details> |
---|
| 155 | </payment_item_detail>""" % xmldict |
---|
[14121] | 156 | |
---|
[11846] | 157 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 158 | self.context.provider_amt = provider_amt |
---|
| 159 | self.context.gateway_amt = GATEWAY_AMT |
---|
| 160 | |
---|
| 161 | hashargs = ( |
---|
| 162 | self.context.p_id + |
---|
[13532] | 163 | self.product_id + |
---|
[11846] | 164 | self.pay_item_id + |
---|
| 165 | str(int(self.amount_auth)) + |
---|
| 166 | self.site_redirect_url + |
---|
| 167 | self.mac) |
---|
| 168 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 169 | |
---|
| 170 | return |
---|
| 171 | |
---|
[11868] | 172 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
| 173 | """ View which sends a POST request to the Interswitch |
---|
| 174 | CollegePAY payment gateway. |
---|
| 175 | """ |
---|
| 176 | grok.context(ICustomStudentOnlinePayment) |
---|
| 177 | action = POST_ACTION |
---|
| 178 | site_name = SITE_NAME |
---|
| 179 | currency = CURRENCY |
---|
[14248] | 180 | pay_item_id = '000' |
---|
[11846] | 181 | |
---|
[11868] | 182 | def update(self): |
---|
[12975] | 183 | error = self.init_update() |
---|
[13376] | 184 | |
---|
[12975] | 185 | if error: |
---|
| 186 | self.flash(error, type='danger') |
---|
| 187 | self.redirect(self.url(self.context, '@@index')) |
---|
| 188 | return |
---|
[13400] | 189 | |
---|
[11868] | 190 | student = self.student |
---|
[13408] | 191 | p_session = self.context.p_session |
---|
[13400] | 192 | try: |
---|
[13408] | 193 | academic_session = grok.getSite()['configuration'][str(p_session)] |
---|
[13400] | 194 | except KeyError: |
---|
[13407] | 195 | self.flash(_(u'Session configuration object is not available.'), |
---|
| 196 | type='danger') |
---|
[13400] | 197 | self.redirect(self.url(self.context, '@@index')) |
---|
| 198 | return |
---|
[13532] | 199 | if contr_agreement_student(student) == 'first': |
---|
[13382] | 200 | self.product_id = PRODUCT_ID_PT |
---|
[13606] | 201 | self.mac = MAC_PT |
---|
[13382] | 202 | else: |
---|
| 203 | self.product_id = PRODUCT_ID_REGULAR |
---|
[13606] | 204 | self.mac = MAC_REGULAR |
---|
[13382] | 205 | |
---|
[12975] | 206 | # To guarantee that cleared students pay both acceptance fee |
---|
| 207 | # and school fees, the page can only be accessed |
---|
| 208 | # for school fee payments if acceptance/clearance fee has |
---|
| 209 | # been successfully queried/paid beforehand. This |
---|
| 210 | # requirement applies to students in state 'cleared' and |
---|
[14380] | 211 | # entry_session greater than 2012 only. |
---|
[13400] | 212 | if self.context.p_category.startswith('schoolfee') and \ |
---|
[12975] | 213 | student.state == CLEARED and \ |
---|
| 214 | student.entry_session > 2012: |
---|
| 215 | acceptance_fee_paid = False |
---|
| 216 | for ticket in student['payments'].values(): |
---|
| 217 | if ticket.p_state == 'paid' and \ |
---|
[13400] | 218 | ticket.p_category.startswith('clearance'): |
---|
[12975] | 219 | acceptance_fee_paid = True |
---|
| 220 | break |
---|
| 221 | if not acceptance_fee_paid: |
---|
| 222 | self.flash( |
---|
| 223 | _('Please pay acceptance fee first.'), type="danger") |
---|
| 224 | self.redirect(self.url(self.context, '@@index')) |
---|
| 225 | return |
---|
| 226 | |
---|
[11868] | 227 | xmldict = self.xmldict |
---|
[12729] | 228 | xmltext = "" |
---|
[14945] | 229 | xmldict['institution_acct'] = '1010827641' |
---|
| 230 | xmldict['institution_bank_id'] = '117' |
---|
[11868] | 231 | xmldict['detail_ref'] = self.context.p_id |
---|
| 232 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 233 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 234 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 235 | xmldict['institution_item_name'] = self.category |
---|
| 236 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
[13381] | 237 | provider_amt = 0.0 |
---|
[12729] | 238 | |
---|
[13400] | 239 | # Schoolfee |
---|
| 240 | if self.context.p_category.startswith('schoolfee'): |
---|
[13532] | 241 | if contr_agreement_student(student) == 'first': |
---|
[13403] | 242 | # First agreement |
---|
[13400] | 243 | provider_amt = 1900.0 |
---|
[15387] | 244 | joint_venture_amt = 0.0 |
---|
| 245 | aaue_share_amt = 0.0 |
---|
[13414] | 246 | student_union_due_amt = gateway_net_amt( |
---|
| 247 | academic_session.union_fee) |
---|
| 248 | student_welfare_assurance_amt = gateway_net_amt( |
---|
| 249 | academic_session.welfare_fee) |
---|
[15180] | 250 | sports_amt = gateway_net_amt( |
---|
| 251 | academic_session.sports_fee) |
---|
| 252 | library_amt = gateway_net_amt( |
---|
| 253 | academic_session.library_fee) |
---|
[15181] | 254 | library_amt_pg = gateway_net_amt( |
---|
| 255 | academic_session.library_fee_pg) |
---|
[14980] | 256 | xmldict['student_union_bank_id'] = '31' |
---|
| 257 | xmldict['student_union_acct'] = '0051005007' |
---|
[15384] | 258 | xmldict['aaue_share_bank_id'] = '117' |
---|
| 259 | xmldict['aaue_share_acct'] = '1010827641' |
---|
| 260 | xmldict['joint_venture_bank_id'] = '117' |
---|
| 261 | xmldict['joint_venture_acct'] = '1010827641' |
---|
[15359] | 262 | xmldict['institution_acct'] = '1014847058' |
---|
| 263 | xmldict['institution_bank_id'] = '7' |
---|
[13379] | 264 | if student.current_mode == 'found': |
---|
| 265 | self.pay_item_id = '103' |
---|
| 266 | else: |
---|
| 267 | self.pay_item_id = '105' |
---|
[13400] | 268 | else: |
---|
[13403] | 269 | # Second agreement |
---|
[13400] | 270 | provider_amt = 1500.0 |
---|
[15384] | 271 | joint_venture_amt = 1000.0 |
---|
| 272 | aaue_share_amt = 1500.0 |
---|
[13414] | 273 | student_union_due_amt = gateway_net_amt( |
---|
| 274 | academic_session.union_fee) |
---|
| 275 | student_welfare_assurance_amt = gateway_net_amt( |
---|
| 276 | academic_session.welfare_fee) |
---|
[15180] | 277 | sports_amt = gateway_net_amt( |
---|
| 278 | academic_session.sports_fee) |
---|
| 279 | library_amt = gateway_net_amt( |
---|
| 280 | academic_session.library_fee) |
---|
[15181] | 281 | library_amt_pg = gateway_net_amt( |
---|
| 282 | academic_session.library_fee_pg) |
---|
[14980] | 283 | xmldict['student_union_bank_id'] = '7' |
---|
| 284 | xmldict['student_union_acct'] = '1019763348' |
---|
[15384] | 285 | xmldict['aaue_share_bank_id'] = '117' |
---|
| 286 | xmldict['aaue_share_acct'] = '1010827641' |
---|
| 287 | xmldict['joint_venture_bank_id'] = '117' |
---|
| 288 | xmldict['joint_venture_acct'] = '1010827641' |
---|
[13644] | 289 | self.pay_item_id = '107' |
---|
[13527] | 290 | if student.is_postgrad: |
---|
| 291 | self.pay_item_id = '111' |
---|
[15460] | 292 | xmldict['institution_acct'] = '5210006575' |
---|
| 293 | xmldict['institution_bank_id'] = '51' |
---|
[14469] | 294 | if student.current_mode == 'ijmbe': |
---|
[14523] | 295 | self.pay_item_id = '119' |
---|
[14469] | 296 | xmldict['joint_venture_bank_id'] = '117' |
---|
[14945] | 297 | xmldict['joint_venture_acct'] = '1010827641' |
---|
[13400] | 298 | |
---|
| 299 | xmldict['provider_amt'] = 100 * provider_amt |
---|
[15384] | 300 | xmldict['joint_venture_amt'] = 100 * joint_venture_amt |
---|
| 301 | xmldict['aaue_share_amt'] = 100 * aaue_share_amt |
---|
[13732] | 302 | if self.context.p_item == 'Balance': |
---|
| 303 | xmldict['institution_amt'] = 100 * ( |
---|
| 304 | gateway_net_amt(self.context.amount_auth)) |
---|
[14987] | 305 | elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \ |
---|
| 306 | and student.current_mode != 'ijmbe': |
---|
[13400] | 307 | # Schoolfee including additional fees |
---|
[13379] | 308 | xmldict['student_union_due_amt'] = 100 * student_union_due_amt |
---|
| 309 | xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt |
---|
[15192] | 310 | |
---|
| 311 | if student.entry_session == 2018 and student.is_fresh: |
---|
| 312 | xmldict['sports_amt'] = 100 * sports_amt |
---|
| 313 | if student.is_postgrad: |
---|
| 314 | xmldict['library_amt'] = 100 * library_amt_pg |
---|
| 315 | else: |
---|
| 316 | xmldict['library_amt'] = 100 * library_amt |
---|
| 317 | xmldict['institution_amt'] = 100 * ( |
---|
| 318 | gateway_net_amt(self.context.amount_auth) |
---|
| 319 | - provider_amt |
---|
[15384] | 320 | - joint_venture_amt |
---|
| 321 | - aaue_share_amt |
---|
[15192] | 322 | - student_union_due_amt |
---|
| 323 | - student_welfare_assurance_amt |
---|
| 324 | - sports_amt |
---|
| 325 | - library_amt) |
---|
| 326 | xmltext = """<payment_item_detail> |
---|
[11868] | 327 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 328 | <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" /> |
---|
[12729] | 329 | <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" /> |
---|
[15387] | 330 | <item_detail item_id="3" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="%(student_union_bank_id)s" acct_num="%(student_union_acct)s" /> |
---|
| 331 | <item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
| 332 | <item_detail item_id="5" item_name="Sports Development Fee" item_amt="%(sports_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
| 333 | <item_detail item_id="6" item_name="Library Development Fee" item_amt="%(library_amt)d" bank_id="8" acct_num="2000122995" />""" % xmldict |
---|
| 334 | if contr_agreement_student(student) == 'second': |
---|
| 335 | xmltext += """" |
---|
| 336 | <item_detail item_id="7" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" /> |
---|
| 337 | <item_detail item_id="8" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" /> |
---|
[11868] | 338 | </item_details> |
---|
| 339 | </payment_item_detail>""" % xmldict |
---|
[15387] | 340 | else: |
---|
| 341 | xmltext += """" |
---|
| 342 | </item_details> |
---|
[15396] | 343 | </payment_item_detail>""" |
---|
[15192] | 344 | else: |
---|
| 345 | xmldict['institution_amt'] = 100 * ( |
---|
| 346 | gateway_net_amt(self.context.amount_auth) |
---|
| 347 | - provider_amt |
---|
[15384] | 348 | - joint_venture_amt |
---|
| 349 | - aaue_share_amt |
---|
[15192] | 350 | - student_union_due_amt |
---|
| 351 | - student_welfare_assurance_amt) |
---|
| 352 | xmltext = """<payment_item_detail> |
---|
| 353 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 354 | <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" /> |
---|
| 355 | <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" /> |
---|
[15387] | 356 | <item_detail item_id="3" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="%(student_union_bank_id)s" acct_num="%(student_union_acct)s" /> |
---|
| 357 | <item_detail item_id="4" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" />""" % xmldict |
---|
| 358 | if contr_agreement_student(student) == 'second': |
---|
| 359 | xmltext += """" |
---|
| 360 | <item_detail item_id="5" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" /> |
---|
| 361 | <item_detail item_id="6" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" /> |
---|
[15192] | 362 | </item_details> |
---|
| 363 | </payment_item_detail>""" % xmldict |
---|
[15387] | 364 | else: |
---|
| 365 | xmltext += """" |
---|
| 366 | </item_details> |
---|
[15396] | 367 | </payment_item_detail>""" |
---|
[15387] | 368 | elif contr_agreement_student(student) == 'second': |
---|
| 369 | # Schoolfee without Student Union Fee ands Student Welfare Assurance |
---|
[15384] | 370 | xmldict['institution_amt'] = 100 * ( |
---|
| 371 | gateway_net_amt(self.context.amount_auth) |
---|
[15387] | 372 | - provider_amt |
---|
| 373 | - joint_venture_amt |
---|
| 374 | - aaue_share_amt) |
---|
[15384] | 375 | xmltext = """<payment_item_detail> |
---|
| 376 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 377 | <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" /> |
---|
| 378 | <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" /> |
---|
[15387] | 379 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="%(joint_venture_bank_id)s" acct_num="%(joint_venture_acct)s" /> |
---|
| 380 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="%(aaue_share_bank_id)s" acct_num="%(aaue_share_acct)s" /> |
---|
[15384] | 381 | </item_details> |
---|
| 382 | </payment_item_detail>""" % xmldict |
---|
[13400] | 383 | else: |
---|
| 384 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 385 | gateway_net_amt(self.context.amount_auth) |
---|
[15387] | 386 | - provider_amt) |
---|
[13400] | 387 | xmltext = """<payment_item_detail> |
---|
| 388 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 389 | <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" /> |
---|
| 390 | <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" /> |
---|
| 391 | </item_details> |
---|
| 392 | </payment_item_detail>""" % xmldict |
---|
| 393 | |
---|
| 394 | |
---|
| 395 | # Clearance |
---|
| 396 | elif self.context.p_category.startswith('clearance'): |
---|
[15467] | 397 | provider_amt = 0.0 |
---|
[13532] | 398 | if contr_agreement_student(student) == 'first': |
---|
[13403] | 399 | # First agreement |
---|
[13379] | 400 | if student.current_mode == 'found': |
---|
| 401 | self.pay_item_id = '102' |
---|
| 402 | else: |
---|
| 403 | self.pay_item_id = '104' |
---|
[15359] | 404 | xmldict['institution_acct'] = '1014847058' |
---|
| 405 | xmldict['institution_bank_id'] = '7' |
---|
[13400] | 406 | else: |
---|
[13403] | 407 | # Second agreement |
---|
[13400] | 408 | self.pay_item_id = '102' |
---|
[13527] | 409 | if student.is_postgrad: |
---|
| 410 | self.pay_item_id = '110' |
---|
[15463] | 411 | xmldict['institution_acct'] = '5210006575' |
---|
| 412 | xmldict['institution_bank_id'] = '51' |
---|
[14469] | 413 | if student.current_mode == 'ijmbe': |
---|
[14523] | 414 | self.pay_item_id = '120' |
---|
[15467] | 415 | # ivama: Acceptance fee split is unique to "ug_ft" |
---|
| 416 | # The reason for split is perculiar to them only... |
---|
| 417 | # That amount was deducted from UTME application fee because |
---|
| 418 | # some regulatory body have pegged the application fee which |
---|
| 419 | # didn't affect another programmes. |
---|
| 420 | if student.current_mode == 'ug_ft': |
---|
| 421 | provider_amt = 1500.0 |
---|
| 422 | xmldict['provider_amt'] = 100 * provider_amt |
---|
[13410] | 423 | if self.context.p_category.endswith('_incl'): |
---|
[13400] | 424 | # Clearance including additional fees |
---|
[13414] | 425 | gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee) |
---|
| 426 | aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee) |
---|
[13379] | 427 | xmldict['gown_fee_amt'] = 100 * gown_fee_amt |
---|
[13414] | 428 | xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt |
---|
[13379] | 429 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 430 | gateway_net_amt(self.context.amount_auth) |
---|
[13409] | 431 | - gown_fee_amt |
---|
[15190] | 432 | - aaue_lf_fee_amt |
---|
| 433 | - provider_amt) |
---|
[13379] | 434 | xmltext = """<payment_item_detail> |
---|
[11868] | 435 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 436 | <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" /> |
---|
[14920] | 437 | <item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="117" acct_num="1010827641" /> |
---|
[15391] | 438 | <item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_lf_fee_amt)d" bank_id="117" acct_num="1010827641" />""" % xmldict |
---|
[15467] | 439 | if provider_amt: |
---|
[15391] | 440 | xmltext += """" |
---|
[15168] | 441 | <item_detail item_id="4" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
[11868] | 442 | </item_details> |
---|
| 443 | </payment_item_detail>""" % xmldict |
---|
[15391] | 444 | else: |
---|
| 445 | xmltext += """" |
---|
| 446 | </item_details> |
---|
[15396] | 447 | </payment_item_detail>""" |
---|
[13400] | 448 | |
---|
[15375] | 449 | elif student.current_mode == 'bridge': |
---|
| 450 | # Clearance without any surcharge |
---|
| 451 | xmldict['institution_amt'] = 100 * gateway_net_amt( |
---|
| 452 | self.context.amount_auth) |
---|
| 453 | xmltext = """<payment_item_detail> |
---|
| 454 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 455 | <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" /> |
---|
| 456 | </item_details> |
---|
| 457 | </payment_item_detail>""" % xmldict |
---|
| 458 | |
---|
[13381] | 459 | else: |
---|
[13400] | 460 | # Clearance without additional fees |
---|
[13381] | 461 | xmldict['institution_amt'] = 100 * ( |
---|
[15190] | 462 | gateway_net_amt(self.context.amount_auth) |
---|
| 463 | - provider_amt) |
---|
[15168] | 464 | xmltext = """<payment_item_detail> |
---|
| 465 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
[15396] | 466 | <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" />""" % xmldict |
---|
[15467] | 467 | if provider_amt: |
---|
[15391] | 468 | xmltext += """" |
---|
[15168] | 469 | <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" /> |
---|
| 470 | </item_details> |
---|
| 471 | </payment_item_detail>""" % xmldict |
---|
[15391] | 472 | else: |
---|
| 473 | xmltext += """" |
---|
| 474 | </item_details> |
---|
[15396] | 475 | </payment_item_detail>""" |
---|
[13379] | 476 | |
---|
[13403] | 477 | # Union Dues |
---|
[13400] | 478 | elif self.context.p_category == 'union': |
---|
| 479 | self.pay_item_id = '103' |
---|
| 480 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 481 | gateway_net_amt(self.context.amount_auth)) |
---|
[14980] | 482 | if contr_agreement_student(student) == 'first': |
---|
| 483 | # First agreement |
---|
| 484 | xmldict['institution_acct'] = '0051005007' |
---|
| 485 | xmldict['institution_bank_id'] = '31' |
---|
| 486 | else: |
---|
| 487 | # Second agreement |
---|
| 488 | xmldict['institution_bank_id'] = '7' |
---|
| 489 | xmldict['institution_acct'] = '1019763348' |
---|
[13379] | 490 | |
---|
[13403] | 491 | # Lapel/File |
---|
[13400] | 492 | elif self.context.p_category == 'lapel': |
---|
| 493 | self.pay_item_id = '104' |
---|
| 494 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 495 | gateway_net_amt(self.context.amount_auth)) |
---|
[13381] | 496 | |
---|
[13403] | 497 | # Welfare Assurance |
---|
[13400] | 498 | elif self.context.p_category == 'welfare': |
---|
| 499 | self.pay_item_id = '105' |
---|
[14979] | 500 | xmldict['institution_acct'] = '1006407792' |
---|
| 501 | xmldict['institution_bank_id'] = '123' |
---|
[13400] | 502 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 503 | gateway_net_amt(self.context.amount_auth)) |
---|
[13381] | 504 | |
---|
[14234] | 505 | # ID Card |
---|
| 506 | elif self.context.p_category == 'id_card': |
---|
| 507 | self.pay_item_id = '000' |
---|
| 508 | xmldict['institution_amt'] = 100 * ( |
---|
| 509 | gateway_net_amt(self.context.amount_auth)) |
---|
| 510 | |
---|
[13400] | 511 | # Matric Gown |
---|
| 512 | elif self.context.p_category == 'matric_gown': |
---|
| 513 | self.pay_item_id = '106' |
---|
| 514 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 515 | gateway_net_amt(self.context.amount_auth)) |
---|
[13381] | 516 | |
---|
[13400] | 517 | # Concessional |
---|
| 518 | elif self.context.p_category == 'concessional': |
---|
| 519 | self.pay_item_id = '107' |
---|
| 520 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 521 | gateway_net_amt(self.context.amount_auth)) |
---|
[13381] | 522 | |
---|
[13400] | 523 | # Hostel Maintenance |
---|
| 524 | elif self.context.p_category == 'hostel_maintenance': |
---|
[14223] | 525 | provider_amt = 500.0 |
---|
[13400] | 526 | self.pay_item_id = '109' |
---|
[14223] | 527 | xmldict['provider_amt'] = 100 * provider_amt |
---|
[13400] | 528 | xmldict['institution_amt'] = 100 * ( |
---|
[14223] | 529 | gateway_net_amt(self.context.amount_auth) - provider_amt) |
---|
[13400] | 530 | xmltext = """<payment_item_detail> |
---|
[13383] | 531 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 532 | <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" /> |
---|
[14223] | 533 | <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" /> |
---|
[13383] | 534 | </item_details> |
---|
| 535 | </payment_item_detail>""" % xmldict |
---|
| 536 | |
---|
[14258] | 537 | # GST Fees |
---|
| 538 | elif self.context.p_category.startswith('gst_'): |
---|
[14687] | 539 | if contr_agreement_student(student) == 'first': |
---|
| 540 | self.pay_item_id = '115' |
---|
| 541 | else: |
---|
| 542 | self.pay_item_id = '116' |
---|
[14979] | 543 | xmldict['institution_acct'] = '1010893123' |
---|
| 544 | xmldict['institution_bank_id'] = '117' |
---|
[14258] | 545 | xmldict['institution_amt'] = 100 * ( |
---|
| 546 | gateway_net_amt(self.context.amount_auth)) |
---|
| 547 | |
---|
| 548 | # ENT Fees |
---|
| 549 | elif self.context.p_category.startswith('ent_'): |
---|
[14687] | 550 | if contr_agreement_student(student) == 'first': |
---|
| 551 | self.pay_item_id = '114' |
---|
| 552 | else: |
---|
| 553 | self.pay_item_id = '118' |
---|
[14979] | 554 | xmldict['institution_acct'] = '6220029828' |
---|
| 555 | xmldict['institution_bank_id'] = '51' |
---|
[14258] | 556 | xmldict['institution_amt'] = 100 * ( |
---|
| 557 | gateway_net_amt(self.context.amount_auth)) |
---|
| 558 | |
---|
| 559 | # Faculty and Departmental Dues |
---|
| 560 | elif self.context.p_category == 'fac_dep': |
---|
| 561 | self.pay_item_id = '117' |
---|
| 562 | xmldict['institution_amt'] = 100 * ( |
---|
| 563 | gateway_net_amt(self.context.amount_auth)) |
---|
| 564 | |
---|
[14376] | 565 | # Restitution Fee |
---|
| 566 | elif self.context.p_category == 'restitution': |
---|
| 567 | self.pay_item_id = '117' |
---|
| 568 | xmldict['institution_amt'] = 100 * ( |
---|
| 569 | gateway_net_amt(self.context.amount_auth)) |
---|
| 570 | |
---|
[14676] | 571 | # Late Registration Fee |
---|
| 572 | elif self.context.p_category == 'late_registration': |
---|
[14686] | 573 | if contr_agreement_student(student) == 'first': |
---|
| 574 | self.pay_item_id = '113' |
---|
| 575 | else: |
---|
| 576 | self.pay_item_id = '123' |
---|
[14676] | 577 | xmldict['institution_amt'] = 100 * ( |
---|
| 578 | gateway_net_amt(self.context.amount_auth)) |
---|
[15463] | 579 | if student.is_postgrad: |
---|
| 580 | xmldict['institution_acct'] = '5210006575' |
---|
| 581 | xmldict['institution_bank_id'] = '51' |
---|
[14945] | 582 | if not xmltext: |
---|
[14676] | 583 | xmltext = """<payment_item_detail> |
---|
| 584 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 585 | <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" /> |
---|
| 586 | </item_details> |
---|
| 587 | </payment_item_detail>""" % xmldict |
---|
[11868] | 588 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 589 | self.context.provider_amt = provider_amt |
---|
[13437] | 590 | self.context.gateway_amt = self.amount_auth - gateway_net_amt( |
---|
| 591 | self.amount_auth) |
---|
[11868] | 592 | hashargs = ( |
---|
| 593 | self.context.p_id + |
---|
[13382] | 594 | self.product_id + |
---|
[11868] | 595 | self.pay_item_id + |
---|
| 596 | str(int(self.amount_auth)) + |
---|
| 597 | self.site_redirect_url + |
---|
| 598 | self.mac) |
---|
| 599 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 600 | return |
---|
| 601 | |
---|
| 602 | |
---|
[11846] | 603 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
| 604 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
[13586] | 605 | """Request webservice view for the CollegePAY gateway |
---|
| 606 | """ |
---|
| 607 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 608 | gateway_host = HOST |
---|
| 609 | gateway_url = URL |
---|
| 610 | https = HTTPS |
---|
[13379] | 611 | |
---|
[13586] | 612 | @property |
---|
[13606] | 613 | def mac(self): |
---|
| 614 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 615 | return MAC_PT |
---|
| 616 | return MAC_REGULAR |
---|
| 617 | |
---|
| 618 | @property |
---|
[13586] | 619 | def product_id(self): |
---|
| 620 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 621 | return PRODUCT_ID_PT |
---|
| 622 | return PRODUCT_ID_REGULAR |
---|
| 623 | |
---|
| 624 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
| 625 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
| 626 | """Payment verify view for the CollegePAY gateway |
---|
[11846] | 627 | """ |
---|
| 628 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 629 | gateway_host = HOST |
---|
[13586] | 630 | gateway_url = URL |
---|
[11916] | 631 | https = HTTPS |
---|
[11868] | 632 | |
---|
[13532] | 633 | @property |
---|
[13606] | 634 | def mac(self): |
---|
| 635 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 636 | return MAC_PT |
---|
| 637 | return MAC_REGULAR |
---|
| 638 | |
---|
| 639 | @property |
---|
[13532] | 640 | def product_id(self): |
---|
| 641 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 642 | return PRODUCT_ID_PT |
---|
| 643 | return PRODUCT_ID_REGULAR |
---|
| 644 | |
---|
[11868] | 645 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
| 646 | InterswitchPaymentRequestWebservicePageStudent): |
---|
[13586] | 647 | """Request webservice view for the CollegePAY gateway |
---|
[11868] | 648 | """ |
---|
| 649 | grok.context(ICustomStudentOnlinePayment) |
---|
| 650 | gateway_host = HOST |
---|
[13586] | 651 | gateway_url = URL |
---|
[11916] | 652 | https = HTTPS |
---|
[13379] | 653 | |
---|
| 654 | @property |
---|
[13606] | 655 | def mac(self): |
---|
| 656 | if contr_agreement_student(self.context.student) == 'first': |
---|
| 657 | return MAC_PT |
---|
| 658 | return MAC_REGULAR |
---|
| 659 | |
---|
| 660 | @property |
---|
[13379] | 661 | def product_id(self): |
---|
[13532] | 662 | if contr_agreement_student(self.context.student) == 'first': |
---|
[13379] | 663 | return PRODUCT_ID_PT |
---|
| 664 | return PRODUCT_ID_REGULAR |
---|
[13586] | 665 | |
---|
| 666 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
| 667 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
| 668 | """Payment verify view for the CollegePAY gateway |
---|
| 669 | """ |
---|
| 670 | grok.context(ICustomStudentOnlinePayment) |
---|
| 671 | gateway_host = HOST |
---|
| 672 | gateway_url = URL |
---|
| 673 | https = HTTPS |
---|
| 674 | |
---|
| 675 | @property |
---|
[13606] | 676 | def mac(self): |
---|
| 677 | if contr_agreement_student(self.context.student) == 'first': |
---|
| 678 | return MAC_PT |
---|
| 679 | return MAC_REGULAR |
---|
| 680 | |
---|
| 681 | @property |
---|
[13586] | 682 | def product_id(self): |
---|
| 683 | if contr_agreement_student(self.context.student) == 'first': |
---|
| 684 | return PRODUCT_ID_PT |
---|
| 685 | return PRODUCT_ID_REGULAR |
---|