Changeset 8430 for main/waeup.uniben/trunk/src/waeup/uniben/interswitch
- Timestamp:
- 12 May 2012, 08:43:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/interswitch/browser.py
r8424 r8430 32 32 from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment 33 33 from waeup.uniben.applicants.interfaces import ICustomApplicantOnlinePayment 34 from waeup.uniben.students.utils import actions_after_student_payment35 from waeup.uniben.applicants.utils import actions_after_applicant_payment36 34 from waeup.uniben.interfaces import MessageFactory as _ 37 35 … … 91 89 return response 92 90 93 def query_interswitch(user, payment, view): 94 ob_class = view.__implemented__.__name__ 91 def query_interswitch(payment): 95 92 sr = get_SOAP_response(PRODUCT_ID, payment.p_id) 96 user.loggerInfo(ob_class, 'callback received: %s' % sr)97 93 wlist = sr.split(':') 98 94 if len(wlist) != 7: 99 view.flash(_('Invalid callback: ${a}', 100 mapping = {'a': wlist})) 101 user.loggerInfo(ob_class,'invalid callback: %s' % payment.p_id) 102 return False 95 msg = _('Invalid callback: ${a}', mapping = {'a': sr}) 96 log = 'invalid callback for payment %s: %s' % (payment.p_id, sr) 97 return False, msg, log 103 98 payment.r_code = wlist[0] 104 99 payment.r_desc = wlist[1] … … 107 102 payment.r_pay_reference = wlist[5] 108 103 if payment.r_code != '00': 109 view.flash(_('Unsuccessful callback: ${a}', mapping = {'a': wlist[1]}))110 user.loggerInfo(ob_class,'unsuccessful callback: %s' % payment.p_id)104 msg = _('Unsuccessful callback: ${a}', mapping = {'a': sr}) 105 log = 'usuccessful callback for payment %s: %s' % (payment.p_id, sr) 111 106 payment.p_state = 'failed' 112 return False 107 return False, msg, log 113 108 if payment.r_amount_approved != payment.amount_auth: 114 view.flash(_('Wrong amount')) 115 user.loggerInfo(ob_class,'successful callback but wrong amount: %s' 116 % payment.p_id) 109 msg = _('Callback amount does not match.') 110 log = 'wrong callback for payment %s: %s' % (payment.p_id, sr) 117 111 payment.p_state = 'failed' 118 return False 112 return False, msg, log 119 113 if wlist[4] != payment.p_id: 120 view.flash(_('Wrong transaction id')) 121 user.loggerInfo(ob_class,'successful callback but wrong transaction id: %s' 122 % payment.p_id) 114 msg = _('Callback transaction id does not match.') 115 log = 'wrong callback for payment %s: %s' % (payment.p_id, sr) 123 116 payment.p_state = 'failed' 124 return False 125 user.loggerInfo(ob_class,'successful callback: %s' % payment.p_id) 117 return False, msg, log 126 118 payment.p_state = 'paid' 127 119 payment.payment_date = datetime.now() 128 return True 120 msg = _('Successful callback received') 121 log = 'valid callback for payment %s: %s' % (payment.p_id, sr) 122 return True, msg, log 129 123 130 124 class InterswitchActionButtonStudent(APABStudent): 131 125 grok.order(1) 132 126 grok.context(ICustomStudentOnlinePayment) 127 grok.require('waeup.payStudent') 133 128 icon = 'actionicon_pay.png' 134 129 text = _('CollegePAY') … … 144 139 grok.order(1) 145 140 grok.context(ICustomApplicantOnlinePayment) 141 grok.require('waeup.payApplicant') 146 142 icon = 'actionicon_pay.png' 147 143 text = _('CollegePAY') … … 175 171 grok.order(2) 176 172 grok.context(ICustomStudentOnlinePayment) 173 grok.require('waeup.payStudent') 177 174 icon = 'actionicon_call.png' 178 175 text = _('Requery CollegePAY') … … 182 179 grok.order(2) 183 180 grok.context(ICustomApplicantOnlinePayment) 181 grok.require('waeup.payApplicant') 184 182 icon = 'actionicon_call.png' 185 183 text = _('Requery CollegePAY') … … 404 402 405 403 def update(self): 404 ob_class = self.__implemented__.__name__ 406 405 if self.context.p_state == 'paid': 407 406 self.flash(_('This ticket has already been paid.')) 408 407 return 409 408 student = self.context.getStudent() 410 if query_interswitch(student, self.context, self): 411 actions_after_student_payment(student, self.context, self) 409 success, msg, log = query_interswitch(self.context) 410 student.loggerInfo(ob_class, log) 411 if not success: 412 self.flash(msg) 413 return 414 success, msg, log = self.context.doAfterStudentPayment() 415 if log is not None: 416 student.loggerInfo(ob_class, log) 417 self.flash(msg) 412 418 return 413 419 … … 424 430 425 431 def update(self): 432 ob_class = self.__implemented__.__name__ 426 433 if self.context.p_state == 'paid': 427 434 self.flash(_('This ticket has already been paid.')) 428 435 return 429 436 applicant = self.context.__parent__ 430 if query_interswitch(applicant, self.context, self): 431 actions_after_applicant_payment(applicant, self) 437 success, msg, log = query_interswitch(self.context) 438 applicant.loggerInfo(ob_class, log) 439 if not success: 440 self.flash(msg) 441 return 442 success, msg, log = self.context.doAfterApplicantPayment() 443 if log is not None: 444 applicant.loggerInfo(ob_class, log) 445 self.flash(msg) 432 446 return 433 447
Note: See TracChangeset for help on using the changeset viewer.