Changeset 7926
- Timestamp:
- 20 Mar 2012, 10:14:00 (13 years ago)
- Location:
- main/waeup.custom/trunk/src/waeup/custom
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py
r7919 r7926 26 26 from waeup.kofa.students.browser import write_log_message 27 27 from waeup.kofa.students.viewlets import RequestCallbackActionButton 28 from waeup.custom.utils.utils import actions_after_payment 28 29 from waeup.custom.interfaces import MessageFactory as _ 29 30 … … 171 172 return 172 173 173 class OnlinePaymentCallbackPage(UtilityView, grok.View):174 class InterswitchPaymentCallbackPage(UtilityView, grok.View): 174 175 """ Callback view for the CollegePAY gateway 175 176 """ … … 192 193 # Should be logged instead of printed 193 194 write_log_message(self,'callback received: %s' % query) 194 if query.get('resp', None) != '00': 195 196 self.context.r_card_num = query.get('cardNum', None) 197 self.context.r_code = query.get('resp', None) 198 self.context.r_pay_reference = query.get('payRef', None) 199 self.context.r_amount_approved = int(query.get('apprAmt', '0')) / 100 200 self.context.r_desc = query.get('desc', None) 201 202 if self.context.r_code != '00': 195 203 self.flash(_('Unsuccessful callback: ${a}', 196 204 mapping = {'a': query.get('desc', _('Incomplete query string.'))})) 197 205 write_log_message(self,'unsuccessful callback: %s' % self.context.p_id) 198 self.context.r_card_num = query.get('cardNum', None) 199 self.context.r_code = query.get('resp', None) 200 self.context.p_state = 'failed' 201 return 202 203 if query.get('apprAmt', None) != str(self.context.amount_auth): 206 self.context.p_state = 'failed' 207 return 208 209 total_amount_auth = ( 210 self.context.amount_auth 211 + self.context.surcharge_1 212 + self.context.surcharge_2) 213 214 if self.context.r_amount_approved != total_amount_auth: 204 215 self.flash(_('Wrong amount')) 205 216 write_log_message(self,'successful but wrong amount: %s' % self.context.p_id) 206 self.context.r_card_num = query.get('cardNum', None)207 self.context.r_code = query.get('resp', None)208 217 self.context.p_state = 'failed' 209 218 return … … 217 226 218 227 write_log_message(self,'valid callback: %s' % self.context.p_id) 219 self.context.r_amount_approved = self.context.amount_auth220 self.context.r_card_num = query.get('cardNum', None)221 self.context.r_code = query.get('resp', None)222 self.context.r_desc = query.get('desc', None)223 self.context.r_pay_reference = query.get('payRef', None)224 228 self.context.p_state = 'paid' 225 229 self.context.payment_date = datetime.now() 226 230 227 if self.context.p_category == 'clearance': 228 # Create CLR access code 229 pin, error = create_accesscode('CLR',0,student.student_id) 230 if error: 231 self.flash(_('Valid callback received. ${a}', 232 mapping = {'a':error})) 233 return 234 self.context.ac = pin 235 elif self.context.p_category == 'schoolfee': 236 # Create SFE access code 237 pin, error = create_accesscode('SFE',0,student.student_id) 238 if error: 239 self.flash(_('Valid callback received. ${a}', 240 mapping = {'a':error})) 241 return 242 self.context.ac = pin 243 elif self.context.p_category == 'bed_allocation': 244 # Create HOS access code 245 pin, error = create_accesscode('HOS',0,student.student_id) 246 if error: 247 self.flash(_('Valid callback received. ${a}', 248 mapping = {'a':error})) 249 return 250 self.context.ac = pin 251 self.flash(_('Valid callback received.')) 231 actions_after_payment(student, self.context, self) 232 252 233 return 253 234 … … 257 238 258 239 # Alternative solution, replaces OnlinePaymentCallbackPage 259 class OnlinePaymentRequestWebservicePage(UtilityView, grok.View):240 class InterswitchPaymentRequestWebservicePage(UtilityView, grok.View): 260 241 """ Request webservice view for the CollegePAY gateway 261 242 """ … … 279 260 self.context.r_code = wlist[0] 280 261 self.context.r_desc = wlist[1] 281 self.context.r_amount_approved = int(wlist[2]) 262 self.context.r_amount_approved = int(wlist[2]) / 100 282 263 self.context.r_card_num = wlist[3] 283 264 self.context.r_pay_reference = wlist[5] 284 265 285 if wlist[0]!= '00':266 if self.context.r_code != '00': 286 267 self.flash(_('Unsuccessful callback: ${a}', 287 268 mapping = {'a': wlist[1]})) … … 290 271 return 291 272 292 if wlist[2] != str(self.context.amount_auth): 273 total_amount_auth = ( 274 self.context.amount_auth 275 + self.context.surcharge_1 276 + self.context.surcharge_2) 277 278 if self.context.r_amount_approved != total_amount_auth: 293 279 self.flash(_('Wrong amount')) 294 280 write_log_message(self,'successful callback but wrong amount: %s' % self.context.p_id) … … 296 282 return 297 283 298 if wlist[ 5] != self.context.p_id:284 if wlist[4] != self.context.p_id: 299 285 self.flash(_('Wrong transaction id')) 300 286 write_log_message(self,'successful callback but wrong transaction id: %s' % self.context.p_id) … … 307 293 self.context.payment_date = datetime.now() 308 294 309 if self.context.p_category == 'clearance': 310 # Create CLR access code 311 pin, error = create_accesscode('CLR',0,student.student_id) 312 if error: 313 self.flash(_('Valid callback received. ${a}', 314 mapping = {'a':error})) 315 return 316 self.context.ac = pin 317 elif self.context.p_category == 'schoolfee': 318 # Create SFE access code 319 pin, error = create_accesscode('SFE',0,student.student_id) 320 if error: 321 self.flash(_('Valid callback received. ${a}', 322 mapping = {'a':error})) 323 return 324 self.context.ac = pin 325 elif self.context.p_category == 'bed_allocation': 326 # Create HOS access code 327 pin, error = create_accesscode('HOS',0,student.student_id) 328 if error: 329 self.flash(_('Valid callback received. ${a}', 330 mapping = {'a':error})) 331 return 332 self.context.ac = pin 333 self.flash(_('Valid callback received.')) 295 actions_after_payment(student, self.context, self) 296 334 297 return 335 298 -
main/waeup.custom/trunk/src/waeup/custom/interswitch/tests.py
r7897 r7926 73 73 self.assertMatches('...Failed...', 74 74 self.browser.contents) 75 self.browser.open(self.callback_url(payment_url, '00', '300 '))75 self.browser.open(self.callback_url(payment_url, '00', '300000')) 76 76 self.assertMatches('...Wrong amount...', 77 77 self.browser.contents) 78 self.browser.open(self.callback_url(payment_url, '00', '40000 '))78 self.browser.open(self.callback_url(payment_url, '00', '4000000')) 79 79 self.assertMatches('...Valid callback received...', 80 80 self.browser.contents) -
main/waeup.custom/trunk/src/waeup/custom/utils/utils.py
r7920 r7926 20 20 import os 21 21 from waeup.kofa.utils.utils import KofaUtils 22 from waeup.kofa.accesscodes import create_accesscode 23 from waeup.custom.interfaces import MessageFactory as _ 24 25 def actions_after_payment(student, payment, view): 26 if payment.p_category == 'clearance': 27 # Create CLR access code 28 pin, error = create_accesscode('CLR',0,student.student_id) 29 if error: 30 view.flash(_('Valid callback received. ${a}', 31 mapping = {'a':error})) 32 return 33 payment.ac = pin 34 elif payment.p_category == 'schoolfee': 35 # Create SFE access code 36 pin, error = create_accesscode('SFE',0,student.student_id) 37 if error: 38 view.flash(_('Valid callback received. ${a}', 39 mapping = {'a':error})) 40 return 41 payment.ac = pin 42 elif payment.p_category == 'bed_allocation': 43 # Create HOS access code 44 pin, error = create_accesscode('HOS',0,student.student_id) 45 if error: 46 view.flash(_('Valid callback received. ${a}', 47 mapping = {'a':error})) 48 return 49 payment.ac = pin 50 view.flash(_('Valid callback received.')) 51 return 22 52 23 53
Note: See TracChangeset for help on using the changeset viewer.