[8247] | 1 | ## $Id: payments.py 14296 2016-11-28 12:10:49Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | """ |
---|
| 19 | Student payment components. |
---|
| 20 | """ |
---|
| 21 | import grok |
---|
| 22 | from zope.component.interfaces import IFactory |
---|
| 23 | from zope.interface import implementedBy |
---|
[13043] | 24 | from zope.schema.interfaces import ConstraintNotSatisfied |
---|
| 25 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[8247] | 26 | from waeup.kofa.students.interfaces import IStudentNavigation |
---|
[13049] | 27 | from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID |
---|
[8247] | 28 | from waeup.kofa.utils.helpers import attrs_to_fields |
---|
[11622] | 29 | from waeup.kofa.accesscodes import create_accesscode |
---|
[13625] | 30 | from kofacustom.nigeria.students.payments import ( |
---|
| 31 | NigeriaStudentOnlinePayment, NigeriaStudentOnlinePaymentFactory) |
---|
[8444] | 32 | from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment |
---|
[8247] | 33 | |
---|
[13625] | 34 | class CustomStudentOnlinePayment(NigeriaStudentOnlinePayment): |
---|
[8421] | 35 | """This is a custom online payment for students. |
---|
| 36 | |
---|
| 37 | Since this class inherits from StudentOnlinePayment, it automatically |
---|
| 38 | implements the interfaces of the parent class which means |
---|
| 39 | all viewlets and views meant for StudentOnlinePayment |
---|
| 40 | can also be accessed in the customized system. |
---|
[8247] | 41 | """ |
---|
| 42 | grok.implements(ICustomStudentOnlinePayment, IStudentNavigation) |
---|
| 43 | grok.provides(ICustomStudentOnlinePayment) |
---|
| 44 | |
---|
| 45 | def __init__(self): |
---|
| 46 | super(CustomStudentOnlinePayment, self).__init__() |
---|
| 47 | return |
---|
| 48 | |
---|
[13043] | 49 | def redeemTicket(self): |
---|
[11622] | 50 | student = self.student |
---|
[13512] | 51 | if self.p_category in ('schoolfee', 'schoolfee_incl', 'schoolfee_1') : |
---|
[13043] | 52 | # Bypass activation code creation if next session |
---|
| 53 | # can be started directly. |
---|
| 54 | if student['studycourse'].next_session_allowed: |
---|
| 55 | try: |
---|
| 56 | if student.state == CLEARED: |
---|
| 57 | IWorkflowInfo(student).fireTransition( |
---|
| 58 | 'pay_first_school_fee') |
---|
| 59 | return None |
---|
| 60 | elif student.state == RETURNING: |
---|
| 61 | IWorkflowInfo(student).fireTransition( |
---|
| 62 | 'pay_school_fee') |
---|
| 63 | return None |
---|
| 64 | elif student.state == PAID: |
---|
| 65 | IWorkflowInfo(student).fireTransition( |
---|
| 66 | 'pay_pg_fee') |
---|
| 67 | return None |
---|
| 68 | except ConstraintNotSatisfied: |
---|
| 69 | pass |
---|
[11622] | 70 | # Create SFE access code |
---|
| 71 | pin, error = create_accesscode( |
---|
| 72 | 'SFE',0,self.amount_auth,student.student_id) |
---|
| 73 | if error: |
---|
| 74 | return error |
---|
| 75 | self.ac = pin |
---|
| 76 | elif self.p_category == 'bed_allocation': |
---|
| 77 | # Create HOS access code |
---|
| 78 | pin, error = create_accesscode( |
---|
| 79 | 'HOS',0,self.amount_auth,student.student_id) |
---|
| 80 | if error: |
---|
| 81 | return error |
---|
| 82 | self.ac = pin |
---|
[14296] | 83 | elif self.p_category.startswith('transcript'): |
---|
[11622] | 84 | # Create TSC access code |
---|
| 85 | pin, error = create_accesscode( |
---|
| 86 | 'TSC',0,self.amount_auth,student.student_id) |
---|
| 87 | if error: |
---|
| 88 | return error |
---|
| 89 | self.ac = pin |
---|
| 90 | return None |
---|
[8247] | 91 | |
---|
[9990] | 92 | CustomStudentOnlinePayment = attrs_to_fields( |
---|
| 93 | CustomStudentOnlinePayment, omit=['display_item']) |
---|
[8247] | 94 | |
---|
[13625] | 95 | class CustomStudentOnlinePaymentFactory(NigeriaStudentOnlinePaymentFactory): |
---|
[8247] | 96 | """A factory for student online payments. |
---|
| 97 | """ |
---|
| 98 | |
---|
| 99 | def __call__(self, *args, **kw): |
---|
| 100 | return CustomStudentOnlinePayment() |
---|
| 101 | |
---|
| 102 | def getInterfaces(self): |
---|
| 103 | return implementedBy(CustomStudentOnlinePayment) |
---|