source: main/waeup.aaue/trunk/src/waeup/aaue/students/payments.py @ 17238

Last change on this file since 17238 was 15471, checked in by Henrik Bettermann, 5 years ago

Store xml split data in payment ticket.

  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1## $Id: payments.py 15471 2019-06-21 08:28:09Z 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"""
19Student payment components.
20"""
21import grok
22from zope.component.interfaces import IFactory
23from zope.interface import implementedBy
24from zope.schema.interfaces import ConstraintNotSatisfied
25from hurry.workflow.interfaces import IWorkflowInfo
26from waeup.kofa.students.interfaces import IStudentNavigation
27from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID
28from waeup.kofa.utils.helpers import attrs_to_fields
29from waeup.kofa.accesscodes import create_accesscode
30from kofacustom.nigeria.students.payments import (
31    NigeriaStudentOnlinePayment, NigeriaStudentOnlinePaymentFactory)
32from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment
33
34class CustomStudentOnlinePayment(NigeriaStudentOnlinePayment):
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.
41    """
42    grok.implements(ICustomStudentOnlinePayment, IStudentNavigation)
43    grok.provides(ICustomStudentOnlinePayment)
44
45    def __init__(self):
46        super(CustomStudentOnlinePayment, self).__init__()
47        return
48
49    def redeemTicket(self):
50        student = self.student
51        if self.p_category in ('schoolfee', 'schoolfee_incl', 'schoolfee_1'):
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
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
83        elif self.p_category.startswith('transcript'):
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
91
92CustomStudentOnlinePayment = attrs_to_fields(
93    CustomStudentOnlinePayment, omit=['display_item'])
94
95class CustomStudentOnlinePaymentFactory(NigeriaStudentOnlinePaymentFactory):
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)
Note: See TracBrowser for help on using the repository browser.