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

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

Implement combi payments (tests will follow).

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