[7894] | 1 | ## $Id: browser.py 11145 2014-02-21 06:28:51Z henrik $ |
---|
| 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 | ## |
---|
[7898] | 18 | import httplib |
---|
[9392] | 19 | import hashlib |
---|
[7894] | 20 | import grok |
---|
[9464] | 21 | from zope.interface import Interface |
---|
| 22 | from zope.component import getUtility, queryAdapter |
---|
[9789] | 23 | from kofacustom.nigeria.interswitch.browser import ( |
---|
[10131] | 24 | InterswitchPaymentRequestWebservicePageStudent, |
---|
| 25 | InterswitchPaymentRequestWebservicePageApplicant |
---|
[9789] | 26 | ) |
---|
[7894] | 27 | from waeup.kofa.browser.layout import KofaPage, UtilityView |
---|
[9751] | 28 | from waeup.kofa.interfaces import IKofaUtils |
---|
[8281] | 29 | from waeup.kofa.utils.helpers import to_timezone |
---|
[9347] | 30 | from waeup.kwarapoly.students.interfaces import ICustomStudentOnlinePayment |
---|
| 31 | from waeup.kwarapoly.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
| 32 | from waeup.kwarapoly.interfaces import MessageFactory as _ |
---|
[7894] | 33 | |
---|
[9487] | 34 | PRODUCT_ID = '3930' |
---|
[10131] | 35 | SITE_NAME = 'kwarapoly.waeup.org' |
---|
[9387] | 36 | PROVIDER_ACCT = '1010764827' |
---|
| 37 | PROVIDER_BANK_ID = '117' |
---|
[8263] | 38 | PROVIDER_ITEM_NAME = 'BT Education' |
---|
[9347] | 39 | INSTITUTION_NAME = 'KwaraPoly' |
---|
[7894] | 40 | CURRENCY = '566' |
---|
[9789] | 41 | GATEWAY_AMT = 300.0 |
---|
[8401] | 42 | #QUERY_URL = 'https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx' |
---|
[8293] | 43 | #QUERY_URL = 'https://testwebpay.interswitchng.com/test_paydirect/services/TransactionQueryURL.aspx' |
---|
[9392] | 44 | |
---|
[9487] | 45 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/webpay/pay.aspx' |
---|
| 46 | #POST_ACTION = 'https://testwebpay.interswitchng.com/test_paydirect/webpay/pay.aspx' |
---|
[7894] | 47 | |
---|
[9487] | 48 | HOST = 'webpay.interswitchng.com' |
---|
| 49 | #HOST = 'testwebpay.interswitchng.com' |
---|
[9392] | 50 | |
---|
[9487] | 51 | URL = '/paydirect/services/TransactionQueryWs.asmx' |
---|
| 52 | #URL = '/test_paydirect/services/TransactionQueryWs.asmx' |
---|
[7898] | 53 | httplib.HTTPConnection.debuglevel = 0 |
---|
| 54 | |
---|
[8256] | 55 | class InterswitchPageStudent(KofaPage): |
---|
[7894] | 56 | """ View which sends a POST request to the Interswitch |
---|
| 57 | CollegePAY payment gateway. |
---|
| 58 | """ |
---|
[8255] | 59 | grok.context(ICustomStudentOnlinePayment) |
---|
[7894] | 60 | grok.name('goto_interswitch') |
---|
[8256] | 61 | grok.template('student_goto_interswitch') |
---|
[7894] | 62 | grok.require('waeup.payStudent') |
---|
| 63 | label = _('Submit data to CollegePAY (Interswitch Payment Gateway)') |
---|
| 64 | submit_button = _('Submit') |
---|
| 65 | action = POST_ACTION |
---|
| 66 | site_name = SITE_NAME |
---|
| 67 | currency = CURRENCY |
---|
| 68 | product_id = PRODUCT_ID |
---|
[9487] | 69 | mac = 'E6BA6CBBA9AF2871EE25C32C8D57C98895B9B001DC5B9CB2C463E2A9BDA44A3F1260C8A364F33789CDF74CB3EE7E6EF5D94F48D3AF7B727E75D97F07618DFA6D' |
---|
[7894] | 70 | |
---|
[9464] | 71 | def interswitch_img_url(self): |
---|
| 72 | return interswitch_img_url(self) |
---|
| 73 | |
---|
[7894] | 74 | def update(self): |
---|
[8256] | 75 | #if self.context.p_state != 'unpaid': |
---|
| 76 | if self.context.p_state == 'paid': |
---|
[7894] | 77 | self.flash(_("Payment ticket can't be re-send to CollegePAY.")) |
---|
| 78 | self.redirect(self.url(self.context, '@@index')) |
---|
| 79 | return |
---|
[8256] | 80 | |
---|
[8745] | 81 | student = self.student = self.context.student |
---|
| 82 | certificate = getattr(student['studycourse'],'certificate',None) |
---|
[8276] | 83 | self.amount_auth = 100 * self.context.amount_auth |
---|
[7894] | 84 | xmldict = {} |
---|
| 85 | if certificate is not None: |
---|
| 86 | xmldict['department'] = certificate.__parent__.__parent__.code |
---|
| 87 | xmldict['faculty'] = certificate.__parent__.__parent__.__parent__.code |
---|
| 88 | else: |
---|
| 89 | xmldict['department'] = None |
---|
| 90 | xmldict['faculty'] = None |
---|
[9408] | 91 | self.category = getUtility(IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category] |
---|
[8281] | 92 | tz = getUtility(IKofaUtils).tzinfo |
---|
| 93 | self.local_date_time = to_timezone( |
---|
| 94 | self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z") |
---|
[8256] | 95 | self.site_redirect_url = self.url(self.context, 'request_webservice') |
---|
[8263] | 96 | # Provider data |
---|
| 97 | xmldict['detail_ref'] = self.context.p_id |
---|
| 98 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 99 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 100 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 101 | # Institution data |
---|
[9616] | 102 | xmldict['institution_acct'] = "0000000000000" |
---|
| 103 | xmldict['institution_bank_id'] = '0' |
---|
| 104 | xmldict['institution_item_name'] = self.category |
---|
[8263] | 105 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
[10736] | 106 | xmldict['institution_amt'] = 0.0 |
---|
| 107 | dalash_amt = 200.0 |
---|
| 108 | provider_amt = 300.0 |
---|
| 109 | gateway_amt = GATEWAY_AMT |
---|
[9616] | 110 | self.pay_item_id = '000' |
---|
[9737] | 111 | if self.context.p_category == 'schoolfee': |
---|
[9616] | 112 | self.pay_item_id = '101' |
---|
[9789] | 113 | dalash_amt = 1800.0 |
---|
[10736] | 114 | provider_amt = 1200.0 |
---|
[9616] | 115 | if xmldict['faculty'] in ('CPGS',): |
---|
| 116 | xmldict['institution_acct'] = "1771180233" |
---|
| 117 | xmldict['institution_bank_id'] = '120' |
---|
| 118 | elif xmldict['faculty'] in ('IBAS',): |
---|
[10667] | 119 | xmldict['institution_acct'] = "2013910271" |
---|
| 120 | xmldict['institution_bank_id'] = '8' |
---|
| 121 | self.pay_item_id = '107' |
---|
[9616] | 122 | elif xmldict['faculty'] in ('IETS',): |
---|
[10667] | 123 | xmldict['institution_acct'] = "2013910271" |
---|
| 124 | xmldict['institution_bank_id'] = '8' |
---|
| 125 | self.pay_item_id = '109' |
---|
| 126 | elif xmldict['faculty'] in ('IFMS',): |
---|
[9616] | 127 | xmldict['institution_acct'] = "0106259811" |
---|
| 128 | xmldict['institution_bank_id'] = '10' |
---|
[10667] | 129 | self.pay_item_id = '106' |
---|
[9616] | 130 | elif xmldict['faculty'] in ('ITCH',): |
---|
[10667] | 131 | xmldict['institution_acct'] = "1771180233" |
---|
| 132 | xmldict['institution_bank_id'] = '120' |
---|
| 133 | self.pay_item_id = '110' |
---|
| 134 | elif xmldict['faculty'] in ('IICT',): |
---|
[9616] | 135 | xmldict['institution_acct'] = "2013910271" |
---|
| 136 | xmldict['institution_bank_id'] = '8' |
---|
[10667] | 137 | self.pay_item_id = '108' |
---|
[10736] | 138 | elif self.context.p_category == 'certificate': |
---|
| 139 | self.pay_item_id = '111' |
---|
| 140 | xmldict['institution_acct'] = "0131959715" |
---|
| 141 | xmldict['institution_bank_id'] = '10' |
---|
| 142 | elif self.context.p_category == 'state_result': |
---|
| 143 | self.pay_item_id = '112' |
---|
| 144 | xmldict['institution_acct'] = "0131959715" |
---|
| 145 | xmldict['institution_bank_id'] = '10' |
---|
| 146 | elif self.context.p_category == 'transcript_local': |
---|
| 147 | self.pay_item_id = '113' |
---|
| 148 | xmldict['institution_acct'] = "0131959715" |
---|
| 149 | xmldict['institution_bank_id'] = '10' |
---|
| 150 | elif self.context.p_category == 'transcript_foreign': |
---|
| 151 | self.pay_item_id = '114' |
---|
| 152 | xmldict['institution_acct'] = "0131959715" |
---|
| 153 | xmldict['institution_bank_id'] = '10' |
---|
| 154 | elif self.context.p_category == 'ver_result': |
---|
| 155 | self.pay_item_id = '115' |
---|
| 156 | xmldict['institution_acct'] = "0131959715" |
---|
| 157 | xmldict['institution_bank_id'] = '10' |
---|
| 158 | elif self.context.p_category == 'change_course': |
---|
| 159 | self.pay_item_id = '116' |
---|
| 160 | xmldict['institution_acct'] = "0131959715" |
---|
| 161 | xmldict['institution_bank_id'] = '10' |
---|
| 162 | elif self.context.p_category == 'change_inst': |
---|
| 163 | self.pay_item_id = '117' |
---|
| 164 | xmldict['institution_acct'] = "0131959715" |
---|
| 165 | xmldict['institution_bank_id'] = '10' |
---|
| 166 | elif self.context.p_category == 'jamb_reject': |
---|
| 167 | self.pay_item_id = '118' |
---|
| 168 | xmldict['institution_acct'] = "0131959715" |
---|
| 169 | xmldict['institution_bank_id'] = '10' |
---|
| 170 | elif self.context.p_category == 'cert_of_cert': |
---|
| 171 | self.pay_item_id = '119' |
---|
| 172 | xmldict['institution_acct'] = "0131959715" |
---|
| 173 | xmldict['institution_bank_id'] = '10' |
---|
| 174 | elif self.context.p_category == 'ref_let': |
---|
| 175 | self.pay_item_id = '120' |
---|
| 176 | xmldict['institution_acct'] = "0131959715" |
---|
| 177 | xmldict['institution_bank_id'] = '10' |
---|
| 178 | elif self.context.p_category == 'proc_cert': |
---|
| 179 | self.pay_item_id = '121' |
---|
| 180 | xmldict['institution_acct'] = "0131959715" |
---|
| 181 | xmldict['institution_bank_id'] = '10' |
---|
| 182 | elif self.context.p_category == 'loss_idcard': |
---|
| 183 | self.pay_item_id = '122' |
---|
| 184 | xmldict['institution_acct'] = "0131959715" |
---|
| 185 | xmldict['institution_bank_id'] = '10' |
---|
| 186 | dalash_amt = 6.0 |
---|
| 187 | xmldict['dalash_amt'] = 100 * dalash_amt |
---|
| 188 | provider_amt = 9.0 |
---|
| 189 | gateway_amt = 15.0 |
---|
| 190 | elif self.context.p_category == 'loss_examcard': |
---|
| 191 | self.pay_item_id = '123' |
---|
| 192 | xmldict['institution_acct'] = "0131959715" |
---|
| 193 | xmldict['institution_bank_id'] = '10' |
---|
| 194 | dalash_amt = 3.0 |
---|
| 195 | xmldict['dalash_amt'] = 100 * dalash_amt |
---|
| 196 | provider_amt = 4.5 |
---|
| 197 | gateway_amt = 7.5 |
---|
| 198 | elif self.context.p_category == 'loss_result': |
---|
| 199 | self.pay_item_id = '124' |
---|
| 200 | xmldict['institution_acct'] = "0131959715" |
---|
| 201 | xmldict['institution_bank_id'] = '10' |
---|
| 202 | elif self.context.p_category == 'loss_receipt': |
---|
| 203 | self.pay_item_id = '125' |
---|
| 204 | xmldict['institution_acct'] = "0131959715" |
---|
| 205 | xmldict['institution_bank_id'] = '10' |
---|
| 206 | elif self.context.p_category == 'loss_clearance': |
---|
| 207 | self.pay_item_id = '126' |
---|
| 208 | xmldict['institution_acct'] = "0131959715" |
---|
| 209 | xmldict['institution_bank_id'] = '10' |
---|
| 210 | elif self.context.p_category == 'conv_brochure': |
---|
| 211 | self.pay_item_id = '127' |
---|
| 212 | xmldict['institution_acct'] = "0131959715" |
---|
| 213 | xmldict['institution_bank_id'] = '10' |
---|
[9617] | 214 | elif 'maintenance' in self.context.p_category: |
---|
[9626] | 215 | self.pay_item_id = '102' |
---|
[9617] | 216 | xmldict['institution_acct'] = "0039050937" |
---|
| 217 | xmldict['institution_bank_id'] = '31' |
---|
[9789] | 218 | dalash_amt = 0.0 |
---|
| 219 | provider_amt = 0.0 |
---|
[9617] | 220 | |
---|
[10736] | 221 | |
---|
| 222 | xmldict['dalash_amt'] = 100 * dalash_amt |
---|
| 223 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 224 | xmldict['institution_amt'] = 100 * ( |
---|
| 225 | self.context.amount_auth - provider_amt - |
---|
| 226 | gateway_amt - dalash_amt) |
---|
| 227 | |
---|
| 228 | |
---|
[9392] | 229 | hashargs = ( |
---|
| 230 | self.context.p_id + |
---|
| 231 | PRODUCT_ID + |
---|
| 232 | self.pay_item_id + |
---|
| 233 | str(int(self.amount_auth)) + |
---|
| 234 | self.site_redirect_url + |
---|
| 235 | self.mac) |
---|
| 236 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 237 | |
---|
[8263] | 238 | # Interswitch amount is not part of the xml data |
---|
[9617] | 239 | |
---|
[10736] | 240 | if 'maintenance' in self.context.p_category: |
---|
[9617] | 241 | xmltext = """<payment_item_detail> |
---|
[8263] | 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 |
---|
[9617] | 246 | |
---|
[10736] | 247 | else: |
---|
[9617] | 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" /> |
---|
[10736] | 251 | <item_detail item_id="2" item_name="Dalash" item_amt="%(dalash_amt)d" bank_id="117" acct_num="1013196791" /> |
---|
| 252 | <item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
[9617] | 253 | </item_details> |
---|
| 254 | </payment_item_detail>""" % xmldict |
---|
| 255 | |
---|
[8263] | 256 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
[9789] | 257 | self.context.provider_amt = provider_amt |
---|
[10736] | 258 | self.context.gateway_amt = gateway_amt |
---|
[9789] | 259 | self.context.thirdparty_amt = dalash_amt |
---|
[7894] | 260 | return |
---|
| 261 | |
---|
[10131] | 262 | class InterswitchPageApplicant(KofaPage): |
---|
| 263 | """ View which sends a POST request to the Interswitch |
---|
| 264 | CollegePAY payment gateway. |
---|
| 265 | """ |
---|
| 266 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 267 | grok.require('waeup.payApplicant') |
---|
| 268 | grok.template('applicant_goto_interswitch') |
---|
| 269 | grok.name('goto_interswitch') |
---|
| 270 | label = _('Submit data to CollegePAY (Interswitch Payment Gateway)') |
---|
| 271 | submit_button = _('Submit') |
---|
| 272 | action = POST_ACTION |
---|
| 273 | site_name = SITE_NAME |
---|
| 274 | currency = CURRENCY |
---|
| 275 | pay_item_id = '103' |
---|
| 276 | product_id = PRODUCT_ID |
---|
| 277 | mac = 'E6BA6CBBA9AF2871EE25C32C8D57C98895B9B001DC5B9CB2C463E2A9BDA44A3F1260C8A364F33789CDF74CB3EE7E6EF5D94F48D3AF7B727E75D97F07618DFA6D' |
---|
| 278 | |
---|
| 279 | def interswitch_img_url(self): |
---|
| 280 | return interswitch_img_url(self) |
---|
| 281 | |
---|
| 282 | def update(self): |
---|
| 283 | if self.context.p_state != 'unpaid': |
---|
| 284 | self.flash(_("Payment ticket can't be re-send to CollegePAY.")) |
---|
| 285 | self.redirect(self.url(self.context, '@@index')) |
---|
| 286 | return |
---|
| 287 | if self.context.__parent__.__parent__.expired \ |
---|
| 288 | and self.context.__parent__.__parent__.strict_deadline: |
---|
| 289 | self.flash(_("Payment ticket can't be send to CollegePAY. " |
---|
| 290 | "Application period has expired.")) |
---|
| 291 | self.redirect(self.url(self.context, '@@index')) |
---|
| 292 | return |
---|
| 293 | self.applicant = self.context.__parent__ |
---|
| 294 | self.amount_auth = 100 * self.context.amount_auth |
---|
| 295 | xmldict = {} |
---|
| 296 | self.category = getUtility( |
---|
| 297 | IKofaUtils).PAYMENT_CATEGORIES[self.context.p_category] |
---|
| 298 | tz = getUtility(IKofaUtils).tzinfo |
---|
| 299 | self.local_date_time = to_timezone( |
---|
| 300 | self.context.creation_date, tz).strftime("%Y-%m-%d %H:%M:%S %Z") |
---|
| 301 | self.site_redirect_url = self.url(self.context, 'request_webservice') |
---|
[10176] | 302 | provider_amt = 300.0 |
---|
| 303 | dalash_amt = 200.0 |
---|
[10131] | 304 | if self.applicant.applicant_id.startswith('hnd'): |
---|
[10254] | 305 | xmldict['institution_acct'] = '7000016724' |
---|
[10131] | 306 | xmldict['institution_bank_id'] = '9' |
---|
[10597] | 307 | elif self.applicant.applicant_id.startswith('nd'): |
---|
[10131] | 308 | xmldict['institution_acct'] = '2014191363' |
---|
| 309 | xmldict['institution_bank_id'] = '8' |
---|
[10651] | 310 | elif self.applicant.applicant_id.startswith('pgft'): |
---|
| 311 | xmldict['institution_acct'] = '7000016724' |
---|
| 312 | xmldict['institution_bank_id'] = '9' |
---|
[10597] | 313 | elif self.applicant.applicant_id.startswith('prejambites'): |
---|
| 314 | xmldict['institution_acct'] = '0106259811' |
---|
| 315 | xmldict['institution_bank_id'] = '10' |
---|
| 316 | self.pay_item_id = '104' |
---|
| 317 | provider_amt = 0.0 |
---|
| 318 | dalash_amt = 0.0 |
---|
| 319 | elif self.applicant.applicant_id.startswith('pre'): |
---|
| 320 | xmldict['institution_acct'] = '2013910271' |
---|
| 321 | xmldict['institution_bank_id'] = '8' |
---|
| 322 | provider_amt = 0.0 |
---|
| 323 | dalash_amt = 0.0 |
---|
[10844] | 324 | elif self.applicant.applicant_id.startswith('special'): |
---|
| 325 | if self.applicant.special_application == 'certificate': |
---|
| 326 | self.pay_item_id = '111' |
---|
| 327 | xmldict['institution_acct'] = "0131959715" |
---|
| 328 | xmldict['institution_bank_id'] = '10' |
---|
| 329 | elif self.applicant.special_application == 'state_result': |
---|
| 330 | self.pay_item_id = '112' |
---|
| 331 | xmldict['institution_acct'] = "0131959715" |
---|
| 332 | xmldict['institution_bank_id'] = '10' |
---|
| 333 | elif self.applicant.special_application == 'transcript_local': |
---|
| 334 | self.pay_item_id = '113' |
---|
| 335 | xmldict['institution_acct'] = "0131959715" |
---|
| 336 | xmldict['institution_bank_id'] = '10' |
---|
| 337 | elif self.applicant.special_application == 'transcript_foreign': |
---|
| 338 | self.pay_item_id = '114' |
---|
| 339 | xmldict['institution_acct'] = "0131959715" |
---|
| 340 | xmldict['institution_bank_id'] = '10' |
---|
| 341 | elif self.applicant.special_application == 'ver_result': |
---|
| 342 | self.pay_item_id = '115' |
---|
| 343 | xmldict['institution_acct'] = "0131959715" |
---|
| 344 | xmldict['institution_bank_id'] = '10' |
---|
| 345 | elif self.applicant.special_application == 'change_course': |
---|
| 346 | self.pay_item_id = '116' |
---|
| 347 | xmldict['institution_acct'] = "0131959715" |
---|
| 348 | xmldict['institution_bank_id'] = '10' |
---|
| 349 | elif self.applicant.special_application == 'change_inst': |
---|
| 350 | self.pay_item_id = '117' |
---|
| 351 | xmldict['institution_acct'] = "0131959715" |
---|
| 352 | xmldict['institution_bank_id'] = '10' |
---|
| 353 | elif self.applicant.special_application == 'jamb_reject': |
---|
| 354 | self.pay_item_id = '118' |
---|
| 355 | xmldict['institution_acct'] = "0131959715" |
---|
| 356 | xmldict['institution_bank_id'] = '10' |
---|
| 357 | elif self.applicant.special_application == 'cert_of_cert': |
---|
| 358 | self.pay_item_id = '119' |
---|
| 359 | xmldict['institution_acct'] = "0131959715" |
---|
| 360 | xmldict['institution_bank_id'] = '10' |
---|
| 361 | elif self.applicant.special_application == 'ref_let': |
---|
| 362 | self.pay_item_id = '120' |
---|
| 363 | xmldict['institution_acct'] = "0131959715" |
---|
| 364 | xmldict['institution_bank_id'] = '10' |
---|
| 365 | elif self.applicant.special_application == 'proc_cert': |
---|
| 366 | self.pay_item_id = '121' |
---|
| 367 | xmldict['institution_acct'] = "0131959715" |
---|
| 368 | xmldict['institution_bank_id'] = '10' |
---|
| 369 | elif self.applicant.special_application == 'loss_idcard': |
---|
| 370 | self.pay_item_id = '122' |
---|
| 371 | xmldict['institution_acct'] = "0131959715" |
---|
| 372 | xmldict['institution_bank_id'] = '10' |
---|
| 373 | dalash_amt = 6.0 |
---|
| 374 | xmldict['dalash_amt'] = 100 * dalash_amt |
---|
| 375 | provider_amt = 9.0 |
---|
| 376 | gateway_amt = 15.0 |
---|
| 377 | elif self.applicant.special_application == 'loss_examcard': |
---|
| 378 | self.pay_item_id = '123' |
---|
| 379 | xmldict['institution_acct'] = "0131959715" |
---|
| 380 | xmldict['institution_bank_id'] = '10' |
---|
| 381 | dalash_amt = 3.0 |
---|
| 382 | xmldict['dalash_amt'] = 100 * dalash_amt |
---|
| 383 | provider_amt = 4.5 |
---|
| 384 | gateway_amt = 7.5 |
---|
| 385 | elif self.applicant.special_application == 'loss_result': |
---|
| 386 | self.pay_item_id = '124' |
---|
| 387 | xmldict['institution_acct'] = "0131959715" |
---|
| 388 | xmldict['institution_bank_id'] = '10' |
---|
| 389 | elif self.applicant.special_application == 'loss_receipt': |
---|
| 390 | self.pay_item_id = '125' |
---|
| 391 | xmldict['institution_acct'] = "0131959715" |
---|
| 392 | xmldict['institution_bank_id'] = '10' |
---|
| 393 | elif self.applicant.special_application == 'loss_clearance': |
---|
| 394 | self.pay_item_id = '126' |
---|
| 395 | xmldict['institution_acct'] = "0131959715" |
---|
| 396 | xmldict['institution_bank_id'] = '10' |
---|
| 397 | elif self.applicant.special_application == 'conv_brochure': |
---|
| 398 | self.pay_item_id = '127' |
---|
| 399 | xmldict['institution_acct'] = "0131959715" |
---|
| 400 | xmldict['institution_bank_id'] = '10' |
---|
| 401 | else: |
---|
| 402 | xmldict['institution_acct'] = '00000000000' |
---|
| 403 | xmldict['institution_bank_id'] = '00' |
---|
[10131] | 404 | else: |
---|
| 405 | xmldict['institution_acct'] = '00000000000' |
---|
| 406 | xmldict['institution_bank_id'] = '00' |
---|
[10176] | 407 | xmldict['dalash_amt'] = 100 * dalash_amt |
---|
[10131] | 408 | xmldict['detail_ref'] = self.context.p_id |
---|
| 409 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 410 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 411 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 412 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 413 | xmldict['institution_amt'] = 100 * ( |
---|
[10176] | 414 | self.context.amount_auth - provider_amt - GATEWAY_AMT - dalash_amt) |
---|
[10131] | 415 | xmldict['institution_item_name'] = self.context.p_category |
---|
| 416 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
| 417 | |
---|
| 418 | hashargs = ( |
---|
| 419 | self.context.p_id + |
---|
| 420 | PRODUCT_ID + |
---|
| 421 | self.pay_item_id + |
---|
| 422 | str(int(self.amount_auth)) + |
---|
| 423 | self.site_redirect_url + |
---|
| 424 | self.mac) |
---|
| 425 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
| 426 | |
---|
| 427 | # Interswitch amount is not part of the xml data |
---|
[10597] | 428 | |
---|
| 429 | if not self.applicant.applicant_id.startswith('pre'): |
---|
| 430 | xmltext = """<payment_item_detail> |
---|
[10131] | 431 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 432 | <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" /> |
---|
[10176] | 433 | <item_detail item_id="2" item_name="Dalash" item_amt="%(dalash_amt)d" bank_id="117" acct_num="1013196791" /> |
---|
| 434 | <item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
[10131] | 435 | </item_details> |
---|
| 436 | </payment_item_detail>""" % xmldict |
---|
[10597] | 437 | |
---|
| 438 | else: |
---|
| 439 | xmltext = """<payment_item_detail> |
---|
| 440 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 441 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 442 | </item_details> |
---|
| 443 | </payment_item_detail>""" % xmldict |
---|
| 444 | |
---|
[10131] | 445 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 446 | self.context.provider_amt = provider_amt |
---|
| 447 | self.context.gateway_amt = GATEWAY_AMT |
---|
[10176] | 448 | self.context.thirdparty_amt = dalash_amt |
---|
[10131] | 449 | return |
---|
| 450 | |
---|
[9789] | 451 | class InterswitchPaymentRequestWebservicePageStudent( |
---|
| 452 | InterswitchPaymentRequestWebservicePageStudent): |
---|
[7919] | 453 | """ Request webservice view for the CollegePAY gateway |
---|
| 454 | """ |
---|
[8255] | 455 | grok.context(ICustomStudentOnlinePayment) |
---|
[9789] | 456 | product_id = PRODUCT_ID |
---|
| 457 | gateway_host = HOST |
---|
[10131] | 458 | gateway_url = URL |
---|
| 459 | |
---|
| 460 | class InterswitchPaymentRequestWebservicePageApplicant( |
---|
| 461 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
| 462 | """ Request webservice view for the CollegePAY gateway |
---|
| 463 | """ |
---|
| 464 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 465 | product_id = PRODUCT_ID |
---|
| 466 | gateway_host = HOST |
---|
[9789] | 467 | gateway_url = URL |
---|