[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 | """ |
---|
| 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() |
---|
[1625] | 29 | online_transactions = context.online_payments_import |
---|
[1620] | 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) |
---|
[1845] | 38 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
[1620] | 39 | try: |
---|
| 40 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
| 41 | except: |
---|
[1845] | 42 | aq_portal = context.portal_catalog_real.evalAdvancedQuery |
---|
| 43 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
[1620] | 44 | |
---|
| 45 | query1 = Eq('portal_type','Payment') |
---|
[1845] | 46 | query2 = Eq('SearchableText',"Approved Successful") |
---|
[1620] | 47 | online_payments = aq_portal(query1 & query2) |
---|
| 48 | set_trace() |
---|
[1625] | 49 | online_transactions = context.online_payments_import |
---|
[1620] | 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) |
---|
[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 |
---|