source: WAeUP_SRP/trunk/skins/waeup_epayment/pay_by_sc.py @ 1352

Last change on this file since 1352 was 1303, checked in by joachim, 18 years ago

add workflow transitions for online-payment.
don't display used scratchcard-pins.

  • Property svn:keywords set to Id
File size: 3.0 KB
RevLine 
[1274]1## Script (Python) "pay_by_sc"
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: pay_by_sc.py 1303 2007-01-15 17:17:11Z joachim $
11"""
12pay online
13"""
14import logging
15from urllib import urlencode
16logger = logging.getLogger('EPayment.')
17import DateTime
18lt = context.portal_layouts
19request = context.REQUEST
20students = context.portal_url.getPortalObject().campus.students
21
22student_id = context.getStudentId()
23if student_id is None:
[1283]24    return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
[1274]25
26student = getattr(students,student_id)
27sbrain = context.students_catalog(id=student_id)[0]
28amount,description = context.getSchoolFee(sbrain.faculty)
[1283]29res = context.portal_catalog(portal_type="Certificate",
30                                     id = sbrain.course)
31if not res:
[1303]32    logger.info('"%s","certificate not found", "%s"' % (student_id,sbrain.course))
[1283]33    prefix = ""
[1286]34else:
[1283]35    prefix = res[0].getObject().getContent().school_fee_code
36    if not prefix or prefix == 'none':
37        prefix = res[0].getPath().split('/')[-4]
38
39validate = request.has_key("cpsdocument_create_button")
[1274]40res,psm,ds = lt.renderLayout(layout_id= 'student_schoolfee',
41                      schema_id= 'epayment',
42                      context=context,
[1283]43                      mapping=validate and request,
[1274]44                      ob={},
45                      layout_mode="create",
46                      formaction = "pay_by_sc",
47                      button = 'Pay'
48                      )
49if psm == 'invalid':
50    psm = 'Please correct your errors!'
51    return context.pay_by_sc_form(rendered = res,
52                                 psm = psm,
53                                 mode = 'edit',
54                                 ds = ds,
55                                 )
56elif psm == '':
57    return context.pay_by_sc_form(rendered = res,
58                                 psm = None,
59                                 mode = 'edit',
60                                 ds = ds,
61                                 )
62elif psm == 'valid':
63    pass
64if "payments" not in student.objectIds():
65    student.invokeFactory('PaymentsFolder','payments')
66    payments = getattr(student,'payments')
67    d = {}
68    d['Title'] = 'Payments'
69    payments.getContent().edit(mapping=d)
70    wftool.doActionFor(payments,'open')
71else:
72    payments = getattr(student,'payments')
[1283]73#from Products.zdb import set_trace; set_trace()
[1274]74info = {}
[1283]75order_id = ds.get('pin_n')
[1274]76p_id = "p%s" % order_id
77now = DateTime.DateTime()
78info['date'] = now
[1286]79info['amount'] = "n/a"
[1283]80pin = info['order_id'] = ds.get('pin')
[1286]81info['type_code'] = "%s" % pin
82info['type_description'] = 'School Fee SC %s' % pin
[1274]83payments.invokeFactory('Payment', p_id)
84payment = getattr(payments,p_id)
[1283]85wftool = context.portal_workflow
86wftool.doActionFor(payment,'open')
[1274]87payment.getContent().edit(mapping=info)
[1283]88wftool.doActionFor(payment,'close')
[1286]89wftool.doActionFor(student,'pay_school_fee')
[1283]90url = "%s/payments" % (student.absolute_url())
[1274]91request.RESPONSE.redirect(url)
92
Note: See TracBrowser for help on using the repository browser.