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