def testDeletePaymentMethod(self):
        """
        """            
        pm = IPaymentManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["paypal", "direct-debit", "prepayment", "cash-on-delivery"], ids)

        result = pm.deletePaymentMethod("paypal")
        self.assertEqual(result, True)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["direct-debit", "prepayment", "cash-on-delivery"], ids)

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, True)
        
        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["direct-debit", "cash-on-delivery"], ids)

        # delete payment validor
        result = pm.deletePaymentMethod("direct-debit")
        self.assertEqual(result, True)
        
        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["cash-on-delivery"], ids)

        result = pm.deletePaymentMethod("paypal")
        self.assertEqual(result, False)

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, False)
Esempio n. 2
0
    def testGetPaymentMethods_2(self):
        """Get paypal (with parameter=paypal)
        """
        pm = IPaymentManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods(interface=IPayPal)]
        self.assertEqual(["paypal"], ids)
    def testGetPaymentMethods_1(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["paypal", "direct-debit", "prepayment", "cash-on-delivery"], ids)
    def testGetPaymentMethods_2(self):
        """Get paypal (with parameter=paypal)
        """
        pm = IPaymentManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods(interface=IPayPal)]
        self.assertEqual(["paypal"], ids)
Esempio n. 5
0
    def testGetPaymentMethods_1(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["directdebit"], ids)
    def testGetPaymentMethods_1(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["directdebit"], ids)
Esempio n. 7
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
Esempio n. 8
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")
Esempio n. 9
0
    def testGetPaymentMethods_1(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(
            ["paypal", "direct-debit", "prepayment", "cash-on-delivery"], ids)
 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 testProcessSelectedPaymentMethod(self):
        """
        """
        self.order.manage_addProduct["EasyShop"].addCustomer("test")
        pm = IPaymentManagement(self.order)
        result = pm.processSelectedPaymentMethod()

        self.assertEqual(result, "NOT_PAYED")
 def testGetSelectedPaymentMethod(self):
     """
     """
     self.order.manage_addProduct["EasyShop"].addCustomer("test")
     pm = IPaymentManagement(self.order)
     m = pm.getSelectedPaymentMethod()
     
     self.assertEqual(m.getId(), "prepayment")
Esempio n. 13
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")
Esempio n. 14
0
    def _getPaymentMethodsAsDL(self):
        """Returns all payment methods as DisplayList.
        """
        dl = DisplayList()

        pm = IPaymentManagement(self)
        for payment_method in pm.getPaymentMethods():
            dl.add(payment_method.getId(), payment_method.Title())

        return dl
Esempio n. 15
0
    def _getPaymentMethodsAsDL(self):
        """Returns all payment methods as DisplayList.
        """
        dl = DisplayList()

        pm = IPaymentManagement(self)
        for payment_method in pm.getPaymentMethods():
            dl.add(payment_method.getId(), payment_method.Title())

        return dl
 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")
Esempio n. 17
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
Esempio n. 18
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
Esempio n. 19
0
 def isValid(self, product=None):
     """Returns true if the corresponding payment validator is not False and
     all contained criteria are True.
     """
     # First we check the general validity. For that we try to get the
     # corresponding payment validator.
     type   = IType(self.context).getType()
     pm     = IPaymentManagement(IShopManagement(self.context).getShop())
     method = pm.getPaymentMethod(type)
     
     # Only if we find one, we check validity. If we didn't find one, we
     # consider the general validity as fulfilled.
     if method and IValidity(method).isValid() == False:
         return False
     
     # If the non-validity isn't proved we check the criteria of context
     # (a customer payment method)
     return super(CustomerPaymentValidityManagement, self).isValid(product)
Esempio n. 20
0
    def isValid(self, product=None):
        """Returns true if the corresponding payment validator is not False and
        all contained criteria are True.
        """
        # First we check the general validity. For that we try to get the
        # corresponding payment validator.
        type = IType(self.context).getType()
        pm = IPaymentManagement(IShopManagement(self.context).getShop())
        method = pm.getPaymentMethod(type)

        # Only if we find one, we check validity. If we didn't find one, we
        # consider the general validity as fulfilled.
        if method and IValidity(method).isValid() == False:
            return False

        # If the non-validity isn't proved we check the criteria of context
        # (a customer payment method)
        return super(CustomerPaymentValidityManagement, self).isValid(product)
Esempio n. 21
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
Esempio n. 22
0
    def testDeletePaymentMethod(self):
        """
        """
        pm = IPaymentManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["directdebit"], ids)

        # Shop level payment methods shouldn't be deletable here.
        result = pm.deletePaymentMethod("paypal")
        self.assertEqual(result, False)

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, False)

        # still all there?
        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["directdebit"], ids)

        result = pm.deletePaymentMethod("directdebit")
        self.assertEqual(result, True)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual([], ids)
    def testDeletePaymentMethod(self):
        """
        """            
        pm = IPaymentManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["directdebit"], ids)

        # Shop level payment methods shouldn't be deletable here.
        result = pm.deletePaymentMethod("paypal")
        self.assertEqual(result, False)

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, False)
        
        # still all there?
        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["directdebit"], ids)

        result = pm.deletePaymentMethod("directdebit")        
        self.assertEqual(result, True)
                
        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual([], ids)
 def testGetSelectedPaymentMethod(self):
     """
     """
     pm = IPaymentManagement(self.customer)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "prepayment")
Esempio n. 25
0
    def testDeletePaymentMethod(self):
        """
        """
        pm = IPaymentManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(
            ["paypal", "direct-debit", "prepayment", "cash-on-delivery"], ids)

        result = pm.deletePaymentMethod("paypal")
        self.assertEqual(result, True)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["direct-debit", "prepayment", "cash-on-delivery"],
                         ids)

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, True)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["direct-debit", "cash-on-delivery"], ids)

        # delete payment validor
        result = pm.deletePaymentMethod("direct-debit")
        self.assertEqual(result, True)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(["cash-on-delivery"], ids)

        result = pm.deletePaymentMethod("paypal")
        self.assertEqual(result, False)

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, False)
Esempio n. 26
0
 def testGetSelectedPaymentMethod_1(self):
     """Customer has selected prepayment
     """
     pm = IPaymentManagement(self.shop)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "prepayment")