source: WAeUP_SRP/trunk/skins/waeup_epayment/interswitch_cb.py @ 1917

Last change on this file since 1917 was 1892, checked in by joachim, 17 years ago

mostly interswitch integration

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
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: interswitch_cb.py 1892 2007-06-13 15:57:09Z joachim $
11"""
12payment callback
13"""
14import logging
15logger = logging.getLogger('Skins.epayment_cb')
16from AccessControl import Unauthorized
17import DateTime
18if context.portal_membership.isAnonymousUser():
19    return None
20
21request = context.REQUEST
22students = context.portal_url.getPortalObject().campus.students
23wftool = context.portal_workflow
24mtool = context.portal_membership
25member = mtool.getAuthenticatedMember()
26member_id = str(member)
27student_id = context.getStudentId()
28if student_id is None or student_id != member_id:
29    logger.info('%s tried to access payment object of %s' % (member_id,student_id))
30    referer = request.get('HTTP_REFERER','none')
31    logger.info('%s:%s illegal access, referer = %s' % (member_id,student_id,referer))
32    real_ip = request.get('HTTP_X_REAL_IP',"none")
33    logger.info('%s:%s illegal access, real_x_ip = %s' % (member_id,student_id,real_ip))
34    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
35
36student = getattr(students,student_id)
37
38resp_codes = (("desc","resp_desc"),
39              ("resp","resp_code"),
40              ("txnref","pay_reference"),
41              ("payRet","resp_pay_reference"),
42              ("retRef","retRef"),
43              ("CardNum","resp_card_num"),
44              ("apprAmt","resp_approved_amount"),
45              )
46pd = {}
47#from Products.zdb import set_trace;set_trace()
48for rc,pdk in resp_codes:
49    pd[pdk] = request.get(rc)
50try:
51    context.getContent().edit(mapping=pd)
52except UnAuthorized,E:
53    logger.info('%s ' % student_id)
54
55#resp = pd['resp_desc']
56#if  resp.startswith('Appro') and resp.endswith('essful'):
57resp = pd['resp_code']
58if  resp == '00':
59    if context.getStudentReviewState() == "school_fee_paid":
60        logger.info('%s paid school_fee in state school_fee_paid' % (student_id))
61    else:
62        wftool.doActionFor(student,'pay_school_fee')
63    logger.info('%s received valid callback' % student_id)
64    referer = request.get('HTTP_REFERER','none')
65    logger.info('%s valid callback referer = %s' % (student_id,referer))
66    real_ip = request.get('HTTP_X_REAL_IP',"none")
67    logger.info('%s valid callback real_ip = %s' % (student_id,real_ip))
68
69else:
70    logger.info('%s received unsuccessfull callback' % student_id)
71try:
72    wftool.doActionFor(context,'close')
73except:
74    logger.info('%s no workflow action close' % student_id)
75       
76
77return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url())
Note: See TracBrowser for help on using the repository browser.