Ignore:
Timestamp:
9 Mar 2015, 06:34:58 (10 years ago)
Author:
uli
Message:

At least step 1.

Location:
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba
Files:
2 added
2 edited

Legend:

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

    r12690 r12704  
    1818"""UI components for customers and related components.
    1919"""
    20 
    21 import sys
    2220import grok
    23 import pytz
    2421import os
    2522from urllib import urlencode
    26 from datetime import datetime
    2723from zope.event import notify
    2824from zope.i18n import translate
    2925from zope.catalog.interfaces import ICatalog
    3026from zope.component import queryUtility, getUtility, createObject
    31 from zope.schema.interfaces import ConstraintNotSatisfied, RequiredMissing
    32 from zope.formlib.textwidgets import BytesDisplayWidget
    3327from zope.security import checkPermission
    3428from hurry.workflow.interfaces import (
     
    4236from waeup.ikoba.browser.layout import (
    4337    IkobaPage, IkobaEditFormPage, IkobaAddFormPage, IkobaDisplayFormPage,
    44     IkobaForm, NullValidator, jsaction, action, UtilityView)
    45 from waeup.ikoba.widgets.datewidget import (
    46     FriendlyDateWidget, FriendlyDateDisplayWidget,
    47     FriendlyDatetimeDisplayWidget)
     38    NullValidator, jsaction, action, UtilityView)
    4839from waeup.ikoba.browser.pages import ContactAdminForm
    4940from waeup.ikoba.browser.breadcrumbs import Breadcrumb
    5041from waeup.ikoba.browser.interfaces import ICaptchaManager
    5142from waeup.ikoba.mandates.mandate import PasswordMandate
    52 from waeup.ikoba.payments.interfaces import IPaymentGatewayServicesLister
     43from waeup.ikoba.payments.payment import format_payment_item_values
     44from waeup.ikoba.payments.interfaces import (
     45    IPaymentGatewayServicesLister, IPaymentGatewayService, IPayer
     46    )
    5347from waeup.ikoba.widgets.hrefwidget import HREFDisplayWidget
    5448from waeup.ikoba.utils.helpers import (
    55     get_current_principal, to_timezone, now, format_date)
     49    get_current_principal, format_date)
    5650from waeup.ikoba.customers.interfaces import (
    5751    ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils,
    5852    ICustomerDocument, ICustomerDocumentsContainer, ICustomerCreate,
    5953    ICustomerPDFDocument, IContractsContainer, IContract,
    60     IContractSelectProduct, ISampleContract,
     54    IContractSelectProduct,
    6155    )
    6256from waeup.ikoba.customers.catalog import search
    6357from waeup.ikoba.customers.workflow import PAYMENT_TRANSITIONS
     58from waeup.ikoba.customers.contracts import payment_items_from_contract
     59
    6460
    6561grok.context(IIkobaObject)
     
    928924    def createDocument(self, **data):
    929925        form = self.request.form
    930         customer = self.context.__parent__
    931926        doctype = form.get('doctype', None)
    932927        # Here we can create various instances of CustomerDocument derived
     
    10991094        tableheader = []
    11001095        tabledata = []
    1101         contenttitle = []
    11021096        for i in range(1,3):
    11031097            tabledata.append(sorted(
     
    11351129    @property
    11361130    def label(self):
    1137         portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    11381131        return '%s of %s\nTitle: %s' % (
    11391132            self.context.translated_class_name,
     
    11421135
    11431136    def render(self):
    1144         portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    11451137        customerview = CustomerBasePDFFormPage(self.context.customer,
    11461138            self.request, self.omit_fields)
     
    11581150
    11591151    def render(self):
    1160         portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    11611152        customerview = CustomerBasePDFFormPage(self.context.customer,
    11621153            self.request, self.omit_fields)
     
    12961287    def createContract(self, **data):
    12971288        form = self.request.form
    1298         customer = self.context.__parent__
    12991289        contype = form.get('contype', None)
    13001290        # Here we can create various instances of Contract derived
     
    15341524                       type='warning')
    15351525        else:
     1526
     1527            service = queryUtility(IPaymentGatewayService, name=self.gw)
     1528            if service is None:
     1529                self.flash(_('Invalid payment gateway.'), type='danger')
     1530                return
     1531            payer = IPayer(self.context)
     1532            payment_items = payment_items_from_contract(self.context)
     1533            payment = service.create_payment(payer, payment_items)
     1534            payment, view_name = service.next_step(payment.payment_id)
     1535            url = self.url(payment, view_name)
     1536            self.flash(_('Payment has been initiated.'))
    15361537            IWorkflowInfo(self.context).fireTransition('await')
    1537             self.flash(_('Payment has been initiated.'))
     1538            self.redirect(url)
     1539            return
     1540
    15381541        return
    15391542
     
    16181621        tableheader = []
    16191622        tabledata = []
    1620         contenttitle = []
    16211623        for i in range(1,3):
    16221624            tabledata.append(sorted(
     
    16731675    @property
    16741676    def label(self):
    1675         portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    16761677        return self.context.title
    16771678
     
    16881689
    16891690    def render(self):
    1690         portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    16911691        customerview = CustomerBasePDFFormPage(self.context.customer,
    16921692            self.request, self.omit_fields)
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/demo_provider.py

    r12701 r12704  
    11import grok
    22from waeup.ikoba.interfaces import MessageFactory as _
    3 from waeup.ikoba.payments.interfaces import IPaymentGatewayService
     3from waeup.ikoba.browser.layout import IkobaPage
     4from waeup.ikoba.payments.interfaces import IPaymentGatewayService, IPayment
    45from waeup.ikoba.payments.payment import Payment, get_payment
     6
     7
     8grok.templatedir('templates')
    59
    610
     
    3640        if payment is None:
    3741            return None, None
    38         return payment, 'index'
     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 TracChangeset for help on using the changeset viewer.