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

Last change on this file since 9405 was 9405, checked in by Henrik Bettermann, 12 years ago

Make payment categories more easily customizable.

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1## $Id: interfaces.py 9405 2012-10-24 21:31:48Z 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.university.vocabularies import ContextualDictSourceFactoryBase
21from waeup.kofa.interfaces import (
22    IKofaObject, SimpleKofaVocabulary, academic_sessions_vocab)
23from waeup.kofa.interfaces import MessageFactory as _
24
25payment_states = SimpleKofaVocabulary(
26    (_('Not yet paid'),'unpaid'),
27    (_('Paid'),'paid'),
28    (_('Failed'),'failed'),
29    )
30
31class PaymentCategorySource(ContextualDictSourceFactoryBase):
32    """A application category source delivers all special handling categories
33    provided for accommodation booking.
34    """
35    #: name of dict to deliver from kofa utils.
36    DICT_NAME = 'PAYMENT_CATEGORIES'
37
38class IPaymentsContainer(IKofaObject):
39    """A container for all kind of payment objects.
40
41    """
42
43class IPayment(IKofaObject):
44    """A base representation of payments.
45
46    """
47    p_id = Attribute('Payment identifier.')
48
49    p_category = schema.Choice(
50        title = _(u'Payment Category'),
51        default = u'schoolfee',
52        source = PaymentCategorySource(),
53        required = True,
54        )
55
56    p_item = schema.TextLine(
57        title = _(u'Payment Item'),
58        default = None,
59        required = False,
60        )
61
62    p_session = schema.Choice(
63        title = _(u'Payment Session'),
64        source = academic_sessions_vocab,
65        required = False,
66        )
67
68    p_state = schema.Choice(
69        title = _(u'Payment State'),
70        default = u'unpaid',
71        vocabulary = payment_states,
72        required = True,
73        )
74
75    creation_date = schema.Datetime(
76        title = _(u'Ticket Creation Date'),
77        readonly = False,
78        required = False,
79        )
80
81    payment_date = schema.Datetime(
82        title = _(u'Payment Date'),
83        required = False,
84        readonly = False,
85        )
86
87    amount_auth = schema.Float(
88        title = _(u'Amount Authorized'),
89        default = 0.0,
90        required = True,
91        readonly = False,
92        )
93
94class ISCPayment(IPayment):
95    """A scratch card payment.
96
97    """
98
99    p_code = schema.TextLine(
100        title = _(u'Payment Access Code'),
101        #default = u'Certificate XYZ',
102        required = False,
103        readonly = True,
104        )
105
106class IOnlinePayment(IPayment):
107    """A payment via payment gateways.
108
109    """
110
111    ac = schema.TextLine(
112        title = _(u'Activation Code'),
113        default = None,
114        required = False,
115        readonly = False,
116        )
117
118    r_amount_approved = schema.Float(
119        title = _(u'Response Amount Approved'),
120        default = 0.0,
121        required = False,
122        readonly = False,
123        )
124
125    r_code = schema.TextLine(
126        title = _(u'Response Code'),
127        default = None,
128        required = False,
129        readonly = False,
130        )
131
132    r_desc = schema.TextLine(
133        title = _(u'Response Description'),
134        default = None,
135        required = False,
136        readonly = False,
137        )
138
139    def approve():
140        "Approve an online payment and set to paid."
141
142class IPaymentWebservice(IKofaObject):
143    """An interface for a webservice.
144
145    """
146
147    def display_fullname():
148        "Name of  payee."
149
150    def id():
151        "Id of payee"
152
153    def faculty():
154        "Faculty of payee"
155
156    def department():
157        "Department of payee"
Note: See TracBrowser for help on using the repository browser.