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