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