[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 1243 2007-01-08 17:39:17Z joachim $ |
---|
| 11 | """ |
---|
[1158] | 12 | pay online |
---|
[1147] | 13 | """ |
---|
| 14 | import logging |
---|
| 15 | logger = logging.getLogger('EPayment.') |
---|
| 16 | import DateTime |
---|
| 17 | request = context.REQUEST |
---|
| 18 | students = context.portal_url.getPortalObject().campus.students |
---|
| 19 | |
---|
| 20 | student_id = context.getStudentId() |
---|
| 21 | if student_id is None: |
---|
| 22 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
| 23 | |
---|
| 24 | student = getattr(students,student_id) |
---|
[1158] | 25 | sbrain = context.students_catalog(id=student_id)[0] |
---|
[1243] | 26 | amount,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] |
---|
[1147] | 35 | info = {} |
---|
[1243] | 36 | info['amount'] = amount |
---|
| 37 | info['type_code'] = sbrain.faculty |
---|
| 38 | info['type_description'] = description |
---|
[1224] | 39 | info['pay_bill_to'] = sbrain.name |
---|
| 40 | info['pay_ship_to'] = "University of Benin" |
---|
[1158] | 41 | info['student_id'] = student_id |
---|
| 42 | info['student_name'] = sbrain.name |
---|
| 43 | info['student_email'] = sbrain.email |
---|
[1226] | 44 | now = DateTime.DateTime() |
---|
[1243] | 45 | info['date'] = now |
---|
[1226] | 46 | order_id = info['order_id'] = "%d" % int(now.timeTime()*1000) |
---|
[1224] | 47 | info['order_id'] = "%s%s" % (student_id[1:],order_id) |
---|
| 48 | if "payments" not in student.objectIds(): |
---|
[1226] | 49 | student.invokeFactory('PaymentsFolder','payments') |
---|
[1224] | 50 | payments = getattr(student,'payments') |
---|
| 51 | d = {} |
---|
[1243] | 52 | d['Title'] = 'Payments' |
---|
[1226] | 53 | payments.getContent().edit(mapping=d) |
---|
[1243] | 54 | wftool.doActionFor(payments,'open') |
---|
[1224] | 55 | else: |
---|
| 56 | payments = getattr(student,'payments') |
---|
| 57 | p_id = "p%s" % order_id |
---|
| 58 | payments.invokeFactory('Payment', p_id) |
---|
| 59 | payment = getattr(payments,p_id) |
---|
| 60 | d = {} |
---|
| 61 | d.update(info) |
---|
[1243] | 62 | #from Products.zdb import set_trace;set_trace() |
---|
[1224] | 63 | payment.getContent().edit(mapping=d) |
---|
| 64 | info['callback_url'] = "%s/payments/%s/epayment_cb" % (student.absolute_url(),p_id) |
---|
[1243] | 65 | if context.portal_url().find('uniben-demo.waeup.org') >-1 or\ |
---|
| 66 | context.portal_url().find('uniben.waeup.org') >-1: |
---|
[1235] | 67 | info['action'] = "http://www.wemaonlinepayments.biz/payment.aspx" |
---|
| 68 | else: |
---|
| 69 | info['action'] = "%s/payments/%s/simulate_callback" % (student.absolute_url(),p_id) |
---|
[1226] | 70 | logger.info('"%(student_id)s","%(type_description)s", "%(amount)s N"' % info) |
---|
[1158] | 71 | return context.wema_form(info=info) |
---|