[10765] | 1 | ## $Id: browser.py 15022 2018-05-24 09:57:39Z 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 | ## |
---|
| 18 | import httplib |
---|
[12479] | 19 | import hashlib |
---|
[10765] | 20 | import grok |
---|
| 21 | from kofacustom.nigeria.interswitch.browser import ( |
---|
| 22 | InterswitchPaymentRequestWebservicePageApplicant, |
---|
[11638] | 23 | InterswitchPaymentRequestWebservicePageStudent, |
---|
[13587] | 24 | InterswitchPaymentVerifyWebservicePageApplicant, |
---|
| 25 | InterswitchPaymentVerifyWebservicePageStudent, |
---|
[11638] | 26 | InterswitchPageStudent, InterswitchPageApplicant, |
---|
[10765] | 27 | ) |
---|
[14716] | 28 | from kofacustom.dspg.students.interfaces import ICustomStudentOnlinePayment |
---|
| 29 | from kofacustom.dspg.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
| 30 | from kofacustom.dspg.interfaces import MessageFactory as _ |
---|
[10765] | 31 | |
---|
[14726] | 32 | PRODUCT_ID = '7269' # must be provided by Interswitch |
---|
[14749] | 33 | SITE_NAME = 'dspg.waeup.org' |
---|
[14879] | 34 | PROVIDER_ACCT = '2028964403' |
---|
| 35 | PROVIDER_BANK_ID = '8' |
---|
[10765] | 36 | PROVIDER_ITEM_NAME = 'BT Education' |
---|
[14722] | 37 | INSTITUTION_NAME = 'Delta State Polytechnic Ogwashi-Uku' |
---|
[10765] | 38 | CURRENCY = '566' |
---|
[14727] | 39 | GATEWAY_AMT = 250.0 |
---|
[15021] | 40 | MAC = 'D43ED93B7A307B152C7111D04E1F384428057CD1E75428D3A4C5631C28ACB9C8C822A88CA76DEDC5F9A520CF4BFDB2824FF8B207AAFC667DF3CBB13685B66627' |
---|
[10765] | 41 | |
---|
[14726] | 42 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' |
---|
| 43 | #POST_ACTION = 'https://sandbox.interswitchng.com/webpay/pay' |
---|
| 44 | HOST = 'webpay.interswitchng.com' |
---|
| 45 | #HOST = 'sandbox.interswitchng.com' |
---|
| 46 | URL = '/paydirect/api/v1/gettransaction.json' |
---|
| 47 | #URL = '/webpay/api/v1/gettransaction.json' |
---|
[14276] | 48 | |
---|
[12479] | 49 | httplib.HTTPSConnection.debuglevel = 0 |
---|
| 50 | HTTPS = True |
---|
[10765] | 51 | |
---|
[14859] | 52 | SPECIAL_PAYMENT_PARAMS = { |
---|
[14864] | 53 | |
---|
| 54 | 'carryover1': ('101', 500.0, '1012808851', '117'), |
---|
| 55 | 'carryover5': ('101', 500.0, '1012808851', '117'), |
---|
| 56 | 'carryover6': ('101', 500.0, '1012808851', '117'), |
---|
| 57 | 'carryover7': ('101', 500.0, '1012808851', '117'), |
---|
| 58 | 'carryover8': ('101', 500.0, '1012808851', '117'), |
---|
| 59 | 'carryover9': ('101', 500.0, '1012808851', '117'), |
---|
| 60 | 'carryover10': ('101', 500.0, '1012808851', '117'), |
---|
[14868] | 61 | 'carryover11': ('101', 500.0, '1012808851', '117'), |
---|
| 62 | 'carryover12': ('101', 500.0, '1012808851', '117'), |
---|
[14869] | 63 | 'balance': ('101', 500.0, '1012808851', '117'), |
---|
[14864] | 64 | |
---|
[14859] | 65 | 'certificate': ('111', 500.0, '1012808851', '117'), |
---|
| 66 | 'state_result': ('112', 500.0, '1012808851', '117'), |
---|
| 67 | 'transcript_local': ('113', 500.0, '1012808851', '117'), |
---|
| 68 | 'transcript_foreign': ('114', 500.0, '1012808851', '117'), |
---|
| 69 | 'ver_result': ('115', 500.0, '1012808851', '117'), |
---|
| 70 | 'change_course': ('116', 500.0, '1012808851', '117'), |
---|
| 71 | 'change_inst': ('117', 500.0, '1012808851', '117'), |
---|
| 72 | 'jamb_reject': ('118', 500.0, '1012808851', '117'), |
---|
| 73 | 'cert_of_cert': ('119', 500.0, '1012808851', '117'), |
---|
| 74 | 'ref_let': ('120', 500.0, '1012808851', '117'), |
---|
| 75 | 'proc_cert': ('121', 500.0, '1012808851', '117'), |
---|
| 76 | 'loss_idcard': ('122', 9.0, '1012808851', '117'), |
---|
| 77 | 'loss_examcard': ('123', 4.5, '1012808851', '117'), |
---|
| 78 | 'loss_result': ('124', 500.0, '1012808851', '117'), |
---|
| 79 | 'loss_receipt': ('125', 500.0, '1012808851', '117'), |
---|
| 80 | 'loss_clearance': ('126', 500.0, '1012808851', '117'), |
---|
| 81 | 'conv_brochure': ('127', 500.0, '1012808851', '117'), |
---|
| 82 | 'hnd_certificate': ('128', 500.0, '1012808851', '117'), |
---|
| 83 | 'hnd_state_result': ('129', 500.0, '1012808851', '117'), |
---|
| 84 | 'hnd_transcript_local': ('130', 500.0, '1012808851', '117'), |
---|
| 85 | 'hnd_transcript_foreign': ('131', 500.0, '1012808851', '117'), |
---|
| 86 | 'staff_loss_idcard': ('132', 9.0, '1012808851', '117'), |
---|
| 87 | 'hnd_conv_brochure': ('133', 500.0, '1012808851', '117'), |
---|
| 88 | 'pgd_state_result': ('134', 500.0, '1012808851', '117'), |
---|
| 89 | 'pgd_conv_brochure': ('135', 500.0, '1012808851', '117'), |
---|
| 90 | 'pgd_certificate': ('136', 500.0, '1012808851', '117'), |
---|
| 91 | 'log_book': ('137', 4.5, '1012808851', '117'), |
---|
| 92 | 'pgd_transcript_foreign': ('138', 500.0, '1012808851', '117'), |
---|
| 93 | 'pgd_transcript_local': ('139', 500.0, '1012808851', '117'), |
---|
| 94 | 'jamb_regularization': ('140', 500.0, '1012808851', '117'), |
---|
| 95 | 'utme_registration': ('142', 9.0, '1012808851', '117'), |
---|
| 96 | 'utme_cbt': ('143', 9.0, '1012808851', '117'), |
---|
| 97 | 'nysc_id_card': ('144', 9.0, '1012808851', '117'), |
---|
| 98 | 'ijmb_result': ('147', 500.0, '1012808851', '117'), |
---|
| 99 | } |
---|
| 100 | |
---|
[14862] | 101 | |
---|
[14875] | 102 | # Not yet readily configured. Bank account numbers are |
---|
[14862] | 103 | # contradictory. pay_item_ids are not yet assigned. |
---|
| 104 | |
---|
[11638] | 105 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
[10765] | 106 | """ View which sends a POST request to the Interswitch |
---|
| 107 | CollegePAY payment gateway. |
---|
| 108 | """ |
---|
| 109 | grok.context(ICustomStudentOnlinePayment) |
---|
| 110 | action = POST_ACTION |
---|
| 111 | site_name = SITE_NAME |
---|
| 112 | currency = CURRENCY |
---|
| 113 | product_id = PRODUCT_ID |
---|
[15021] | 114 | mac = MAC |
---|
[14875] | 115 | pay_item_id = '000' |
---|
[10765] | 116 | |
---|
| 117 | def update(self): |
---|
[12979] | 118 | error = self.init_update() |
---|
| 119 | if error: |
---|
| 120 | self.flash(error, type='danger') |
---|
| 121 | self.redirect(self.url(self.context, '@@index')) |
---|
| 122 | return |
---|
[11647] | 123 | student = self.student |
---|
| 124 | xmldict = self.xmldict |
---|
[10765] | 125 | # Provider data |
---|
| 126 | xmldict['detail_ref'] = self.context.p_id |
---|
| 127 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 128 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 129 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 130 | # Institution data |
---|
[14875] | 131 | xmldict['institution_acct'] = '00000000' |
---|
| 132 | xmldict['institution_bank_id'] = '00' |
---|
[10765] | 133 | xmldict['institution_amt'] = '0.0' |
---|
[14875] | 134 | provider_amt = 0.0 |
---|
[14961] | 135 | tech_fee = 0.0 |
---|
[14862] | 136 | if self.context.p_category.startswith('schoolfee'): |
---|
| 137 | self.pay_item_id = '102' |
---|
[14875] | 138 | provider_amt = 2800.0 |
---|
[14961] | 139 | tech_fee = 1200.0 |
---|
[14889] | 140 | if student.faccode == 'SPAT': |
---|
| 141 | xmldict['institution_acct'] = '1012808851' |
---|
[14875] | 142 | xmldict['institution_bank_id'] = '117' |
---|
[14889] | 143 | elif student.current_mode in ('nd_ft', 'hnd_ft'): |
---|
[14953] | 144 | xmldict['institution_acct'] = '0010761873' |
---|
| 145 | xmldict['institution_bank_id'] = '11' |
---|
[14862] | 146 | elif self.context.p_category == 'clearance': |
---|
| 147 | self.pay_item_id = '103' |
---|
[14875] | 148 | provider_amt = 500.0 |
---|
[14889] | 149 | if student.faccode == 'SPAT': |
---|
| 150 | xmldict['institution_acct'] = '1012808851' |
---|
[14875] | 151 | xmldict['institution_bank_id'] = '117' |
---|
[14889] | 152 | elif student.current_mode == 'nd_ft': |
---|
[14875] | 153 | xmldict['institution_acct'] = '2004402644' |
---|
| 154 | xmldict['institution_bank_id'] = '8' |
---|
[14942] | 155 | elif self.context.p_category == 'gown': |
---|
| 156 | self.pay_item_id = '102' # We use school fee item id. |
---|
| 157 | xmldict['institution_acct'] = '2006612782' |
---|
| 158 | xmldict['institution_bank_id'] = '8' |
---|
[15021] | 159 | elif self.context.p_category == 'sports': |
---|
| 160 | self.pay_item_id = '110' |
---|
| 161 | xmldict['institution_acct'] = '6060300688' |
---|
| 162 | xmldict['institution_bank_id'] = '51' |
---|
| 163 | elif self.context.p_category == 'siwes': |
---|
| 164 | self.pay_item_id = '111' |
---|
| 165 | xmldict['institution_acct'] = '1001174679' |
---|
| 166 | xmldict['institution_bank_id'] = '123' |
---|
[15022] | 167 | elif self.context.p_category == 'eed_1': |
---|
[15021] | 168 | self.pay_item_id = '112' |
---|
| 169 | xmldict['institution_acct'] = '0039782431' |
---|
| 170 | xmldict['institution_bank_id'] = '11' |
---|
[15022] | 171 | elif self.context.p_category == 'eed_2': |
---|
| 172 | self.pay_item_id = '116' |
---|
| 173 | xmldict['institution_acct'] = '0039782431' |
---|
| 174 | xmldict['institution_bank_id'] = '11' |
---|
| 175 | elif self.context.p_category == 'olevel_results_1': |
---|
[15021] | 176 | self.pay_item_id = '113' |
---|
| 177 | xmldict['institution_acct'] = '2015327204' |
---|
| 178 | xmldict['institution_bank_id'] = '8' |
---|
[15022] | 179 | elif self.context.p_category == 'olevel_results_2': |
---|
| 180 | self.pay_item_id = '115' |
---|
| 181 | xmldict['institution_acct'] = '2015327204' |
---|
| 182 | xmldict['institution_bank_id'] = '8' |
---|
[14862] | 183 | elif self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys(): |
---|
| 184 | self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0] |
---|
| 185 | provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1] |
---|
| 186 | xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2] |
---|
| 187 | xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3] |
---|
[10765] | 188 | xmldict['provider_amt'] = 100 * provider_amt |
---|
[14961] | 189 | xmldict['tech_fee'] = 100 * tech_fee |
---|
[12511] | 190 | xmldict['institution_item_name'] = self.context.category |
---|
[10765] | 191 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
[14889] | 192 | xmldict['institution_amt'] = institution_amt = 100 * ( |
---|
[14961] | 193 | self.context.amount_auth - provider_amt - tech_fee - GATEWAY_AMT) |
---|
| 194 | |
---|
[10765] | 195 | if provider_amt == 0: |
---|
| 196 | xmltext = """<payment_item_detail> |
---|
| 197 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 198 | <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" /> |
---|
| 199 | </item_details> |
---|
| 200 | </payment_item_detail>""" % xmldict |
---|
[14961] | 201 | elif tech_fee == 0: |
---|
| 202 | xmltext = """<payment_item_detail> |
---|
| 203 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 204 | <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" /> |
---|
| 205 | <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" /> |
---|
| 206 | </item_details> |
---|
| 207 | </payment_item_detail>""" % xmldict |
---|
[10765] | 208 | else: |
---|
| 209 | xmltext = """<payment_item_detail> |
---|
| 210 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 211 | <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" /> |
---|
| 212 | <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" /> |
---|
[14962] | 213 | <item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="307" acct_num="5100189030" /> |
---|
[10765] | 214 | </item_details> |
---|
| 215 | </payment_item_detail>""" % xmldict |
---|
[14889] | 216 | |
---|
| 217 | # isouaba: All certificates in SPAT are part time thus any payments |
---|
| 218 | # coming from those certificates (Application, Acceptance, school fees |
---|
| 219 | # etc) 40% should be split to keystone account. |
---|
| 220 | if student.faccode == 'SPAT': |
---|
| 221 | xmldict['institution_amt_2'] = 0.4 * institution_amt |
---|
| 222 | xmldict['institution_amt_1'] = 0.6 * institution_amt |
---|
| 223 | if provider_amt == 0: |
---|
| 224 | xmltext = """<payment_item_detail> |
---|
| 225 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 226 | <item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 227 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 228 | </item_details> |
---|
| 229 | </payment_item_detail>""" % xmldict |
---|
[14964] | 230 | elif tech_fee == 0: |
---|
| 231 | xmltext = """<payment_item_detail> |
---|
| 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 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 234 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 235 | <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" /> |
---|
| 236 | </item_details> |
---|
| 237 | </payment_item_detail>""" % xmldict |
---|
[14889] | 238 | else: |
---|
| 239 | xmltext = """<payment_item_detail> |
---|
| 240 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 241 | <item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 242 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 243 | <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" /> |
---|
[14964] | 244 | <item_detail item_id="4" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="307" acct_num="5100189030" /> |
---|
[14889] | 245 | </item_details> |
---|
| 246 | </payment_item_detail>""" % xmldict |
---|
[14921] | 247 | # dep_sug payments are treated completely separately. The following lines |
---|
| 248 | # override the configuration above. |
---|
| 249 | if self.context.p_category == 'dep_sug': |
---|
| 250 | self.pay_item_id = '102' # We use school fee item id |
---|
| 251 | # amount_auth is being ignored. However, the sum of all split payments |
---|
| 252 | # must coincide with the amount_auth configured in students/utils.py |
---|
[14938] | 253 | xmldict['amt1'] = 100 * 1000 |
---|
[14921] | 254 | xmldict['amt2'] = 100 * 500 |
---|
| 255 | xmldict['amt3'] = 100 * 900 |
---|
| 256 | xmldict['amt4'] = 100 * 500 |
---|
[14938] | 257 | |
---|
[14940] | 258 | xmltext = """<payment_item_detail> |
---|
[14921] | 259 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 260 | <item_detail item_id="1" item_name="SUG" item_amt="%(amt1)d" bank_id="11" acct_num="0038079930" /> |
---|
| 261 | <item_detail item_id="2" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" /> |
---|
| 262 | <item_detail item_id="3" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" /> |
---|
[14938] | 263 | <item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" /> |
---|
[14921] | 264 | </item_details> |
---|
| 265 | </payment_item_detail>""" % xmldict |
---|
[14940] | 266 | |
---|
| 267 | # if student.faccode == 'SPAT': |
---|
| 268 | # xmltext = """<payment_item_detail> |
---|
| 269 | #<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 270 | #<item_detail item_id="1" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" /> |
---|
| 271 | #<item_detail item_id="2" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" /> |
---|
| 272 | #</item_details> |
---|
| 273 | #</payment_item_detail>""" % xmldict |
---|
| 274 | |
---|
[10765] | 275 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 276 | self.context.provider_amt = provider_amt |
---|
| 277 | self.context.gateway_amt = GATEWAY_AMT |
---|
[12479] | 278 | hashargs = ( |
---|
| 279 | self.context.p_id + |
---|
| 280 | PRODUCT_ID + |
---|
| 281 | self.pay_item_id + |
---|
| 282 | str(int(self.amount_auth)) + |
---|
| 283 | self.site_redirect_url + |
---|
| 284 | self.mac) |
---|
| 285 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
[10765] | 286 | return |
---|
| 287 | |
---|
[11638] | 288 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
[10765] | 289 | """ View which sends a POST request to the Interswitch |
---|
| 290 | CollegePAY payment gateway. |
---|
| 291 | """ |
---|
| 292 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 293 | action = POST_ACTION |
---|
| 294 | site_name = SITE_NAME |
---|
| 295 | currency = CURRENCY |
---|
[14729] | 296 | pay_item_id = '101' # must be provided by Interswitch |
---|
[10765] | 297 | product_id = PRODUCT_ID |
---|
[15021] | 298 | mac = MAC |
---|
[10765] | 299 | |
---|
| 300 | def update(self): |
---|
[12979] | 301 | error = self.init_update() |
---|
| 302 | if error: |
---|
| 303 | self.flash(error, type='danger') |
---|
| 304 | self.redirect(self.url(self.context, '@@index')) |
---|
| 305 | return |
---|
[10765] | 306 | xmldict = {} |
---|
[14731] | 307 | provider_amt = 500.0 |
---|
[14859] | 308 | gateway_amt = GATEWAY_AMT |
---|
[14810] | 309 | xmldict['institution_acct'] = '00000000' |
---|
| 310 | xmldict['institution_bank_id'] = '00' |
---|
| 311 | if self.applicant.__parent__.application_category in ('ndft', 'hndft'): |
---|
| 312 | xmldict['institution_acct'] = '0010761873' |
---|
[14815] | 313 | xmldict['institution_bank_id'] = '11' |
---|
[14810] | 314 | elif self.applicant.__parent__.application_category in ( |
---|
| 315 | 'ndpt', 'hndpt', 'ndwe', 'hndwe'): |
---|
| 316 | xmldict['institution_acct'] = '1015220292' |
---|
| 317 | xmldict['institution_bank_id'] = '117' |
---|
[14859] | 318 | elif self.applicant.applicant_id.startswith('special'): |
---|
| 319 | if self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys(): |
---|
| 320 | self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0] |
---|
| 321 | provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1] |
---|
| 322 | xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2] |
---|
| 323 | xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3] |
---|
| 324 | if self.pay_item_id in ('122', '123', '132', '137', '141', |
---|
| 325 | '142', '143', '144', '146', '147',): |
---|
| 326 | gateway_amt = round(0.015 * self.context.amount_auth, 2) |
---|
[10765] | 327 | xmldict['detail_ref'] = self.context.p_id |
---|
| 328 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 329 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 330 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 331 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
[14889] | 332 | xmldict['institution_amt'] = institution_amt = 100 * ( |
---|
| 333 | self.context.amount_auth - provider_amt - gateway_amt) |
---|
[12511] | 334 | xmldict['institution_item_name'] = self.context.category |
---|
[10765] | 335 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
| 336 | xmltext = """<payment_item_detail> |
---|
| 337 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 338 | <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" /> |
---|
| 339 | <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" /> |
---|
| 340 | </item_details> |
---|
| 341 | </payment_item_detail>""" % xmldict |
---|
[14889] | 342 | |
---|
| 343 | # isouaba: All certificates in SPAT are part time thus any payments |
---|
| 344 | # coming from those certificates (Application, Acceptance, school fees |
---|
| 345 | # etc) 40% should be split to keystone account. |
---|
| 346 | if self.applicant.__parent__.application_category in ( |
---|
| 347 | 'ndpt', 'hndpt', 'ndwe', 'hndwe'): |
---|
| 348 | xmldict['institution_amt_2'] = 0.4 * institution_amt |
---|
| 349 | xmldict['institution_amt_1'] = 0.6 * institution_amt |
---|
| 350 | xmltext = """<payment_item_detail> |
---|
| 351 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 352 | <item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 353 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 354 | <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" /> |
---|
| 355 | </item_details> |
---|
| 356 | </payment_item_detail>""" % xmldict |
---|
| 357 | |
---|
[10765] | 358 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 359 | self.context.provider_amt = provider_amt |
---|
| 360 | self.context.gateway_amt = GATEWAY_AMT |
---|
[12479] | 361 | |
---|
| 362 | hashargs = ( |
---|
| 363 | self.context.p_id + |
---|
| 364 | PRODUCT_ID + |
---|
| 365 | self.pay_item_id + |
---|
| 366 | str(int(self.amount_auth)) + |
---|
| 367 | self.site_redirect_url + |
---|
| 368 | self.mac) |
---|
| 369 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
[10765] | 370 | return |
---|
| 371 | |
---|
[11638] | 372 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
[10765] | 373 | InterswitchPaymentRequestWebservicePageStudent): |
---|
[13587] | 374 | """Request webservice view for the CollegePAY gateway |
---|
[10765] | 375 | """ |
---|
| 376 | grok.context(ICustomStudentOnlinePayment) |
---|
| 377 | product_id = PRODUCT_ID |
---|
| 378 | gateway_host = HOST |
---|
| 379 | gateway_url = URL |
---|
[15021] | 380 | mac = MAC |
---|
[10765] | 381 | |
---|
[13587] | 382 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
| 383 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
| 384 | """Payment verify view for the CollegePAY gateway |
---|
| 385 | """ |
---|
| 386 | grok.context(ICustomStudentOnlinePayment) |
---|
| 387 | product_id = PRODUCT_ID |
---|
| 388 | gateway_host = HOST |
---|
| 389 | gateway_url = URL |
---|
[15021] | 390 | mac = MAC |
---|
[13587] | 391 | |
---|
[11638] | 392 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
[10765] | 393 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
[13587] | 394 | """Request webservice view for the CollegePAY gateway |
---|
[10765] | 395 | """ |
---|
| 396 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 397 | product_id = PRODUCT_ID |
---|
| 398 | gateway_host = HOST |
---|
[12479] | 399 | gateway_url = URL |
---|
[15021] | 400 | mac = MAC |
---|
[13587] | 401 | |
---|
| 402 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
| 403 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
| 404 | """Payment verify view for the CollegePAY gateway |
---|
| 405 | """ |
---|
| 406 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 407 | product_id = PRODUCT_ID |
---|
| 408 | gateway_host = HOST |
---|
[14722] | 409 | gateway_url = URL |
---|
[15021] | 410 | mac = MAC |
---|