## Script (Python) "epayment_cb" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: epayment_cb.py 1365 2007-01-26 22:05:40Z henrik $ """ payment callback """ import logging logger = logging.getLogger('EPayment.CallBack') import DateTime if context.portal_membership.isAnonymousUser(): return None request = context.REQUEST students = context.portal_url.getPortalObject().campus.students wftool = context.portal_workflow student_id = context.getStudentId() if student_id is None: return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) student = getattr(students,student_id) resp_codes = (("x_RespDesc","resp_desc"), ("x_RespPayRef","resp_pay_reference"), ("x_RespCode","resp_code"), ("x_CardNum","resp_card_num"), ("x_ApprAmt","resp_approved_amount"), ) pd = {} #from Products.zdb import set_trace;set_trace() for rc,pdk in resp_codes: pd[pdk] = request.get(rc) context.getContent().edit(mapping=pd) resp = pd['resp_desc'] if resp.startswith('Appro') and resp.endswith('essful'): wftool.doActionFor(student,'pay_school_fee') logger.info('"%s", "received valid callback"' % student_id) elif len(resp) < 3: logger.info('"%s", "received no callback"' % student_id) else: logger.info('"%s", "received unsuccessfull callback"' % student_id) wftool.doActionFor(context,'close') return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url())