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