Changeset 12636 for main/waeup.ikoba


Ignore:
Timestamp:
28 Feb 2015, 13:56:26 (10 years ago)
Author:
uli
Message:

Make payment a container of PaymentItes?.

Location:
main/waeup.ikoba/branches/uli-fake-gw-provider/src/waeup/ikoba/payments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-fake-gw-provider/src/waeup/ikoba/payments/interfaces.py

    r12319 r12636  
    2020from zope import schema
    2121from zope.component import getUtilitiesFor
     22from zope.container.interfaces import IContainer
     23from zope.container.constraints import containers, contains
    2224from zope.interface import Interface
    2325from waeup.ikoba.interfaces import (
     
    115117
    116118
    117 class IPayment(IIkobaObject):
     119class ICreditCard(Interface):
     120    """A credit card.
     121
     122    A credit card is connected to a Payer.
     123    """
     124    credit_card_id = schema.TextLine(
     125        title=u'Internal Credit Card ID',
     126        required=True,
     127        )
     128
     129
     130class IPaymentItem(Interface):
     131    """Something to sell.
     132    """
     133    item_id = schema.TextLine(
     134        title=u'Payment Item ID',
     135        required=True,
     136        )
     137
     138    title = schema.TextLine(
     139        title=u'Title',
     140        description=u'A short title of the good sold.',
     141        required=True,
     142        default=u'Unnamed'
     143        )
     144
     145    amount = schema.Decimal(
     146        title=u'Amount',
     147        description=u'Total amount, includung any taxes, fees, etc.',
     148        required=True,
     149        default=decimal.Decimal('0.00'),
     150        )
     151
     152    currency = schema.Choice(
     153        title=u'Currency',
     154        source=ISO_4217_CURRENCIES_VOCAB,
     155        required=True,
     156        default='USD',
     157        )
     158
     159
     160class IPayment(IContainer):
    118161    """A base representation of payments.
    119162
     
    139182    we mark the payment 'failed'.
    140183    """
     184    contains(IPaymentItem)
     185
    141186    payment_id = schema.TextLine(
    142187        title=u'Payment Identifier',
     
    208253        """
    209254
    210 
    211 class IOnlinePayment(IPayment):
    212     """A payment via payment gateways.
    213 
    214     """
    215 
    216     ac = schema.TextLine(
    217         title=_(u'Activation Code'),
    218         default=None,
    219         required=False,
    220         readonly=False,
    221         )
    222 
    223     r_amount_approved = schema.Float(
    224         title=_(u'Response Amount Approved'),
    225         default=0.0,
    226         required=False,
    227         readonly=False,
    228         )
    229 
    230     r_code = schema.TextLine(
    231         title=_(u'Response Code'),
    232         default=None,
    233         required=False,
    234         readonly=False,
    235         )
    236 
    237     r_desc = schema.TextLine(
    238         title=_(u'Response Description'),
    239         default=None,
    240         required=False,
    241         readonly=False,
    242         )
    243 
    244     def approve():
    245         "Approve an online payment and set to paid."
    246 
    247 
    248 class ICreditCard(Interface):
    249     """A credit card.
    250 
    251     A credit card is connected to a Payer.
    252     """
    253     credit_card_id = schema.TextLine(
    254         title=u'Internal Credit Card ID',
    255         required=True,
    256         )
    257 
    258 
    259255class IPayer(Interface):
    260256    """A payer.
     
    283279        required=True
    284280        )
    285 
    286 
    287 class IPaymentItem(Interface):
    288     """Something to sell.
    289     """
    290     item_id = schema.TextLine(
    291         title=u'Payment Item ID',
    292         required=True,
    293         )
    294 
    295     title = schema.TextLine(
    296         title=u'Title',
    297         description=u'A short title of the good sold.',
    298         required=True,
    299         default=u'Unnamed'
    300         )
    301 
    302     amount = schema.Decimal(
    303         title=u'Amount',
    304         description=u'Total amount, includung any taxes, fees, etc.',
    305         required=True,
    306         default=decimal.Decimal('0.00'),
    307         )
    308 
    309     currency = schema.Choice(
    310         title=u'Currency',
    311         source=ISO_4217_CURRENCIES_VOCAB,
    312         required=True,
    313         default='USD',
    314         )
  • main/waeup.ikoba/branches/uli-fake-gw-provider/src/waeup/ikoba/payments/payment.py

    r12461 r12636  
    2828from waeup.ikoba.payments.interfaces import (
    2929    IPayment, STATE_UNPAID, STATE_FAILED, STATE_PAID,
    30     IPaymentGatewayService, IPayer, IPaymentItem,
     30    IPaymentGatewayService, IPayer, IPaymentItem, IPayee,
    3131    )
    3232from waeup.ikoba.utils.logger import Logger
     
    4949
    5050
    51 class Payment(grok.Model, Logger):
     51@attrs_to_fields
     52class Payment(grok.Container, Logger):
    5253    """This is a payment.
    5354    """
     
    6465        self.payment_date = None
    6566        self.payment_id = u'PAY_' + unicode(uuid.uuid4().hex)
    66         self.gateway_service = None
     67        #self.gateway_service = None
    6768        self.amount = decimal.Decimal("0.00")
    68         self.payed_item_id = None
    69         self.payer_id = None
     69        #self.payed_item_id = None
     70        #self.payer_id = None
    7071        self.state = STATE_UNPAID
    7172        return
     
    9798
    9899@attrs_to_fields
     100class Payer(object):
     101    """A Payment is for testing.
     102
     103    It cannot be stored in ZODB.
     104    """
     105    grok.implements(IPayer)
     106
     107
     108@attrs_to_fields
    99109class PaymentItem(grok.Model):
    100110
    101111    grok.implements(IPaymentItem)
     112
     113    def __init__(self):
     114        super(PaymentItem, self).__init__()
     115
     116
     117
     118@attrs_to_fields
     119class Payee(object):
     120    """Someone being paid.
     121
     122    This is for testing only and cannot be stored in ZODB.
     123    """
     124    grok.implements(IPayee)
Note: See TracChangeset for help on using the changeset viewer.