Ignore:
Timestamp:
11 Mar 2015, 17:08:34 (10 years ago)
Author:
uli
Message:

Restructure things a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/demo_provider.py

    r12723 r12734  
    22from waeup.ikoba.interfaces import MessageFactory as _
    33from waeup.ikoba.browser.layout import IkobaEditFormPage, action
    4 from waeup.ikoba.payments.interfaces import IPaymentGatewayService, IPayment
     4from waeup.ikoba.payments.interfaces import (
     5    IPaymentGatewayService, IPayment, IPayable, IPayer, IPayee,)
    56from waeup.ikoba.payments.payment import (
    6     Payment, get_payment, find_payable_from_payable_id)
     7    Payment, get_payment, find_payable_from_payable_id,
     8    PaymentProviderServiceBase)
    79
    810
     
    1012
    1113
    12 class DemoCreditcardPaymentService(grok.GlobalUtility):
     14class DemoCreditcardPaymentService(PaymentProviderServiceBase):
    1315    """A demo payment gateway service.
    1416
     
    2022    title = _(u'Credit Card (Demo Payments)')
    2123
    22     def create_payment(self, payer, payment_item_list=[],  payee=None):
     24    def create_payment(self, payer, payable,  payee=None):
    2325        """Create a payment.
    2426        """
    25         payment = Payment()
     27        if not IPayer.providedBy(payer):
     28            payer = IPayer(payer)
     29        if not IPayable.providedBy(payable):
     30            payable = IPayable(payable)
     31        if (payee is not None) and (not IPayee.providedBy(payee)):
     32            payee = IPayee(payee)
     33        payment = Payment(payer, payable, payee)
    2634        payment.gateway_service = 'demo_creditcard'  # must be grok.name above
    27         payment.payer_id = payer.payer_id
    28         # XXX: we should not have to store a payment before adding items
    29         site = grok.getSite()
    30         site['payments'][payment.payment_id] = payment
    31         for item in payment_item_list:
    32             payment.add_payment_item(item)
    3335        return payment
    3436
Note: See TracChangeset for help on using the changeset viewer.