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