source: main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/interfaces.py @ 12124

Last change on this file since 12124 was 12115, checked in by uli, 10 years ago

pep8, pyflakes.

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1## $Id: interfaces.py 12115 2014-12-02 08:34:20Z uli $
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##
18import decimal
19from zope import schema
20from waeup.ikoba.interfaces import (
21    IIkobaObject, SimpleIkobaVocabulary, ContextualDictSourceFactoryBase)
22from waeup.ikoba.interfaces import MessageFactory as _
23
24
25#: Possible states of payments
26STATE_UNPAID = 1
27STATE_PAID = 2
28STATE_FAILED = 4
29
30payment_states = SimpleIkobaVocabulary(
31    (_('Not yet paid'), STATE_UNPAID),
32    (_('Paid'), STATE_PAID),
33    (_('Failed'), STATE_FAILED),
34    )
35
36
37class PaymentCategorySource(ContextualDictSourceFactoryBase):
38    """A payment category source delivers all categories of payments.
39
40    """
41    #: name of dict to deliver from ikoba utils.
42    DICT_NAME = 'PAYMENT_CATEGORIES'
43
44
45class IPaymentsContainer(IIkobaObject):
46    """A container for all kind of payment objects.
47
48    """
49
50
51class IPayment(IIkobaObject):
52    """A base representation of payments.
53
54    """
55    payment_id = schema.TextLine(
56        title=u'Payment Identifier',
57        default=None,
58        required=True,
59        )
60
61    payer_id = schema.TextLine(
62        title=u'Payer',
63        default=None,
64        required=True,
65        )
66
67    payed_item_id = schema.TextLine(
68        title=u'Payed Item',
69        default=None,
70        required=True,
71        )
72
73    state = schema.Choice(
74        title=_(u'Payment State'),
75        default=STATE_UNPAID,
76        vocabulary=payment_states,
77        required=True,
78        )
79
80    creation_date = schema.Datetime(
81        title=_(u'Creation Date'),
82        readonly=False,
83        required=False,
84        )
85
86    payment_date = schema.Datetime(
87        title=_(u'Payment Date'),
88        required=False,
89        readonly=False,
90        )
91
92    amount = schema.Decimal(
93        title=_(u'Amount'),
94        description=_(
95            'The overall sum payed, including all taxes fees, etc.'),
96        default=decimal.Decimal("0.00"),
97        required=True,
98        readonly=False,
99        )
100
101
102class IOnlinePayment(IPayment):
103    """A payment via payment gateways.
104
105    """
106
107    ac = schema.TextLine(
108        title=_(u'Activation Code'),
109        default=None,
110        required=False,
111        readonly=False,
112        )
113
114    r_amount_approved = schema.Float(
115        title=_(u'Response Amount Approved'),
116        default=0.0,
117        required=False,
118        readonly=False,
119        )
120
121    r_code = schema.TextLine(
122        title=_(u'Response Code'),
123        default=None,
124        required=False,
125        readonly=False,
126        )
127
128    r_desc = schema.TextLine(
129        title=_(u'Response Description'),
130        default=None,
131        required=False,
132        readonly=False,
133        )
134
135    def approve():
136        "Approve an online payment and set to paid."
Note: See TracBrowser for help on using the repository browser.