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