[12730] | 1 | ## $Id: browser.py 14122 2016-08-24 06:13:46Z 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' |
---|
[13397] | 38 | PROVIDER_ACCT = '2022866811' |
---|
| 39 | PROVIDER_BANK_ID = '8' |
---|
[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 |
---|
[13532] | 169 | #pay_item_id = '101' |
---|
[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' |
---|
[13379] | 246 | if student.current_mode == 'found': |
---|
| 247 | self.pay_item_id = '103' |
---|
| 248 | else: |
---|
| 249 | self.pay_item_id = '105' |
---|
[13400] | 250 | else: |
---|
[13403] | 251 | # Second agreement |
---|
[13400] | 252 | provider_amt = 1500.0 |
---|
| 253 | joint_venture_amt = 1000.0 |
---|
| 254 | aaue_share_amt = 1500.0 |
---|
[13414] | 255 | student_union_due_amt = gateway_net_amt( |
---|
| 256 | academic_session.union_fee) |
---|
| 257 | student_welfare_assurance_amt = gateway_net_amt( |
---|
| 258 | academic_session.welfare_fee) |
---|
[13400] | 259 | xmldict['institution_bank_id'] = '117' |
---|
| 260 | xmldict['institution_acct'] = '1010827641' |
---|
[14086] | 261 | xmldict['student_union_bank_id'] = '123' |
---|
| 262 | xmldict['student_union_acct'] = '1006360118' |
---|
[13644] | 263 | self.pay_item_id = '107' |
---|
[13527] | 264 | if student.is_postgrad: |
---|
| 265 | xmldict['institution_bank_id'] = '51' |
---|
| 266 | xmldict['institution_acct'] = '5210006575' |
---|
| 267 | self.pay_item_id = '111' |
---|
[13400] | 268 | |
---|
| 269 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 270 | xmldict['joint_venture_amt'] = 100 * joint_venture_amt |
---|
| 271 | xmldict['aaue_share_amt'] = 100 * aaue_share_amt |
---|
[13732] | 272 | if self.context.p_item == 'Balance': |
---|
| 273 | xmldict['institution_amt'] = 100 * ( |
---|
| 274 | gateway_net_amt(self.context.amount_auth)) |
---|
| 275 | xmltext = """<payment_item_detail> |
---|
| 276 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 277 | <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" /> |
---|
| 278 | </item_details> |
---|
| 279 | </payment_item_detail>""" % xmldict |
---|
| 280 | elif self.context.p_category in ('schoolfee_incl', 'schoolfee_1'): |
---|
[13400] | 281 | # Schoolfee including additional fees |
---|
[13379] | 282 | xmldict['student_union_due_amt'] = 100 * student_union_due_amt |
---|
| 283 | xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt |
---|
| 284 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 285 | gateway_net_amt(self.context.amount_auth) |
---|
[13379] | 286 | - provider_amt |
---|
| 287 | - joint_venture_amt |
---|
| 288 | - aaue_share_amt |
---|
[13409] | 289 | - student_union_due_amt |
---|
[13414] | 290 | - student_welfare_assurance_amt) |
---|
[13379] | 291 | xmltext = """<payment_item_detail> |
---|
[11868] | 292 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 293 | <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] | 294 | <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" /> |
---|
| 295 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="51" acct_num="5060023759" /> |
---|
| 296 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
[14086] | 297 | <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] | 298 | <item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="123" acct_num="1006407792" /> |
---|
[11868] | 299 | </item_details> |
---|
| 300 | </payment_item_detail>""" % xmldict |
---|
[13400] | 301 | else: |
---|
| 302 | # Schoolfee without additional fees |
---|
| 303 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 304 | gateway_net_amt(self.context.amount_auth) |
---|
[13400] | 305 | - provider_amt |
---|
| 306 | - joint_venture_amt |
---|
[13414] | 307 | - aaue_share_amt) |
---|
[13400] | 308 | xmltext = """<payment_item_detail> |
---|
| 309 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 310 | <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" /> |
---|
| 311 | <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" /> |
---|
| 312 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="51" acct_num="5060023759" /> |
---|
| 313 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
| 314 | </item_details> |
---|
| 315 | </payment_item_detail>""" % xmldict |
---|
| 316 | |
---|
| 317 | |
---|
| 318 | # Clearance |
---|
| 319 | elif self.context.p_category.startswith('clearance'): |
---|
[13532] | 320 | if contr_agreement_student(student) == 'first': |
---|
[13403] | 321 | # First agreement |
---|
[13379] | 322 | if student.current_mode == 'found': |
---|
| 323 | self.pay_item_id = '102' |
---|
| 324 | else: |
---|
| 325 | self.pay_item_id = '104' |
---|
| 326 | xmldict['institution_acct'] = '1014066976' |
---|
| 327 | xmldict['institution_bank_id'] = '117' |
---|
[13400] | 328 | else: |
---|
[13403] | 329 | # Second agreement |
---|
[13400] | 330 | self.pay_item_id = '102' |
---|
| 331 | xmldict['institution_acct'] = '1010827641' |
---|
| 332 | xmldict['institution_bank_id'] = '117' |
---|
[13527] | 333 | if student.is_postgrad: |
---|
| 334 | xmldict['institution_bank_id'] = '51' |
---|
| 335 | xmldict['institution_acct'] = '5210006575' |
---|
| 336 | self.pay_item_id = '110' |
---|
[13400] | 337 | |
---|
[13410] | 338 | if self.context.p_category.endswith('_incl'): |
---|
[13400] | 339 | # Clearance including additional fees |
---|
[13414] | 340 | gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee) |
---|
| 341 | aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee) |
---|
[13379] | 342 | xmldict['gown_fee_amt'] = 100 * gown_fee_amt |
---|
[13414] | 343 | xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt |
---|
[13379] | 344 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 345 | gateway_net_amt(self.context.amount_auth) |
---|
[13409] | 346 | - gown_fee_amt |
---|
[13414] | 347 | - aaue_lf_fee_amt) |
---|
[13379] | 348 | xmltext = """<payment_item_detail> |
---|
[11868] | 349 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 350 | <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] | 351 | <item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
[13414] | 352 | <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] | 353 | </item_details> |
---|
| 354 | </payment_item_detail>""" % xmldict |
---|
[13400] | 355 | |
---|
[13381] | 356 | else: |
---|
[13400] | 357 | # Clearance without additional fees |
---|
[13381] | 358 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 359 | gateway_net_amt(self.context.amount_auth)) |
---|
[13381] | 360 | xmltext = """<payment_item_detail> |
---|
| 361 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 362 | <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" /> |
---|
| 363 | </item_details> |
---|
| 364 | </payment_item_detail>""" % xmldict |
---|
[13379] | 365 | |
---|
[13403] | 366 | # Union Dues |
---|
[13400] | 367 | elif self.context.p_category == 'union': |
---|
| 368 | self.pay_item_id = '103' |
---|
[14086] | 369 | if contr_agreement_student(student) == 'first': |
---|
| 370 | # First agreement |
---|
[14088] | 371 | xmldict['institution_acct'] = '0051005007' |
---|
| 372 | xmldict['institution_bank_id'] = '31' |
---|
| 373 | else: |
---|
| 374 | # Second agreement |
---|
[14086] | 375 | xmldict['institution_bank_id'] = '123' |
---|
| 376 | xmldict['institution_acct'] = '1006360118' |
---|
[13400] | 377 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 378 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 379 | xmltext = """<payment_item_detail> |
---|
[13381] | 380 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 381 | <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" /> |
---|
| 382 | </item_details> |
---|
| 383 | </payment_item_detail>""" % xmldict |
---|
[13379] | 384 | |
---|
[13403] | 385 | # Lapel/File |
---|
[13400] | 386 | elif self.context.p_category == 'lapel': |
---|
| 387 | self.pay_item_id = '104' |
---|
| 388 | xmldict['institution_acct'] = '4010660109' |
---|
| 389 | xmldict['institution_bank_id'] = '51' |
---|
| 390 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 391 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 392 | xmltext = """<payment_item_detail> |
---|
[13381] | 393 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 394 | <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" /> |
---|
| 395 | </item_details> |
---|
| 396 | </payment_item_detail>""" % xmldict |
---|
| 397 | |
---|
[13403] | 398 | # Welfare Assurance |
---|
[13400] | 399 | elif self.context.p_category == 'welfare': |
---|
| 400 | self.pay_item_id = '105' |
---|
| 401 | xmldict['institution_acct'] = '1006407792' |
---|
| 402 | xmldict['institution_bank_id'] = '123' |
---|
| 403 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 404 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 405 | xmltext = """<payment_item_detail> |
---|
[13381] | 406 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 407 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 408 | </item_details> |
---|
| 409 | </payment_item_detail>""" % xmldict |
---|
| 410 | |
---|
[13400] | 411 | # Matric Gown |
---|
| 412 | elif self.context.p_category == 'matric_gown': |
---|
| 413 | self.pay_item_id = '106' |
---|
| 414 | xmldict['institution_acct'] = '5060023429' |
---|
| 415 | xmldict['institution_bank_id'] = '51' |
---|
| 416 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 417 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 418 | xmltext = """<payment_item_detail> |
---|
[13381] | 419 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 420 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 421 | </item_details> |
---|
| 422 | </payment_item_detail>""" % xmldict |
---|
| 423 | |
---|
[13400] | 424 | # Concessional |
---|
| 425 | elif self.context.p_category == 'concessional': |
---|
| 426 | self.pay_item_id = '107' |
---|
| 427 | xmldict['institution_acct'] = '1010835352' |
---|
| 428 | xmldict['institution_bank_id'] = '117' |
---|
| 429 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 430 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 431 | xmltext = """<payment_item_detail> |
---|
[13381] | 432 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 433 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 434 | </item_details> |
---|
| 435 | </payment_item_detail>""" % xmldict |
---|
| 436 | |
---|
[13400] | 437 | # Hostel Maintenance |
---|
| 438 | elif self.context.p_category == 'hostel_maintenance': |
---|
| 439 | self.pay_item_id = '109' |
---|
| 440 | xmldict['institution_acct'] = '1006406795' |
---|
| 441 | xmldict['institution_bank_id'] = '123' |
---|
| 442 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 443 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 444 | xmltext = """<payment_item_detail> |
---|
[13383] | 445 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 446 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 447 | </item_details> |
---|
| 448 | </payment_item_detail>""" % xmldict |
---|
| 449 | |
---|
[11868] | 450 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 451 | self.context.provider_amt = provider_amt |
---|
[13437] | 452 | self.context.gateway_amt = self.amount_auth - gateway_net_amt( |
---|
| 453 | self.amount_auth) |
---|
[11868] | 454 | hashargs = ( |
---|
| 455 | self.context.p_id + |
---|
[13382] | 456 | self.product_id + |
---|
[11868] | 457 | self.pay_item_id + |
---|
| 458 | str(int(self.amount_auth)) + |
---|
| 459 | self.site_redirect_url + |
---|
| 460 | self.mac) |
---|
| 461 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 462 | return |
---|
| 463 | |
---|
| 464 | |
---|
[11846] | 465 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
| 466 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
[13586] | 467 | """Request webservice view for the CollegePAY gateway |
---|
| 468 | """ |
---|
| 469 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 470 | gateway_host = HOST |
---|
| 471 | gateway_url = URL |
---|
| 472 | https = HTTPS |
---|
[13379] | 473 | |
---|
[13586] | 474 | @property |
---|
[13606] | 475 | def mac(self): |
---|
| 476 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 477 | return MAC_PT |
---|
| 478 | return MAC_REGULAR |
---|
| 479 | |
---|
| 480 | @property |
---|
[13586] | 481 | def product_id(self): |
---|
| 482 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 483 | return PRODUCT_ID_PT |
---|
| 484 | return PRODUCT_ID_REGULAR |
---|
| 485 | |
---|
| 486 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
| 487 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
| 488 | """Payment verify view for the CollegePAY gateway |
---|
[11846] | 489 | """ |
---|
| 490 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 491 | gateway_host = HOST |
---|
[13586] | 492 | gateway_url = URL |
---|
[11916] | 493 | https = HTTPS |
---|
[11868] | 494 | |
---|
[13532] | 495 | @property |
---|
[13606] | 496 | def mac(self): |
---|
| 497 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 498 | return MAC_PT |
---|
| 499 | return MAC_REGULAR |
---|
| 500 | |
---|
| 501 | @property |
---|
[13532] | 502 | def product_id(self): |
---|
| 503 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 504 | return PRODUCT_ID_PT |
---|
| 505 | return PRODUCT_ID_REGULAR |
---|
| 506 | |
---|
[11868] | 507 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
| 508 | InterswitchPaymentRequestWebservicePageStudent): |
---|
[13586] | 509 | """Request webservice view for the CollegePAY gateway |
---|
[11868] | 510 | """ |
---|
| 511 | grok.context(ICustomStudentOnlinePayment) |
---|
| 512 | gateway_host = HOST |
---|
[13586] | 513 | gateway_url = URL |
---|
[11916] | 514 | https = HTTPS |
---|
[13379] | 515 | |
---|
| 516 | @property |
---|
[13606] | 517 | def mac(self): |
---|
| 518 | if contr_agreement_student(self.context.student) == 'first': |
---|
| 519 | return MAC_PT |
---|
| 520 | return MAC_REGULAR |
---|
| 521 | |
---|
| 522 | @property |
---|
[13379] | 523 | def product_id(self): |
---|
[13532] | 524 | if contr_agreement_student(self.context.student) == 'first': |
---|
[13379] | 525 | return PRODUCT_ID_PT |
---|
| 526 | return PRODUCT_ID_REGULAR |
---|
[13586] | 527 | |
---|
| 528 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
| 529 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
| 530 | """Payment verify view for the CollegePAY gateway |
---|
| 531 | """ |
---|
| 532 | grok.context(ICustomStudentOnlinePayment) |
---|
| 533 | gateway_host = HOST |
---|
| 534 | gateway_url = URL |
---|
| 535 | https = HTTPS |
---|
| 536 | |
---|
| 537 | @property |
---|
[13606] | 538 | def mac(self): |
---|
| 539 | if contr_agreement_student(self.context.student) == 'first': |
---|
| 540 | return MAC_PT |
---|
| 541 | return MAC_REGULAR |
---|
| 542 | |
---|
| 543 | @property |
---|
[13586] | 544 | def product_id(self): |
---|
| 545 | if contr_agreement_student(self.context.student) == 'first': |
---|
| 546 | return PRODUCT_ID_PT |
---|
| 547 | return PRODUCT_ID_REGULAR |
---|