source: WAeUP_SRP/trunk/skins/waeup_epayment/pay_online.py @ 1359

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

simulate callback disabled
performance of getReviewInfo improved

  • Property svn:keywords set to Id
File size: 3.4 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: pay_online.py 1355 2007-01-25 20:49:22Z henrik $
11"""
12pay online
13"""
14from urllib import urlencode
15import logging
16logger = logging.getLogger('EPayment.PayOnline')
17import DateTime
18request = context.REQUEST
19wftool = context.portal_workflow
20students = context.portal_url.getPortalObject().campus.students
21
22student_id = context.getStudentId()
23student = getattr(students,student_id) 
24
25sbrain = context.students_catalog(id=student_id)[0]
26amount,description = context.getSchoolFee(sbrain.faculty)
27##res = context.portal_catalog(portal_type="Certificate",
28##                                     id = sbrain.course)
29##
30##if not res:
31##    logger.info('"%s","certificate not found", "%s"' % (student_id,course))
32##    sfc = "ART"
33##else:
34##    sfc = res[0].getPath().split('/')[-4]
35info = {}
36info['site_id'] = '300100100'
37info['currency_id'] = '566'
38info['amount'] = amount
39info['type_code'] = sbrain.faculty
40info['type_description'] = description
41info['pay_bill_to'] = sbrain.name
42info['pay_ship_to'] = "University of Benin"
43info['student_id'] = student_id
44info['student_name'] = sbrain.name
45info['student_email'] = sbrain.email
46now = DateTime.DateTime()
47info['date'] = now
48order_id = info['order_id'] = "%d" % int(now.timeTime()*1000)
49info['order_id'] = "%s%s" % (student_id[1:],order_id)
50p_id = "p%s" % order_id
51
52if student_id is None:
53    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
54   
55if context.portal_url().find('uniben-demo.waeup.org') >-1 or\
56   context.portal_url().find('uniben.waeup.org') >-1:
57    info['action'] = "http://www.wemaonlinepayments.biz/payment.aspx"
58else:
59    return None
60    #info['action'] = "%s/payments/%s/simulate_callback" % (student.absolute_url(),p_id) 
61
62
63if "payments" not in student.objectIds():
64    student.invokeFactory('PaymentsFolder','payments')
65    payments = getattr(student,'payments')
66    d = {}
67    d['Title'] = 'Payments'
68    payments.getContent().edit(mapping=d)
69    wftool.doActionFor(payments,'open')
70else:
71    payments = getattr(student,'payments')
72if request.has_key('epayment'):
73    return context.wema_form(info=info)
74
75
76payments.invokeFactory('Payment', p_id)
77payment = getattr(payments,p_id)
78wftool.doActionFor(payment,'open')
79d = {}
80d.update(info)
81#from Products.zdb import set_trace;set_trace()
82payment.getContent().edit(mapping=d)
83#wftool.doActionFor(payment,'close')
84#wftool.doActionFor(student,'pay_school_fee')
85info['callback_url'] = "%s/payments/%s/epayment_cb" % (student.absolute_url(),p_id)
86
87logger.info('"%(student_id)s","%(type_description)s", "%(amount)s N"' % info)
88payment_fields = (('x_SiteID','site_id'),
89                  ('x_Redirect_url','callback_url'),
90                  ('x_CurrencyID','currency_id'),
91                  ('x_PaymentCode','type_code'),
92                  ('x_PayDesc','type_description'),
93                  ('x_Billto','pay_bill_to'),
94                  ('x_Shipto','pay_ship_to'),
95                  ('x_PayerID','student_id'),
96                  ('x_PayerNames','student_name'),
97                  ('x_PayerEmail','student_email'),
98                  ('x_OrderID','order_id'),
99                  ('x_amt','amount'),
100                  )
101args = {}
102for arg,field in payment_fields:
103    args[arg] = info[field]
104url = info['action'] + "?" + urlencode(args)
105request.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.