[1224] | 1 | ## Script (Python) "epayment_cb" |
---|
| 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: epayment_cb.py 1349 2007-01-25 17:51:30Z joachim $ |
---|
| 11 | """ |
---|
| 12 | payment callback |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
[1348] | 15 | logger = logging.getLogger('EPayment.CallBack') |
---|
[1224] | 16 | import DateTime |
---|
| 17 | |
---|
| 18 | request = context.REQUEST |
---|
| 19 | students = context.portal_url.getPortalObject().campus.students |
---|
[1303] | 20 | wftool = context.portal_workflow |
---|
[1224] | 21 | student_id = context.getStudentId() |
---|
| 22 | if student_id is None: |
---|
| 23 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
| 24 | |
---|
| 25 | student = getattr(students,student_id) |
---|
| 26 | |
---|
[1246] | 27 | resp_codes = (("x_RespDesc","resp_desc"), |
---|
[1224] | 28 | ("x_RespPayRef","resp_pay_reference"), |
---|
| 29 | ("x_RespCode","resp_code"), |
---|
| 30 | ("x_CardNum","resp_card_num"), |
---|
| 31 | ("x_ApprAmt","resp_approved_amount"), |
---|
| 32 | ) |
---|
[1229] | 33 | pd = {} |
---|
[1243] | 34 | #from Products.zdb import set_trace;set_trace() |
---|
[1224] | 35 | for rc,pdk in resp_codes: |
---|
| 36 | pd[pdk] = request.get(rc) |
---|
[1229] | 37 | context.getContent().edit(mapping=pd) |
---|
[1349] | 38 | resp = pd['resp_desc'] |
---|
| 39 | if resp.startswith('Appro') and resp.endswith('essful'): |
---|
[1348] | 40 | wftool.doActionFor(student,'pay_school_fee') |
---|
| 41 | logger.info('"%s", "received valid callback"' % student_id) |
---|
[1349] | 42 | elif len(resp) < 3: |
---|
| 43 | logger.info('"%s", "received no callback"' % student_id) |
---|
[1348] | 44 | else: |
---|
[1349] | 45 | logger.info('"%s", "received unsuccessfull callback"' % student_id) |
---|
[1308] | 46 | wftool.doActionFor(context,'close') |
---|
[1303] | 47 | |
---|
[1304] | 48 | return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url()) |
---|