[12730] | 1 | ## $Id: browser.py 13586 2016-01-11 08:58:32Z 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 |
---|
[13586] | 49 | MAC = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023' |
---|
[11846] | 50 | |
---|
[11917] | 51 | httplib.HTTPSConnection.debuglevel = 0 |
---|
[11846] | 52 | |
---|
[13379] | 53 | |
---|
[13414] | 54 | def gateway_net_amt(fee): |
---|
[13438] | 55 | if fee > GATEWAY_AMT: |
---|
[13414] | 56 | return fee - GATEWAY_AMT |
---|
[13438] | 57 | return 0.0 |
---|
[13406] | 58 | |
---|
[13532] | 59 | def contr_agreement_applicant(applicant): |
---|
| 60 | if applicant.__parent__.code[:2] in ('fp', 'pt'): |
---|
| 61 | return 'first' |
---|
| 62 | return 'second' |
---|
| 63 | |
---|
| 64 | def contr_agreement_student(student): |
---|
[13379] | 65 | if student.current_mode == 'found' or student.current_mode.endswith('_pt'): |
---|
[13403] | 66 | return 'first' |
---|
| 67 | return 'second' |
---|
[13379] | 68 | |
---|
[11846] | 69 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
| 70 | """ View which sends a POST request to the Interswitch |
---|
| 71 | CollegePAY payment gateway. |
---|
[13379] | 72 | |
---|
| 73 | So far only PT application has been configured. |
---|
[11846] | 74 | """ |
---|
| 75 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 76 | action = POST_ACTION |
---|
| 77 | site_name = SITE_NAME |
---|
| 78 | currency = CURRENCY |
---|
[13586] | 79 | mac = MAC |
---|
[11846] | 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' |
---|
| 91 | else: |
---|
| 92 | self.product_id = PRODUCT_ID_REGULAR |
---|
| 93 | self.pay_item_id = '109' |
---|
[11846] | 94 | xmldict = {} |
---|
| 95 | provider_amt = 1000.0 |
---|
| 96 | xmldict['institution_acct'] = '1010835352' |
---|
| 97 | xmldict['institution_bank_id'] = '117' |
---|
| 98 | xmldict['detail_ref'] = self.context.p_id |
---|
| 99 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 100 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 101 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 102 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
[13414] | 103 | xmldict['institution_amt'] = 100 * ( |
---|
| 104 | self.context.amount_auth - provider_amt - GATEWAY_AMT) |
---|
[13532] | 105 | xmldict['institution_item_name'] = self.category |
---|
[11846] | 106 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
| 107 | # Interswitch amount is not part of the xml data |
---|
| 108 | xmltext = """<payment_item_detail> |
---|
| 109 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 110 | <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" /> |
---|
| 111 | <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" /> |
---|
| 112 | </item_details> |
---|
| 113 | </payment_item_detail>""" % xmldict |
---|
| 114 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 115 | self.context.provider_amt = provider_amt |
---|
| 116 | self.context.gateway_amt = GATEWAY_AMT |
---|
| 117 | |
---|
| 118 | hashargs = ( |
---|
| 119 | self.context.p_id + |
---|
[13532] | 120 | self.product_id + |
---|
[11846] | 121 | self.pay_item_id + |
---|
| 122 | str(int(self.amount_auth)) + |
---|
| 123 | self.site_redirect_url + |
---|
| 124 | self.mac) |
---|
| 125 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 126 | |
---|
| 127 | return |
---|
| 128 | |
---|
[11868] | 129 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
| 130 | """ View which sends a POST request to the Interswitch |
---|
| 131 | CollegePAY payment gateway. |
---|
| 132 | """ |
---|
| 133 | grok.context(ICustomStudentOnlinePayment) |
---|
| 134 | action = POST_ACTION |
---|
| 135 | site_name = SITE_NAME |
---|
| 136 | currency = CURRENCY |
---|
[13532] | 137 | #pay_item_id = '101' |
---|
[13586] | 138 | mac = MAC |
---|
[11846] | 139 | |
---|
[11868] | 140 | def update(self): |
---|
[12975] | 141 | error = self.init_update() |
---|
[13376] | 142 | |
---|
| 143 | ###################################### |
---|
[13381] | 144 | #error = 'Sorry, Interswitch payments are temporarily disabled.' |
---|
[13376] | 145 | ###################################### |
---|
| 146 | |
---|
[12975] | 147 | if error: |
---|
| 148 | self.flash(error, type='danger') |
---|
| 149 | self.redirect(self.url(self.context, '@@index')) |
---|
| 150 | return |
---|
[13400] | 151 | |
---|
[11868] | 152 | student = self.student |
---|
[13408] | 153 | p_session = self.context.p_session |
---|
[13400] | 154 | try: |
---|
[13408] | 155 | academic_session = grok.getSite()['configuration'][str(p_session)] |
---|
[13400] | 156 | except KeyError: |
---|
[13407] | 157 | self.flash(_(u'Session configuration object is not available.'), |
---|
| 158 | type='danger') |
---|
[13400] | 159 | self.redirect(self.url(self.context, '@@index')) |
---|
| 160 | return |
---|
[13532] | 161 | if contr_agreement_student(student) == 'first': |
---|
[13382] | 162 | self.product_id = PRODUCT_ID_PT |
---|
| 163 | else: |
---|
| 164 | self.product_id = PRODUCT_ID_REGULAR |
---|
| 165 | |
---|
[12975] | 166 | # To guarantee that cleared students pay both acceptance fee |
---|
| 167 | # and school fees, the page can only be accessed |
---|
| 168 | # for school fee payments if acceptance/clearance fee has |
---|
| 169 | # been successfully queried/paid beforehand. This |
---|
| 170 | # requirement applies to students in state 'cleared' and |
---|
| 171 | # entry_session greater than 2013 only. |
---|
[13400] | 172 | if self.context.p_category.startswith('schoolfee') and \ |
---|
[12975] | 173 | student.state == CLEARED and \ |
---|
| 174 | student.entry_session > 2012: |
---|
| 175 | acceptance_fee_paid = False |
---|
| 176 | for ticket in student['payments'].values(): |
---|
| 177 | if ticket.p_state == 'paid' and \ |
---|
[13400] | 178 | ticket.p_category.startswith('clearance'): |
---|
[12975] | 179 | acceptance_fee_paid = True |
---|
| 180 | break |
---|
| 181 | if not acceptance_fee_paid: |
---|
| 182 | self.flash( |
---|
| 183 | _('Please pay acceptance fee first.'), type="danger") |
---|
| 184 | self.redirect(self.url(self.context, '@@index')) |
---|
| 185 | return |
---|
| 186 | |
---|
[11868] | 187 | xmldict = self.xmldict |
---|
[12729] | 188 | xmltext = "" |
---|
[11868] | 189 | # Provider data |
---|
| 190 | xmldict['detail_ref'] = self.context.p_id |
---|
| 191 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 192 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 193 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 194 | xmldict['institution_item_name'] = self.category |
---|
| 195 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
[13381] | 196 | provider_amt = 0.0 |
---|
[12729] | 197 | |
---|
[13400] | 198 | # Schoolfee |
---|
| 199 | if self.context.p_category.startswith('schoolfee'): |
---|
[13532] | 200 | if contr_agreement_student(student) == 'first': |
---|
[13403] | 201 | # First agreement |
---|
[13400] | 202 | provider_amt = 1900.0 |
---|
| 203 | joint_venture_amt = 1100.0 |
---|
| 204 | aaue_share_amt = 1000.0 |
---|
[13414] | 205 | student_union_due_amt = gateway_net_amt( |
---|
| 206 | academic_session.union_fee) |
---|
| 207 | student_welfare_assurance_amt = gateway_net_amt( |
---|
| 208 | academic_session.welfare_fee) |
---|
[13379] | 209 | xmldict['institution_bank_id'] = '7' |
---|
| 210 | xmldict['institution_acct'] = '1014847058' |
---|
| 211 | if student.current_mode == 'found': |
---|
| 212 | self.pay_item_id = '103' |
---|
| 213 | else: |
---|
| 214 | self.pay_item_id = '105' |
---|
[13400] | 215 | else: |
---|
[13403] | 216 | # Second agreement |
---|
[13400] | 217 | provider_amt = 1500.0 |
---|
| 218 | joint_venture_amt = 1000.0 |
---|
| 219 | aaue_share_amt = 1500.0 |
---|
[13414] | 220 | student_union_due_amt = gateway_net_amt( |
---|
| 221 | academic_session.union_fee) |
---|
| 222 | student_welfare_assurance_amt = gateway_net_amt( |
---|
| 223 | academic_session.welfare_fee) |
---|
[13400] | 224 | xmldict['institution_bank_id'] = '117' |
---|
| 225 | xmldict['institution_acct'] = '1010827641' |
---|
| 226 | self.pay_item_id = '101' |
---|
[13527] | 227 | if student.is_postgrad: |
---|
| 228 | xmldict['institution_bank_id'] = '51' |
---|
| 229 | xmldict['institution_acct'] = '5210006575' |
---|
| 230 | self.pay_item_id = '111' |
---|
[13400] | 231 | |
---|
| 232 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 233 | xmldict['joint_venture_amt'] = 100 * joint_venture_amt |
---|
| 234 | xmldict['aaue_share_amt'] = 100 * aaue_share_amt |
---|
[13512] | 235 | if self.context.p_category in ('schoolfee_incl', 'schoolfee_1'): |
---|
[13400] | 236 | # Schoolfee including additional fees |
---|
[13379] | 237 | xmldict['student_union_due_amt'] = 100 * student_union_due_amt |
---|
| 238 | xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt |
---|
| 239 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 240 | gateway_net_amt(self.context.amount_auth) |
---|
[13379] | 241 | - provider_amt |
---|
| 242 | - joint_venture_amt |
---|
| 243 | - aaue_share_amt |
---|
[13409] | 244 | - student_union_due_amt |
---|
[13414] | 245 | - student_welfare_assurance_amt) |
---|
[13379] | 246 | xmltext = """<payment_item_detail> |
---|
[11868] | 247 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 248 | <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] | 249 | <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" /> |
---|
| 250 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="51" acct_num="5060023759" /> |
---|
| 251 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
| 252 | <item_detail item_id="5" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="123" acct_num="1006360118" /> |
---|
| 253 | <item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="31" acct_num="1006407792" /> |
---|
[11868] | 254 | </item_details> |
---|
| 255 | </payment_item_detail>""" % xmldict |
---|
[13400] | 256 | else: |
---|
| 257 | # Schoolfee without additional fees |
---|
| 258 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 259 | gateway_net_amt(self.context.amount_auth) |
---|
[13400] | 260 | - provider_amt |
---|
| 261 | - joint_venture_amt |
---|
[13414] | 262 | - aaue_share_amt) |
---|
[13400] | 263 | xmltext = """<payment_item_detail> |
---|
| 264 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 265 | <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" /> |
---|
| 266 | <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" /> |
---|
| 267 | <item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="51" acct_num="5060023759" /> |
---|
| 268 | <item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
| 269 | </item_details> |
---|
| 270 | </payment_item_detail>""" % xmldict |
---|
| 271 | |
---|
| 272 | |
---|
| 273 | # Clearance |
---|
| 274 | elif self.context.p_category.startswith('clearance'): |
---|
[13532] | 275 | if contr_agreement_student(student) == 'first': |
---|
[13403] | 276 | # First agreement |
---|
[13379] | 277 | if student.current_mode == 'found': |
---|
| 278 | self.pay_item_id = '102' |
---|
| 279 | else: |
---|
| 280 | self.pay_item_id = '104' |
---|
| 281 | xmldict['institution_acct'] = '1014066976' |
---|
| 282 | xmldict['institution_bank_id'] = '117' |
---|
[13400] | 283 | else: |
---|
[13403] | 284 | # Second agreement |
---|
[13400] | 285 | self.pay_item_id = '102' |
---|
| 286 | xmldict['institution_acct'] = '1010827641' |
---|
| 287 | xmldict['institution_bank_id'] = '117' |
---|
[13527] | 288 | if student.is_postgrad: |
---|
| 289 | xmldict['institution_bank_id'] = '51' |
---|
| 290 | xmldict['institution_acct'] = '5210006575' |
---|
| 291 | self.pay_item_id = '110' |
---|
[13400] | 292 | |
---|
[13410] | 293 | if self.context.p_category.endswith('_incl'): |
---|
[13400] | 294 | # Clearance including additional fees |
---|
[13414] | 295 | gown_fee_amt = gateway_net_amt(academic_session.matric_gown_fee) |
---|
| 296 | aaue_lf_fee_amt = gateway_net_amt(academic_session.lapel_fee) |
---|
[13379] | 297 | xmldict['gown_fee_amt'] = 100 * gown_fee_amt |
---|
[13414] | 298 | xmldict['aaue_lf_fee_amt'] = 100 * aaue_lf_fee_amt |
---|
[13379] | 299 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 300 | gateway_net_amt(self.context.amount_auth) |
---|
[13409] | 301 | - gown_fee_amt |
---|
[13414] | 302 | - aaue_lf_fee_amt) |
---|
[13379] | 303 | xmltext = """<payment_item_detail> |
---|
[11868] | 304 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 305 | <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] | 306 | <item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="51" acct_num="5060020947" /> |
---|
[13414] | 307 | <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] | 308 | </item_details> |
---|
| 309 | </payment_item_detail>""" % xmldict |
---|
[13400] | 310 | |
---|
[13381] | 311 | else: |
---|
[13400] | 312 | # Clearance without additional fees |
---|
[13381] | 313 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 314 | gateway_net_amt(self.context.amount_auth)) |
---|
[13381] | 315 | xmltext = """<payment_item_detail> |
---|
| 316 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 317 | <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" /> |
---|
| 318 | </item_details> |
---|
| 319 | </payment_item_detail>""" % xmldict |
---|
[13379] | 320 | |
---|
[13403] | 321 | # Union Dues |
---|
[13400] | 322 | elif self.context.p_category == 'union': |
---|
| 323 | self.pay_item_id = '103' |
---|
| 324 | xmldict['institution_acct'] = '1006360118' |
---|
| 325 | xmldict['institution_bank_id'] = '123' |
---|
| 326 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 327 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 328 | xmltext = """<payment_item_detail> |
---|
[13381] | 329 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 330 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 331 | </item_details> |
---|
| 332 | </payment_item_detail>""" % xmldict |
---|
[13379] | 333 | |
---|
[13403] | 334 | # Lapel/File |
---|
[13400] | 335 | elif self.context.p_category == 'lapel': |
---|
| 336 | self.pay_item_id = '104' |
---|
| 337 | xmldict['institution_acct'] = '4010660109' |
---|
| 338 | xmldict['institution_bank_id'] = '51' |
---|
| 339 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 340 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 341 | xmltext = """<payment_item_detail> |
---|
[13381] | 342 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 343 | <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" /> |
---|
| 344 | </item_details> |
---|
| 345 | </payment_item_detail>""" % xmldict |
---|
| 346 | |
---|
[13403] | 347 | # Welfare Assurance |
---|
[13400] | 348 | elif self.context.p_category == 'welfare': |
---|
| 349 | self.pay_item_id = '105' |
---|
| 350 | xmldict['institution_acct'] = '1006407792' |
---|
| 351 | xmldict['institution_bank_id'] = '123' |
---|
| 352 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 353 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 354 | xmltext = """<payment_item_detail> |
---|
[13381] | 355 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 356 | <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" /> |
---|
| 357 | </item_details> |
---|
| 358 | </payment_item_detail>""" % xmldict |
---|
| 359 | |
---|
[13400] | 360 | # Matric Gown |
---|
| 361 | elif self.context.p_category == 'matric_gown': |
---|
| 362 | self.pay_item_id = '106' |
---|
| 363 | xmldict['institution_acct'] = '5060023429' |
---|
| 364 | xmldict['institution_bank_id'] = '51' |
---|
| 365 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 366 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 367 | xmltext = """<payment_item_detail> |
---|
[13381] | 368 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 369 | <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" /> |
---|
| 370 | </item_details> |
---|
| 371 | </payment_item_detail>""" % xmldict |
---|
| 372 | |
---|
[13400] | 373 | # Concessional |
---|
| 374 | elif self.context.p_category == 'concessional': |
---|
| 375 | self.pay_item_id = '107' |
---|
| 376 | xmldict['institution_acct'] = '1010835352' |
---|
| 377 | xmldict['institution_bank_id'] = '117' |
---|
| 378 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 379 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 380 | xmltext = """<payment_item_detail> |
---|
[13381] | 381 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 382 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 383 | </item_details> |
---|
| 384 | </payment_item_detail>""" % xmldict |
---|
| 385 | |
---|
[13400] | 386 | # Hostel Maintenance |
---|
| 387 | elif self.context.p_category == 'hostel_maintenance': |
---|
| 388 | self.pay_item_id = '109' |
---|
| 389 | xmldict['institution_acct'] = '1006406795' |
---|
| 390 | xmldict['institution_bank_id'] = '123' |
---|
| 391 | xmldict['institution_amt'] = 100 * ( |
---|
[13414] | 392 | gateway_net_amt(self.context.amount_auth)) |
---|
[13400] | 393 | xmltext = """<payment_item_detail> |
---|
[13383] | 394 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 395 | <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" /> |
---|
| 396 | </item_details> |
---|
| 397 | </payment_item_detail>""" % xmldict |
---|
| 398 | |
---|
[11868] | 399 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 400 | self.context.provider_amt = provider_amt |
---|
[13437] | 401 | self.context.gateway_amt = self.amount_auth - gateway_net_amt( |
---|
| 402 | self.amount_auth) |
---|
[11868] | 403 | hashargs = ( |
---|
| 404 | self.context.p_id + |
---|
[13382] | 405 | self.product_id + |
---|
[11868] | 406 | self.pay_item_id + |
---|
| 407 | str(int(self.amount_auth)) + |
---|
| 408 | self.site_redirect_url + |
---|
| 409 | self.mac) |
---|
| 410 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 411 | return |
---|
| 412 | |
---|
| 413 | |
---|
[11846] | 414 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
| 415 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
[13586] | 416 | """Request webservice view for the CollegePAY gateway |
---|
| 417 | """ |
---|
| 418 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 419 | gateway_host = HOST |
---|
| 420 | gateway_url = URL |
---|
| 421 | https = HTTPS |
---|
| 422 | mac = MAC |
---|
[13379] | 423 | |
---|
[13586] | 424 | @property |
---|
| 425 | def product_id(self): |
---|
| 426 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 427 | return PRODUCT_ID_PT |
---|
| 428 | return PRODUCT_ID_REGULAR |
---|
| 429 | |
---|
| 430 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
| 431 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
| 432 | """Payment verify view for the CollegePAY gateway |
---|
[11846] | 433 | """ |
---|
| 434 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 435 | gateway_host = HOST |
---|
[13586] | 436 | gateway_url = URL |
---|
[11916] | 437 | https = HTTPS |
---|
[13586] | 438 | mac = MAC |
---|
[11868] | 439 | |
---|
[13532] | 440 | @property |
---|
| 441 | def product_id(self): |
---|
| 442 | if contr_agreement_applicant(self.context.__parent__) == 'first': |
---|
| 443 | return PRODUCT_ID_PT |
---|
| 444 | return PRODUCT_ID_REGULAR |
---|
| 445 | |
---|
[11868] | 446 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
| 447 | InterswitchPaymentRequestWebservicePageStudent): |
---|
[13586] | 448 | """Request webservice view for the CollegePAY gateway |
---|
[11868] | 449 | """ |
---|
| 450 | grok.context(ICustomStudentOnlinePayment) |
---|
| 451 | gateway_host = HOST |
---|
[13586] | 452 | gateway_url = URL |
---|
[11916] | 453 | https = HTTPS |
---|
[13586] | 454 | mac = MAC |
---|
[13379] | 455 | |
---|
| 456 | @property |
---|
| 457 | def product_id(self): |
---|
[13532] | 458 | if contr_agreement_student(self.context.student) == 'first': |
---|
[13379] | 459 | return PRODUCT_ID_PT |
---|
| 460 | return PRODUCT_ID_REGULAR |
---|
[13586] | 461 | |
---|
| 462 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
| 463 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
| 464 | """Payment verify view for the CollegePAY gateway |
---|
| 465 | """ |
---|
| 466 | grok.context(ICustomStudentOnlinePayment) |
---|
| 467 | gateway_host = HOST |
---|
| 468 | gateway_url = URL |
---|
| 469 | https = HTTPS |
---|
| 470 | mac = MAC |
---|
| 471 | |
---|
| 472 | @property |
---|
| 473 | def product_id(self): |
---|
| 474 | if contr_agreement_student(self.context.student) == 'first': |
---|
| 475 | return PRODUCT_ID_PT |
---|
| 476 | return PRODUCT_ID_REGULAR |
---|