Changeset 12690 for main


Ignore:
Timestamp:
8 Mar 2015, 19:20:02 (10 years ago)
Author:
uli
Message:

Make something was selected before proceed.

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

Legend:

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

    r12689 r12690  
    5050from waeup.ikoba.browser.interfaces import ICaptchaManager
    5151from waeup.ikoba.mandates.mandate import PasswordMandate
     52from waeup.ikoba.payments.interfaces import IPaymentGatewayServicesLister
    5253from waeup.ikoba.widgets.hrefwidget import HREFDisplayWidget
    5354from waeup.ikoba.utils.helpers import (
     
    15131514        payment gateway.
    15141515        """
    1515         from waeup.ikoba.payments.interfaces import IPaymentGatewayServicesLister
    15161516        lister = getUtility(IPaymentGatewayServicesLister)
    15171517        for name, service in lister().items():
    15181518            yield {'name': name, 'title': service.title}
    15191519
    1520     def update(self, CANCEL=None):
     1520    def update(self, CANCEL=None, gw=None):
    15211521        if self.context.state != CREATED or not self.context.fee_based:
    15221522            emit_lock_message(self)
    15231523            return
     1524        self.gw = gw
    15241525        super(SelectPaymentMethodPage, self).update()
    15251526        return
     
    15291530            style='primary', warning=WARNING_CON,)
    15301531    def confirm(self, **data):
    1531         IWorkflowInfo(self.context).fireTransition('await')
    1532         self.flash(_('Payment has been initiated.'))
     1532        if self.gw is None:
     1533            self.flash(_('Please pick a payment method.'),
     1534                       type='warning')
     1535        else:
     1536            IWorkflowInfo(self.context).fireTransition('await')
     1537            self.flash(_('Payment has been initiated.'))
    15331538        return
    15341539
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_browser.py

    r12689 r12690  
    15011501        contract.product_options = [prodoption,]
    15021502
    1503     def test_select_payment(self):
    1504         # select payment
     1503    def prepare_payment_select(self):
    15051504        IWorkflowState(self.customer).setState('approved')
    15061505        IWorkflowState(self.document).setState('verified')
     
    15131512        self.browser.getControl(name="form.password").value = 'cpwd'
    15141513        self.browser.getControl("Login").click()
    1515         # go to our contract
     1514
     1515    def test_select_payment(self):
     1516        # select payment
     1517        self.prepare_payment_select()
    15161518        self.browser.open('%s/CON1/edit' % self.contracts_path)
    15171519        self.browser.getControl("Proceed to checkout").click()
     
    15201522        self.assertTrue(
    15211523            'Credit Card (Demo Payments)' in self.browser.contents)
     1524
     1525    def test_select_payment_no_choice(self):
     1526        # we get warned if no payment was selected
     1527        self.prepare_payment_select()
     1528        never_ending_button_text = (
     1529            'Select payment method and proceed to payment gateway'
     1530            ' (final submission)')
     1531        self.browser.open(
     1532            '%s/CON1/select_payment_method' % self.contracts_path)
     1533        self.browser.getControl(never_ending_button_text).click()
     1534        self.assertTrue(
     1535            'Please pick a payment method' in self.browser.contents)
     1536
     1537    def test_select_payment_demo_provider(self):
     1538        # we can proceed with payments if we select a payment method
     1539        self.prepare_payment_select()
     1540        never_ending_button_text = (
     1541            'Select payment method and proceed to payment gateway'
     1542            ' (final submission)')
     1543        self.browser.open(
     1544            '%s/CON1/select_payment_method' % self.contracts_path)
     1545        radio_ctrl = self.browser.getControl(name='gw')
     1546        radio_ctrl.displayValue = ['Credit Card (Demo Payments)']
     1547        self.browser.getControl(never_ending_button_text).click()
     1548        self.assertTrue(
     1549            'Payment has been initiated.' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.