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