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

Last change on this file since 8794 was 1845, checked in by joachim, 17 years ago

modifications to use QueueCatalog?

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
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()
29online_transactions = context.online_payments_import
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)
38from Products.AdvancedQuery import Eq, Between, Le,In
39try:
40    aq_portal = context.portal_catalog.evalAdvancedQuery
41except:
42    aq_portal = context.portal_catalog_real.evalAdvancedQuery
43aq_students = context.students_catalog.evalAdvancedQuery
44
45query1 = Eq('portal_type','Payment')
46query2 = Eq('SearchableText',"Approved Successful")             
47online_payments = aq_portal(query1 & query2)
48set_trace()
49online_transactions = context.online_payments_import
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)
56    payment_id = op_brain.getId
57    if payment_doc.resp_code == "00" and not transactions:
58        rwrite('"%s","%s","no transaction for successfull payment","","%s"' % (student_id,payment_id,payment_doc.date))
59        continue
60    for transaction in transactions:
61        t_order_id = transaction.order_id
62        if t_order_id == order_id:
63            rwrite('"%s","%s","%s","%s","%s"' % (student_id,
64                                                                        op_brain.getId,
65                                                                        transaction.response_code,
66                                                                        payment_doc.resp_code,
67                                                                        payment_doc.date
68                                                                        ))
69            continue
Note: See TracBrowser for help on using the repository browser.