source: main/waeup.kofa/trunk/src/waeup/kofa/payments/interfaces.py @ 16719

Last change on this file since 16719 was 16526, checked in by Henrik Bettermann, 3 years ago

Extend IPayer adapter.

  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1## $Id: interfaces.py 16526 2021-07-05 15:42:14Z 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##
18from zope.interface import Attribute
19from zope import schema
20from waeup.kofa.interfaces import (
21    IKofaObject, SimpleKofaVocabulary, academic_sessions_vocab,
22    ContextualDictSourceFactoryBase)
23from waeup.kofa.interfaces import MessageFactory as _
24
25payment_states = SimpleKofaVocabulary(
26    (_('Not yet paid'),'unpaid'),
27    (_('Paid'),'paid'),
28    (_('Failed'),'failed'),
29    (_('Fees waived'),'waived'),
30    (_('Scholarship'),'scholarship'),
31    )
32
33class PaymentCategorySource(ContextualDictSourceFactoryBase):
34    """A payment category source delivers all categories of payments.
35
36    """
37    #: name of dict to deliver from kofa utils.
38    DICT_NAME = 'PAYMENT_CATEGORIES'
39
40class PaymentOptionSource(ContextualDictSourceFactoryBase):
41    """A payment option source delivers all options of a payment.
42
43    """
44    #: name of dict to deliver from kofa utils.
45    DICT_NAME = 'PAYMENT_OPTIONS'
46
47class CombiPaymentCategorySource(ContextualDictSourceFactoryBase):
48    """A payment category source delivers all categories of payments.
49
50    """
51    #: name of dict to deliver from kofa utils.
52    DICT_NAME = 'COMBI_PAYMENT_CATEGORIES'
53
54class IPaymentsContainer(IKofaObject):
55    """A container for all kind of payment objects.
56
57    """
58
59class IPayment(IKofaObject):
60    """A base representation of payments.
61
62    """
63    p_id = Attribute('Payment identifier')
64
65    p_category = schema.Choice(
66        title = _(u'Payment Category'),
67        #default = u'schoolfee',
68        source = PaymentCategorySource(),
69        required = True,
70        )
71
72    p_option = schema.Choice(
73        title = _(u'Payment Option'),
74        source = PaymentOptionSource(),
75        required = False,
76        )
77
78    p_item = schema.TextLine(
79        title = u'',
80        default = None,
81        required = False,
82        )
83
84    p_combi = schema.List(
85        title = _(u'Combi Payment'),
86        value_type = schema.Choice(
87            source = CombiPaymentCategorySource(),
88            ),
89        required = False,
90        defaultFactory=list,
91        )
92
93    display_item = schema.TextLine(
94        title = _(u'Payment Item'),
95        required = False,
96        readonly = True,
97        )
98
99    p_session = schema.Choice(
100        title = _(u'Payment Session'),
101        source = academic_sessions_vocab,
102        required = True,
103        )
104
105    p_state = schema.Choice(
106        title = _(u'Payment State'),
107        default = u'unpaid',
108        vocabulary = payment_states,
109        required = True,
110        )
111
112    creation_date = schema.Datetime(
113        title = _(u'Ticket Creation Date'),
114        readonly = False,
115        required = False,
116        )
117
118    payment_date = schema.Datetime(
119        title = _(u'Payment Date'),
120        required = False,
121        readonly = False,
122        )
123
124    amount_auth = schema.Float(
125        title = _(u'Amount Authorized'),
126        default = 0.0,
127        required = True,
128        readonly = False,
129        )
130
131class IOnlinePayment(IPayment):
132    """A payment via payment gateways.
133
134    """
135
136    ac = schema.TextLine(
137        title = _(u'Activation Code'),
138        default = None,
139        required = False,
140        readonly = False,
141        )
142
143    r_amount_approved = schema.Float(
144        title = _(u'Response Amount Approved'),
145        default = 0.0,
146        required = False,
147        readonly = False,
148        )
149
150    r_code = schema.TextLine(
151        title = _(u'Response Code'),
152        default = None,
153        required = False,
154        readonly = False,
155        )
156
157    r_desc = schema.TextLine(
158        title = _(u'Response Description'),
159        default = None,
160        required = False,
161        readonly = False,
162        )
163
164    def approve():
165        "Approve an online payment and set to paid."
166
167class IPayer(IKofaObject):
168    """An interface for an adapter to publish student and applicant data
169    through a simple webservice. Also used in payment modules.
170
171    """
172    payer = Attribute("The payer object")
173    display_fullname = Attribute('Name of payer')
174    id = Attribute('Id of payer')
175    reg_number = Attribute('Reg number of payer')
176    matric_number = Attribute('Matric number of payer')
177    faculty = Attribute('Faculty of payer')
178    department = Attribute('Department of payer')
179    email= Attribute('Email of payer')
180    phone= Attribute('Phone number of payer')
181    current_mode= Attribute('Current study mode of payer')
182    current_level= Attribute('Current level of payer')
183
184    def doAfterPayment():
185        "Do after payment was made."
Note: See TracBrowser for help on using the repository browser.