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