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 1653 2007-03-28 02:35:25Z uli $ |
---|
11 | """ |
---|
12 | payment callback |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('Skins.check_online_payments') |
---|
16 | from AccessControl import Unauthorized |
---|
17 | import DateTime |
---|
18 | if context.portal_membership.isAnonymousUser(): |
---|
19 | return None |
---|
20 | |
---|
21 | request = context.REQUEST |
---|
22 | response = request.RESPONSE |
---|
23 | students = context.portal_url.getPortalObject().campus.students |
---|
24 | wftool = context.portal_workflow |
---|
25 | mtool = context.portal_membership |
---|
26 | member = mtool.getAuthenticatedMember() |
---|
27 | member_id = str(member) |
---|
28 | student_id = context.getStudentId() |
---|
29 | online_transactions = context.online_payments_import |
---|
30 | try: |
---|
31 | from Products.zdb import set_trace |
---|
32 | except: |
---|
33 | def set_trace(): |
---|
34 | pass |
---|
35 | def rwrite(s): |
---|
36 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
37 | response.write("%s<br>\n" % s) |
---|
38 | try: |
---|
39 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
40 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
41 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
42 | except: |
---|
43 | aq_portal = None |
---|
44 | |
---|
45 | query1 = Eq('portal_type','Payment') |
---|
46 | query2 = Eq('SearchableText',"Approved Successful") |
---|
47 | online_payments = aq_portal(query1 & query2) |
---|
48 | set_trace() |
---|
49 | online_transactions = context.online_payments_import |
---|
50 | |
---|
51 | for 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 |
---|