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