Exemple #1
0
 def getSelectedPaymentMethod(self, check_validity=False):
     """
     """
     # First try to get the payment method on customer level. If it isn't
     # found, get it from shop level. (If it isn't found there, which
     # should never happen returns the default method; see shop/payment
     # for more information.)
     
     try:
         selected_method = getattr(
             self.context, 
             self.context.getSelectedPaymentMethod())
             
     except AttributeError:
         shop = self.context.getShop()
         pm = IPaymentManagement(shop)
         selected_method = pm.getSelectedPaymentMethod()
     
     # if selected payment method is not valid return default
     # Todo: Make default manageable    
     if check_validity == False:
         return selected_method
     else:
         if IValidity(selected_method).isValid() == False:
             shop = self.context.getShop()
             pm = IPaymentManagement(shop)
             return pm.getSelectedPaymentMethod(check_validity)
         else:
             return selected_method
Exemple #2
0
    def getSelectedPaymentMethod(self, check_validity=False):
        """
        """
        # First try to get the payment method on customer level. If it isn't
        # found, get it from shop level. (If it isn't found there, which
        # should never happen returns the default method; see shop/payment
        # for more information.)

        try:
            selected_method = getattr(self.context,
                                      self.context.getSelectedPaymentMethod())

        except AttributeError:
            shop = self.context.getShop()
            pm = IPaymentManagement(shop)
            selected_method = pm.getSelectedPaymentMethod()

        # if selected payment method is not valid return default
        # Todo: Make default manageable
        if check_validity == False:
            return selected_method
        else:
            if IValidity(selected_method).isValid() == False:
                shop = self.context.getShop()
                pm = IPaymentManagement(shop)
                return pm.getSelectedPaymentMethod(check_validity)
            else:
                return selected_method
 def testGetSelectedPaymentMethod_3(self):
     """Customer has selected a non existing. Returns default, which is 
     prepayment atm.
     """
     self.customer.setSelectedPaymentMethod("dummy")
     pm = IPaymentManagement(self.shop)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "prepayment")
 def testGetSelectedPaymentMethod(self):
     """
     """
     self.order.manage_addProduct["EasyShop"].addCustomer("test")
     pm = IPaymentManagement(self.order)
     m = pm.getSelectedPaymentMethod()
     
     self.assertEqual(m.getId(), "prepayment")
Exemple #5
0
 def testGetSelectedPaymentMethod_3(self):
     """Customer has selected a non existing. Returns default, which is 
     prepayment atm.
     """
     self.customer.setSelectedPaymentMethod("dummy")
     pm = IPaymentManagement(self.shop)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "prepayment")
 def testGetSelectedPaymentMethod_2(self):
     """Customer has selected paypal
     """
     cm = ICustomerManagement(self.shop)
     customer = cm.getAuthenticatedCustomer()        
     customer.setSelectedPaymentMethod("paypal")
     
     pm = IPaymentManagement(self.shop)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "paypal")
Exemple #7
0
    def testGetSelectedPaymentMethod_2(self):
        """Customer has selected paypal
        """
        cm = ICustomerManagement(self.shop)
        customer = cm.getAuthenticatedCustomer()
        customer.setSelectedPaymentMethod("paypal")

        pm = IPaymentManagement(self.shop)
        result = pm.getSelectedPaymentMethod().getId()
        self.assertEqual(result, "paypal")
Exemple #8
0
    def isComplete(self):
        """Checks weather the customer is complete to checkout.
        
           Customer completeness means the customer is ready to check out:
             1. Invoice address is complete
             2. Shipping address is complete
             3. Selected payment method is complete
             4. There a items in the cart            
        """
        # Get shop
        shop = self.context.getShop()

        # Get shipping and invoice address
        adressman = IAddressManagement(self.context)

        s_addr = adressman.getShippingAddress()
        if s_addr is None: return False

        i_addr = adressman.getInvoiceAddress()
        if i_addr is None: return False

        # Get payment method
        payman = IPaymentManagement(self.context)
        paymeth = payman.getSelectedPaymentMethod()

        # Get cart of the customer
        cart = ICartManagement(shop).getCart()

        # If there is no cart, the customer hasn't selected a product, hence
        # he is not complete
        if cart is None:
            return False

        im = IItemManagement(cart)

        # Check all for completeness
        # if at least one is False customer is not complete, too.
        for toCheck in s_addr, i_addr, paymeth:
            if ICompleteness(toCheck).isComplete() == False:
                return False

        # check items in cart
        if im.hasItems() == False:
            return False

        return True
Exemple #9
0
    def isComplete(self):
        """Checks weather the customer is complete to checkout.
        
           Customer completeness means the customer is ready to check out:
             1. Invoice address is complete
             2. Shipping address is complete
             3. Selected payment method is complete
             4. There a items in the cart            
        """        
        # Get shop
        shop = self.context.getShop()
        
        # Get shipping and invoice address
        adressman = IAddressManagement(self.context)
        
        s_addr = adressman.getShippingAddress()
        if s_addr is None: return False
        
        i_addr = adressman.getInvoiceAddress()
        if i_addr is None: return False

        # Get payment method
        payman = IPaymentManagement(self.context)
        paymeth = payman.getSelectedPaymentMethod()

        # Get cart of the customer
        cart = ICartManagement(shop).getCart()

        # If there is no cart, the customer hasn't selected a product, hence
        # he is not complete
        if cart is None:
            return False
            
        im = IItemManagement(cart)
        
        # Check all for completeness
        # if at least one is False customer is not complete, too.        
        for toCheck in s_addr, i_addr, paymeth:
            if ICompleteness(toCheck).isComplete() == False:
                return False
        
        # check items in cart
        if im.hasItems() == False:
            return False

        return True
 def testGetSelectedPaymentMethod(self):
     """
     """
     pm = IPaymentManagement(self.customer)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "prepayment")
Exemple #11
0
 def testGetSelectedPaymentMethod_1(self):
     """Customer has selected prepayment
     """
     pm = IPaymentManagement(self.shop)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "prepayment")