1 | import grok |
---|
2 | from time import time |
---|
3 | from zope.component import createObject |
---|
4 | from waeup.sirp.students.browser import OnlinePaymentAddFormPage |
---|
5 | from waeup.custom.students.utils import getPaymentDetails |
---|
6 | |
---|
7 | class OnlinePaymentAddFormPage(OnlinePaymentAddFormPage): |
---|
8 | """ Page to add an online payment ticket |
---|
9 | """ |
---|
10 | |
---|
11 | @grok.action('Create ticket') |
---|
12 | def createTicket(self, **data): |
---|
13 | payment = createObject(u'waeup.StudentOnlinePayment') |
---|
14 | self.applyData(payment, **data) |
---|
15 | timestamp = "%d" % int(time()*1000) |
---|
16 | #order_id = "%s%s" % (student_id[1:],timestamp) |
---|
17 | payment.p_id = "p%s" % timestamp |
---|
18 | (payment.amount_auth, |
---|
19 | payment.p_item, payment.p_session, |
---|
20 | payment.surcharge_1, |
---|
21 | payment.surcharge_2, |
---|
22 | payment.surcharge_3) = getPaymentDetails( |
---|
23 | data['p_category'],self.context.__parent__) |
---|
24 | if payment.amount_auth == 0: |
---|
25 | self.flash('Payment amount could not be determined.') |
---|
26 | self.redirect(self.url(self.context, u'@@manage')) |
---|
27 | return |
---|
28 | self.context[payment.p_id] = payment |
---|
29 | self.flash('Payment ticket created.') |
---|
30 | self.redirect(self.url(self.context, u'@@manage')) |
---|
31 | return |
---|