source: WAeUP_SRP/trunk/skins/waeup_epayment/check_online_payments.py @ 5594

Last change on this file since 5594 was 1845, checked in by joachim, 18 years ago

modifications to use QueueCatalog?

  • Property svn:keywords set to Id
File size: 2.5 KB
RevLine 
[1620]1## Script (Python) "check_online_payments"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: check_online_payments.py 1845 2007-06-02 11:01:49Z joachim $
11"""
12payment callback
13"""
14import logging
15logger = logging.getLogger('Skins.check_online_payments')
16from AccessControl import Unauthorized
17import DateTime
18if context.portal_membership.isAnonymousUser():
19    return None
20
21request = context.REQUEST
22response = request.RESPONSE
23students = context.portal_url.getPortalObject().campus.students
24wftool = context.portal_workflow
25mtool = context.portal_membership
26member = mtool.getAuthenticatedMember()
27member_id = str(member)
28student_id = context.getStudentId()
[1625]29online_transactions = context.online_payments_import
[1620]30try:
31    from Products.zdb import set_trace
32except:
33    def set_trace():
34        pass
35def rwrite(s):
36    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
37    response.write("%s<br>\n" % s)
[1845]38from Products.AdvancedQuery import Eq, Between, Le,In
[1620]39try:
40    aq_portal = context.portal_catalog.evalAdvancedQuery
41except:
[1845]42    aq_portal = context.portal_catalog_real.evalAdvancedQuery
43aq_students = context.students_catalog.evalAdvancedQuery
[1620]44
45query1 = Eq('portal_type','Payment')
[1845]46query2 = Eq('SearchableText',"Approved Successful")             
[1620]47online_payments = aq_portal(query1 & query2)
48set_trace()
[1625]49online_transactions = context.online_payments_import
[1620]50
51for op_brain in online_payments:
52    student_id = op_brain.getPath().split('/')[-3]
53    payment_doc = op_brain.getObject().getContent()
54    order_id = "%s%s" % (student_id[1:],op_brain.getId[1:])
55    transactions = online_transactions(student_id = student_id)
[1623]56    payment_id = op_brain.getId
[1620]57    if payment_doc.resp_code == "00" and not transactions:
[1623]58        rwrite('"%s","%s","no transaction for successfull payment","","%s"' % (student_id,payment_id,payment_doc.date))
[1620]59        continue
60    for transaction in transactions:
61        t_order_id = transaction.order_id
62        if t_order_id == order_id:
[1623]63            rwrite('"%s","%s","%s","%s","%s"' % (student_id,
[1624]64                                                                        op_brain.getId,
[1620]65                                                                        transaction.response_code,
[1623]66                                                                        payment_doc.resp_code,
67                                                                        payment_doc.date
[1620]68                                                                        ))
69            continue
Note: See TracBrowser for help on using the repository browser.