source: WAeUP_SRP/trunk/skins/waeup_aaue/request_interswitch2.py @ 6858

Last change on this file since 6858 was 5264, checked in by Henrik Bettermann, 14 years ago

request payment goes live

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1## Script (Python) "pay_online"
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: request_interswitch2.py 5264 2010-07-14 13:21:21Z henrik $
11"""
12pay online
13"""
14from urllib import urlencode
15import logging
16logger = logging.getLogger('Skins.request_interswitch2')
17import DateTime
18
19if context.portal_membership.isAnonymousUser():
20    return None
21
22try:
23    from Products.zdb import set_trace
24except:
25    def set_trace():
26        pass
27request = context.REQUEST
28wftool = context.portal_workflow
29students = context.portal_url.getPortalObject().campus.students
30
31
32student_id = context.getStudentId()
33student = getattr(students,student_id)
34
35student_record = context.students_catalog.getRecordByKey(student_id)
36info = {}
37info['student'] = student_record
38info['payment_possible'] = False
39fee_dict = context.getSchoolFeeForRequest(student_record)
40fulltime = student_record.mode.endswith('_ft')
41
42if not fee_dict:
43    return context.interswitch_form(info=info)
44
45info['payment_possible'] = True
46info['type_description'] = fee_dict['description']
47info['student_id'] = student_id
48info['reg_no'] = student_record.jamb_reg_no
49info['matric_no'] = student_record.matric_no
50info['student_name'] = student_record.name
51info['type'] = 'request'
52info['status'] = 'started'
53info['session_id'] = fee_dict['next_session_id']
54info['session_str'] = fee_dict['next_session_str']
55info['item'] = student_record.course
56info['category'] = 'schoolfee2'
57info['student_email'] = student_record.email
58now = DateTime.DateTime()
59info['date'] = now
60info['pay_ship_to'] = "Ambrose Alli University Ekpoma"
61timestamp = "%d" % int(now.timeTime()*1000)
62info['order_id'] = "%s%s" % (student_id[1:],timestamp)
63p_id = "p%s" % timestamp
64
65if student_id is None:
66    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
67
68#query_url = "http://testwebpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx"
69query_url = "http://webpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx"
70
71info['callback_url'] = "%s/payments/%s/interswitch_request_cb2" % (student.absolute_url(),p_id)
72
73request_url = query_url
74request_url += '?redirectURL=%s' % info['callback_url']
75request_url += '&productid=53'
76request_url += '&merchantref=ignore'
77request_url += '&custNumber=%s' % student_id
78request_url += '&session=%s' % info['session_str']
79request_url += '&semester=Semester 2'
80
81info['request_url'] = request_url
82
83if "payments" not in student.objectIds():
84    student.invokeFactory('PaymentsFolder','payments')
85    payments = getattr(student,'payments')
86    d = {}
87    d['Title'] = 'Payments'
88    payments.getContent().edit(mapping=d)
89    wftool.doActionFor(payments,'open')
90else:
91    payments = getattr(student,'payments')
92
93payments.invokeFactory('Payment', p_id)
94payment = getattr(payments,p_id)
95wftool.doActionFor(payment,'open')
96d = {}
97d.update(info)
98payment.getContent().edit(mapping=d)
99
100logger.info('%(student_id)s initiated second school fee payment request with order_id %(order_id)s and request url %(request_url)s' % info)
101
102return context.interswitch_request_form(info=info)
Note: See TracBrowser for help on using the repository browser.