1 | ## $Id: interfaces.py 12186 2014-12-09 16:45:52Z 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 | from zope.interface import Attribute |
---|
19 | from zope import schema |
---|
20 | from waeup.ikoba.interfaces import ( |
---|
21 | IIkobaObject, SimpleIkobaVocabulary, |
---|
22 | ContextualDictSourceFactoryBase) |
---|
23 | from waeup.ikoba.interfaces import MessageFactory as _ |
---|
24 | |
---|
25 | payment_states = SimpleIkobaVocabulary( |
---|
26 | (_('Not yet paid'),'unpaid'), |
---|
27 | (_('Paid'),'paid'), |
---|
28 | (_('Failed'),'failed'), |
---|
29 | ) |
---|
30 | |
---|
31 | class PaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
32 | """A payment category source delivers all categories of payments. |
---|
33 | |
---|
34 | """ |
---|
35 | #: name of dict to deliver from ikoba utils. |
---|
36 | DICT_NAME = 'PAYMENT_CATEGORIES' |
---|
37 | |
---|
38 | class IPaymentsContainer(IIkobaObject): |
---|
39 | """A container for all kind of payment objects. |
---|
40 | |
---|
41 | """ |
---|
42 | |
---|
43 | class IPayment(IIkobaObject): |
---|
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'', |
---|
58 | default = None, |
---|
59 | required = False, |
---|
60 | ) |
---|
61 | |
---|
62 | display_item = schema.TextLine( |
---|
63 | title = _(u'Payment Item'), |
---|
64 | required = False, |
---|
65 | readonly = True, |
---|
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 | |
---|
94 | class IOnlinePayment(IPayment): |
---|
95 | """A payment via payment gateways. |
---|
96 | |
---|
97 | """ |
---|
98 | |
---|
99 | ac = schema.TextLine( |
---|
100 | title = _(u'Activation Code'), |
---|
101 | default = None, |
---|
102 | required = False, |
---|
103 | readonly = False, |
---|
104 | ) |
---|
105 | |
---|
106 | r_amount_approved = schema.Float( |
---|
107 | title = _(u'Response Amount Approved'), |
---|
108 | default = 0.0, |
---|
109 | required = False, |
---|
110 | readonly = False, |
---|
111 | ) |
---|
112 | |
---|
113 | r_code = schema.TextLine( |
---|
114 | title = _(u'Response Code'), |
---|
115 | default = None, |
---|
116 | required = False, |
---|
117 | readonly = False, |
---|
118 | ) |
---|
119 | |
---|
120 | r_desc = schema.TextLine( |
---|
121 | title = _(u'Response Description'), |
---|
122 | default = None, |
---|
123 | required = False, |
---|
124 | readonly = False, |
---|
125 | ) |
---|
126 | |
---|
127 | def approve(): |
---|
128 | "Approve an online payment and set to paid." |
---|