source: WAeUP_SRP/trunk/skins/waeup_epayment/epayment_cb.py @ 1472

Last change on this file since 1472 was 1367, checked in by Henrik Bettermann, 18 years ago

successful payment depends on respond code

  • Property svn:keywords set to Id
File size: 1.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: epayment_cb.py 1367 2007-01-28 08:51:36Z henrik $
11"""
12payment callback
13"""
14import logging
15logger = logging.getLogger('EPayment.CallBack')
16import DateTime
17if context.portal_membership.isAnonymousUser():
18    return None
19
20request = context.REQUEST
21students = context.portal_url.getPortalObject().campus.students
22wftool = context.portal_workflow
23student_id = context.getStudentId()
24if student_id is None:
25    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
26
27student = getattr(students,student_id)
28
29resp_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              )
35pd = {}
36#from Products.zdb import set_trace;set_trace()
37for rc,pdk in resp_codes:
38    pd[pdk] = request.get(rc)
39context.getContent().edit(mapping=pd)
40#resp = pd['resp_desc']
41#if  resp.startswith('Appro') and resp.endswith('essful'):
42resp = pd['resp_code']
43if  resp == '00':
44    wftool.doActionFor(student,'pay_school_fee')
45    logger.info('"%s", "received valid callback"' % student_id)
46
47elif len(resp) < 3:
48    logger.info('"%s", "received no callback"' % student_id)
49else:
50    logger.info('"%s", "received unsuccessfull callback"' % student_id)
51wftool.doActionFor(context,'close')
52
53return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url())
Note: See TracBrowser for help on using the repository browser.