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