source: WAeUP_SRP/trunk/skins/waeup_epayment/pay_interswitch_acco.py @ 3831

Last change on this file since 3831 was 3778, checked in by Henrik Bettermann, 16 years ago

resolve FCEOkene ticket #131

  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1## Script (Python) "pay_interswitch_acco"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=paytype=None
8##title=
9##
10# $Id: pay_interswitch_acco.py 3778 2008-11-20 06:37:12Z henrik $
11"""
12pay online
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19from urllib import urlencode
20import logging
21logger = logging.getLogger('Skins.pay_interswitch_acco')
22import DateTime
23
24if context.portal_membership.isAnonymousUser():
25    return None
26
27request = context.REQUEST
28wftool = context.portal_workflow
29students = context.portal_url.getPortalObject().campus.students
30
31student_id = context.getStudentId()
32if student_id is None:
33    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
34student = getattr(students,student_id)
35
36student_record = context.students_catalog.getRecordByKey(student_id)
37#amount,description = context.getSchoolFee(student_record.faculty,student_record.session,student_record.course)
38now = DateTime.DateTime()
39timestamp = "%d" % int(now.timeTime()*1000)
40payment_id = "p%s" % timestamp
41hostel = paytype == "HOM"
42if hostel:
43    info = context.getInterswitchParams(paytype,student,payment_id,student_record)
44    info['student'] = student_record
45
46info['pay_bill_to'] = student_record.name
47info['student_id'] = student_id
48info['student_name'] = student_record.name
49info['session_id'] = student_record.session
50info['student_email'] = student_record.email
51info['date'] = now
52info['order_id'] = "%s%s" % (student_id[1:],timestamp)
53
54if "payments" not in student.objectIds():
55    student.invokeFactory('PaymentsFolder','payments')
56    payments = getattr(student,'payments')
57    d = {}
58    d['Title'] = 'Payments'
59    payments.getContent().edit(mapping=d)
60    wftool.doActionFor(payments,'open')
61else:
62    payments = getattr(student,'payments')
63if request.has_key('epayment'):
64    return context.interswitch_form(info=info)
65
66
67payments.invokeFactory('Payment', payment_id)
68payment = getattr(payments,payment_id)
69wftool.doActionFor(payment,'open')
70d = {}
71d.update(info)
72payment.getContent().edit(mapping=d)
73#wftool.doActionFor(payment,'close')
74#wftool.doActionFor(student,'pay_school_fee')
75info['callback_url'] = "%s/payments/%s/%s?echo=%s" % (student.absolute_url(),
76                                                      payment_id,
77                                                      info['callback_function'],
78                                                      payment_id)
79
80logger.info('%(student_id)s initiated %(type_description)s payment with order_id %(order_id)s and callback url %(callback_url)s' % info)
81payment_fields = (('product_id','site_id'),
82                  ('site_name','site_name'),
83                  ('site_redirect_url','callback_url'),
84                  ('Currency','currency_id'),
85                  ('cust_id','student_id'),
86                  ('cust_id_desc','type_description'),
87                  ('cust_name','student_name'),
88                  ('txn_ref','order_id'),
89                  ('Amount','amount'),
90                  ('pay_item_id','pay_item_id'),
91                  ('pay_item_name','pay_item_name'),
92                  ('payment_params','payment_params'),
93                  )
94args = {}
95for arg,field in payment_fields:
96    args[arg] = info[field]
97interswitch_amount = int(info['surcharge'])*100
98uni_amount = int(info['amount'])*100
99total_amount = interswitch_amount + uni_amount
100args['Amount'] = "%d" % (total_amount)
101args['cust_name_desc'] = "Student Name"
102args['xml_data'] = info['xml_data'] =''
103info['args'] = args
104return context.goto_interswitch_form(info=info)
Note: See TracBrowser for help on using the repository browser.