Changeset 8430 for main/waeup.uniben/trunk
- Timestamp:
- 12 May 2012, 08:43:51 (13 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py
r8378 r8430 269 269 270 270 """ 271 272 def doAfterApplicantPayment(): 273 """Process applicant after payment was made. 274 275 """ 276 277 def approveApplicantPayment(): 278 """Approve payment and process applicant. 279 280 """ -
main/waeup.uniben/trunk/src/waeup/uniben/applicants/utils.py
r8247 r8430 25 25 from waeup.uniben.interfaces import MessageFactory as _ 26 26 27 28 def actions_after_applicant_payment(applicant, view):29 wf_info = IWorkflowInfo(applicant)30 try:31 wf_info.fireTransition('pay')32 except InvalidTransitionError:33 view.flash('Error: %s' % sys.exc_info()[1])34 return35 27 36 28 class ApplicantsUtils(ApplicantsUtils): -
main/waeup.uniben/trunk/src/waeup/uniben/etranzact/browser.py
r8267 r8430 22 22 import grok 23 23 from waeup.kofa.browser.layout import KofaPage, UtilityView 24 from waeup.kofa. applicants.viewlets import RequestCallbackActionButton as RCABApplicant25 from waeup.kofa. students.viewlets import RequestCallbackActionButton as RCABStudent24 from waeup.kofa.students.viewlets import ApprovePaymentActionButton as APABStudent 25 from waeup.kofa.applicants.viewlets import ApprovePaymentActionButton as APABApplicant 26 26 from waeup.uniben.interfaces import MessageFactory as _ 27 from waeup.uniben.students.utils import actions_after_student_payment28 from waeup.uniben.applicants.utils import actions_after_applicant_payment29 27 from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment 30 28 from waeup.uniben.applicants.interfaces import ICustomApplicantOnlinePayment … … 35 33 QUERY_URL = 'http://demo.etranzact.com:8080/WebConnect/queryPayoutletTransaction.jsp' 36 34 37 def query_etranzact(confirmation_number, user, payment, view):38 ob_class = view.__implemented__.__name__35 def query_etranzact(confirmation_number, payment): 36 39 37 postdict = {} 40 38 postdict['TERMINAL_ID'] = TERMINAL_ID … … 45 43 f = urllib.urlopen(url=QUERY_URL, data=data) 46 44 success = f.read() 47 user.loggerInfo(ob_class, 'callback received: %s' % success)48 45 if 'COL1' not in success: 49 view.flash(_('Invalid or unsuccessful callback: ${a}',50 mapping = {'a': success}) )51 user.loggerInfo(ob_class, 'invalid callback: %s' % payment.p_id)46 msg = _('Invalid or unsuccessful callback: ${a}', 47 mapping = {'a': success}) 48 log = 'invalid callback for payment %s: %s' % (payment.p_id, success) 52 49 payment.p_state = 'failed' 53 return False 50 return False, msg, log 54 51 success = success.replace('%20',' ').split('&') 55 52 # We expect at least two parameters 56 53 if len(success) < 2: 57 view.flash(_('Invalid callback: ${a}', 58 mapping = {'a': success})) 59 user.loggerInfo(ob_class, 'invalid callback: %s' % payment.p_id) 54 msg = _('Invalid callback: ${a}', mapping = {'a': success}) 55 log = 'invalid callback for payment %s: %s' % (payment.p_id, success) 60 56 payment.p_state = 'failed' 61 return False 57 return False, msg, log 62 58 try: 63 59 success_dict = dict([tuple(i.split('=')) for i in success]) 64 60 except ValueError: 65 view.flash(_('Invalid callback: ${a}', 66 mapping = {'a': success})) 67 user.loggerInfo(ob_class, 'invalid callback: %s' % payment.p_id) 61 msg = _('Invalid callback: ${a}', mapping = {'a': success}) 62 log = 'invalid callback for payment %s: %s' % (payment.p_id, success) 68 63 payment.p_state = 'failed' 69 return False 64 return False, msg, log 70 65 except IOError: 71 view.flash(_('eTranzact IOError')) 72 return False 66 msg = _('eTranzact IOError') 67 log = 'eTranzact IOError' 68 return False, msg, log 73 69 payment.r_code = u'ET' 74 70 payment.r_desc = u'%s' % success_dict.get('TRANS_DESCR') … … 77 73 payment.r_pay_reference = u'%s' % success_dict.get('RECEIPT_NO') 78 74 if payment.r_amount_approved != payment.amount_auth: 79 view.flash(_('Wrong amount')) 80 user.loggerInfo(ob_class, 'successful callback but wrong amount: %s' 81 % payment.p_id) 75 msg = _('Wrong amount') 76 log = 'wrong callback for payment %s: %s' % (payment.p_id, success) 82 77 payment.p_state = 'failed' 83 return False 78 return False, msg, log 84 79 tcode = payment.p_id 85 80 tcode = tcode[len(tcode)-8:len(tcode)] … … 87 82 col1 = col1[len(col1)-8:len(col1)] 88 83 if tcode != col1: 89 view.flash(_('Wrong transaction code')) 90 write_log_message( 91 view,'successful callback but wrong transaction code: %s' 92 % payment.p_id) 93 user.loggerInfo(ob_class, 'successful callback wrong transaction code: %s' 94 % payment.p_id) 84 msg = _('Wrong transaction code') 85 log = 'wrong callback for payment %s: %s' % (payment.p_id, success) 95 86 payment.p_state = 'failed' 96 return False 97 user.loggerInfo(ob_class, 'successful callback: %s' % payment.p_id) 87 return False, msg, log 88 log = 'valid callback for payment %s: %s' % (payment.p_id, success) 89 msg = _('Successful callback received') 98 90 payment.p_state = 'paid' 99 91 payment.payment_date = datetime.now() 100 return True 92 return True, msg, log 101 93 102 class EtranzactEnterPinActionButtonApplicant( RCABApplicant):94 class EtranzactEnterPinActionButtonApplicant(APABApplicant): 103 95 grok.context(ICustomApplicantOnlinePayment) 96 grok.require('waeup.payApplicant') 104 97 grok.order(3) 105 98 icon = 'actionicon_call.png' … … 107 100 target = 'enterpin' 108 101 109 class EtranzactEnterPinActionButtonStudent( RCABStudent):102 class EtranzactEnterPinActionButtonStudent(APABStudent): 110 103 grok.context(ICustomStudentOnlinePayment) 104 grok.require('waeup.payStudent') 111 105 grok.order(3) 112 106 icon = 'actionicon_call.png' … … 140 134 141 135 def update(self, confirmation_number=None): 136 ob_class = self.__implemented__.__name__ 142 137 if self.context.p_state == 'paid': 143 138 self.flash(_('This ticket has already been paid.')) 144 139 return 145 140 student = self.context.getStudent() 146 if query_etranzact(confirmation_number, student, self.context, self): 147 actions_after_student_payment(student, self.context, self) 141 success, msg, log = query_etranzact(confirmation_number,self.context) 142 student.loggerInfo(ob_class, log) 143 if not success: 144 self.flash(msg) 145 return 146 success, msg, log = self.context.doAfterStudentPayment() 147 if log is not None: 148 student.loggerInfo(ob_class, log) 149 self.flash(msg) 148 150 return 149 151 … … 160 162 161 163 def update(self, confirmation_number=None): 164 ob_class = self.__implemented__.__name__ 162 165 if self.context.p_state == 'paid': 163 166 self.flash(_('This ticket has already been paid.')) 164 167 return 165 168 applicant = self.context.__parent__ 166 if query_etranzact(confirmation_number, applicant, self.context, self): 167 actions_after_applicant_payment(applicant, self) 169 success, msg, log = query_etranzact(confirmation_number,self.context) 170 applicant.loggerInfo(ob_class, log) 171 if not success: 172 self.flash(msg) 173 return 174 success, msg, log = self.context.doAfterApplicantPayment() 175 if log is not None: 176 applicant.loggerInfo(ob_class, log) 177 self.flash(msg) 168 178 return 169 179 -
main/waeup.uniben/trunk/src/waeup/uniben/etranzact/tests.py
r8271 r8430 109 109 configuration.application_fee = 1000.0 110 110 self.app['configuration'].addSessionConfiguration(configuration) 111 self.browser.open(self.manage_path) 111 112 self.browser.getControl("Add online").click() 112 113 self.assertMatches('...ticket created...', 113 114 self.browser.contents) 114 ctrl = self.browser.getControl(name='val_id')115 value = ctrl.options[0]116 self.browser.getLink(value).click()117 115 self.assertMatches('...Amount Authorized...', 118 116 self.browser.contents) -
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 -
main/waeup.uniben/trunk/src/waeup/uniben/payments/interfaces.py
r8263 r8430 40 40 ) 41 41 42 r_code = schema.TextLine( 43 title = _(u'Response Code'), 44 default = None, 45 required = False, 46 readonly = False, 47 ) 48 42 49 r_desc = schema.TextLine( 43 50 title = _(u'Response Description'), … … 47 54 ) 48 55 56 # Only defined in custom package 57 49 58 r_pay_reference = schema.TextLine( 50 59 title = _(u'Response Payment Reference'), 51 default = None,52 required = False,53 readonly = False,54 )55 56 r_code = schema.TextLine(57 title = _(u'Response Code'),58 60 default = None, 59 61 required = False, -
main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py
r8416 r8430 372 372 readonly = True, 373 373 ) 374 375 def doAfterStudentPayment(): 376 """Process student after payment was made. 377 378 """ 379 380 def approveStudentPayment(): 381 """Approve payment and process student. 382 383 """ 384 374 385 ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ 375 386 'p_session'].order -
main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
r8421 r8430 33 33 return fee 34 34 return 0.0 35 36 def actions_after_student_payment(student, payment, view):37 if payment.p_category == 'clearance':38 # Create CLR access code39 pin, error = create_accesscode('CLR',0,student.student_id)40 if error:41 view.flash(_('Valid callback received. ${a}',42 mapping = {'a':error}))43 return44 payment.ac = pin45 elif payment.p_category == 'schoolfee':46 # Create SFE access code47 pin, error = create_accesscode('SFE',0,student.student_id)48 if error:49 view.flash(_('Valid callback received. ${a}',50 mapping = {'a':error}))51 return52 payment.ac = pin53 elif payment.p_category == 'bed_allocation':54 # Create HOS access code55 pin, error = create_accesscode('HOS',0,student.student_id)56 if error:57 view.flash(_('Valid callback received. ${a}',58 mapping = {'a':error}))59 return60 payment.ac = pin61 view.flash(_('Valid callback received.'))62 return63 35 64 36 class CustomStudentsUtils(StudentsUtils):
Note: See TracChangeset for help on using the changeset viewer.