source: main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/demo_provider.py @ 12708

Last change on this file since 12708 was 12704, checked in by uli, 10 years ago

At least step 1.

File size: 1.6 KB
Line 
1import grok
2from waeup.ikoba.interfaces import MessageFactory as _
3from waeup.ikoba.browser.layout import IkobaPage
4from waeup.ikoba.payments.interfaces import IPaymentGatewayService, IPayment
5from waeup.ikoba.payments.payment import Payment, get_payment
6
7
8grok.templatedir('templates')
9
10
11class DemoCreditcardPaymentService(grok.GlobalUtility):
12    """A demo payment gateway service.
13
14    This one supports credit card payments.
15    """
16    grok.implements(IPaymentGatewayService)
17    grok.name('demo_creditcard')
18
19    title = _(u'Credit Card (Demo Payments)')
20
21    def create_payment(self, payer, payment_item_list=[],  payee=None):
22        """Create a payment.
23        """
24        payment = Payment()
25        payment.gateway_service = 'demo_creditcard'  # must be grok.name above
26        payment.payer_id = payer.payer_id
27        # XXX: we should not have to store a payment before adding items
28        site = grok.getSite()
29        site['payments'][payment.payment_id] = payment
30        for item in payment_item_list:
31            payment.add_payment_item(item)
32        return payment
33
34    def next_step(self, payment_id):
35        """Tell where to go next.
36
37        Returns (context, view_name). Both may be none.
38        """
39        payment = get_payment(payment_id)
40        if payment is None:
41            return None, None
42        return payment, 'demo_cc1'
43
44
45class CreditCardStep1(IkobaPage):
46    grok.context(IPayment)
47    grok.name('demo_cc1')
48    grok.require('waeup.Public')
49    #grok.require('waeup.handleCustomer')
50    label = "Enter Credit Card Details"
51    grok.template('demo_cc_step1')
52    pnav = 0
53
54    def update(self):
55        print "UPDATE"
Note: See TracBrowser for help on using the repository browser.