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