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