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

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

New Site ID

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