## Script (Python) "check_online_payments" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: check_online_payments.py 1669 2007-04-04 06:31:52Z joachim $ """ payment callback """ import logging logger = logging.getLogger('Skins.check_online_payments') from AccessControl import Unauthorized import DateTime if context.portal_membership.isAnonymousUser(): return None request = context.REQUEST response = request.RESPONSE students = context.portal_url.getPortalObject().campus.students wftool = context.portal_workflow mtool = context.portal_membership member = mtool.getAuthenticatedMember() member_id = str(member) student_id = context.getStudentId() online_transactions = context.online_payments_import try: from Products.zdb import set_trace except: def set_trace(): pass def rwrite(s): response.setHeader('Content-type','text/html; charset=ISO-8859-15') response.write("%s
\n" % s) try: from Products.AdvancedQuery import Eq, Between, Le,In aq_portal = context.portal_catalog.evalAdvancedQuery aq_students = context.students_catalog.evalAdvancedQuery except: aq_portal = None query1 = Eq('portal_type','Payment') query2 = Eq('SearchableText',"Approved Successful") online_payments = aq_portal(query1 & query2) set_trace() online_transactions = context.online_payments_import for op_brain in online_payments: student_id = op_brain.getPath().split('/')[-3] payment_doc = op_brain.getObject().getContent() order_id = "%s%s" % (student_id[1:],op_brain.getId[1:]) transactions = online_transactions(student_id = student_id) payment_id = op_brain.getId if payment_doc.resp_code == "00" and not transactions: rwrite('"%s","%s","no transaction for successfull payment","","%s"' % (student_id,payment_id,payment_doc.date)) continue for transaction in transactions: t_order_id = transaction.order_id if t_order_id == order_id: rwrite('"%s","%s","%s","%s","%s"' % (student_id, op_brain.getId, transaction.response_code, payment_doc.resp_code, payment_doc.date )) continue