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