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