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

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

add resp_code to scratcard-payments

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