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

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

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

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

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, True)
        
        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(['cash-on-delivery', 'credit-card', 'direct-debit'], 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", "credit-card"], ids)

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

        result = pm.deletePaymentMethod("prepayment")
        self.assertEqual(result, False)
    def testGetPaymentMethods(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentMethodManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(['cash-on-delivery', 'credit-card', 'direct-debit', 'paypal', 'prepayment'], ids)
Example #3
0
    def getPaymentMethods(self):
        """
        """
        shop = IShopManagement(self.context).getShop()
        pm = IPaymentMethodManagement(shop)

        result = []
        for payment_method in pm.getPaymentMethods():
            result.append({
                "id":
                payment_method.getId(),
                "title":
                payment_method.Title(),
                "url":
                payment_method.absolute_url(),
                "up_url":
                "%s/es_folder_position?position=up&id=%s" %
                (self.context.absolute_url(), payment_method.getId()),
                "down_url":
                "%s/es_folder_position?position=down&id=%s" %
                (self.context.absolute_url(), payment_method.getId()),
                "amount_of_criteria":
                self._getAmountOfCriteria(payment_method.getId())
            })

        return result
    def testGetPaymentMethods(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentMethodManagement(self.shop)

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual([
            'cash-on-delivery', 'credit-card', 'direct-debit', 'paypal',
            'prepayment'
        ], ids)
Example #5
0
    def _isValid(self, name):
        """Returns true if the payment method with given name is valid.
        """
        spm = IPaymentMethodManagement(self.context)
        dd = spm.getPaymentMethod(name)

        if dd is None or IValidity(dd).isValid() == False:
            return False
        else:
            return True
Example #6
0
 def _isValid(self, name):
     """Returns true if the payment method with given name is valid.
     """
     spm = IPaymentMethodManagement(self.context)
     dd = spm.getPaymentMethod(name)
     
     if dd is None or IValidity(dd).isValid() == False:
         return False
     else:
         return True
Example #7
0
    def getSelectablePaymentMethods(self):
        """Returns selectable payment methods.
        """
        customer = ICustomerManagement(self.context).getAuthenticatedCustomer()
        pm = IPaymentInformationManagement(customer)

        selected_payment_method = \
            pm.getSelectedPaymentMethod(check_validity=True)

        result = []
        pm = IPaymentMethodManagement(self.context)
        for payment in pm.getSelectablePaymentMethods(check_validity=True):

            # Todo: Make default payment method editable. ATM it is prepayment.
            # So if nothing is selected checked is true for prepayment.

            # If id is bank_account_new (this happens when customer wants to
            # add a new direct debit and is due to validation errors redirected to
            # the form).

            checked = False
            if (self.request.get("form.id", "") not in ("bank_account_new", "credit_card_new")) and \
               (selected_payment_method.getId() == safe_unicode(payment.getId())):
                checked = True

            result.append({
                "id": payment.getId(),
                "title": payment.Title(),
                "description": payment.Description(),
                "checked": checked,
            })

        return result
Example #8
0
    def _getPaymentMethodsAsDL(self):
        """Returns all payment methods as DisplayList.
        """
        dl = DisplayList()
        shop = IShopManagement(self).getShop()
        for method in IPaymentMethodManagement(shop).getPaymentMethods():
            dl.add(method.getId(), method.Title())

        return dl
Example #9
0
    def getPaymentMethodTypes(self):
        """Returns all *types* of payment methods of the current customer.
        """
        customer = ICustomerManagement(self.context).getAuthenticatedCustomer()
        pm = IPaymentMethodManagement(self.context)

        result = []
        for payment_method in pm.getPaymentMethods(check_validity=True):

            id = payment_method.getId()
            selected = (id == customer.selected_payment_method)

            result.append({
                "id": payment_method.getId(),
                "title": payment_method.Title(),
                "selected": selected,
            })

        return result
Example #10
0
    def getBankInformation(self):
        """
        """
        customer = self._getCustomer()
        if customer is None:
            return []

        result = []
        pm = IPaymentMethodManagement(customer)
        for payment_method in pm.getPaymentMethods(IBankAccount):
            result.append({
                "url"            : payment_method.absolute_url(),
                "account_number" : payment_method.getAccountNumber(),
                "bic"            : payment_method.getBankIdentificationCode(),
                "name"           : payment_method.getName(),
                "bank_name"      : payment_method.getBankName(),
            })

        return result
Example #11
0
    def getPaymentMethodTypes(self):
        """Returns all *types* of payment methods of the current customer.
        """
        customer = ICustomerManagement(self.context).getAuthenticatedCustomer()
        pm = IPaymentMethodManagement(self.context)
                
        result = []        
        for payment_method in pm.getPaymentMethods(check_validity=True):
            
            id = payment_method.getId()
            selected = (id == customer.selected_payment_method)
            
            result.append({            
                "id"       : payment_method.getId(),
                "title"    : payment_method.Title(),
                "selected" : selected,
            })

        return result
Example #12
0
    def getPaymentMethods(self):
        """
        """
        shop = IShopManagement(self.context).getShop()
        pm = IPaymentMethodManagement(shop)
                
        result = []
        for payment_method in pm.getPaymentMethods():            
            result.append({
            
                "id"       : payment_method.getId(),            
                "title"    : payment_method.Title(),
                "url"      : payment_method.absolute_url(),
                "up_url"   : "%s/es_folder_position?position=up&id=%s" % (self.context.absolute_url(), payment_method.getId()),
                "down_url" : "%s/es_folder_position?position=down&id=%s" % (self.context.absolute_url(), payment_method.getId()),
                "amount_of_criteria" : self._getAmountOfCriteria(payment_method.getId())
            })

        return result
Example #13
0
    def getBankInformation(self):
        """
        """
        customer = self._getCustomer()
        if customer is None:
            return []

        result = []
        pm = IPaymentMethodManagement(customer)
        for payment_method in pm.getPaymentMethods(IBankAccount):
            result.append({
                "url": payment_method.absolute_url(),
                "account_number": payment_method.getAccountNumber(),
                "bic": payment_method.getBankIdentificationCode(),
                "name": payment_method.getName(),
                "bank_name": payment_method.getBankName(),
            })

        return result
Example #14
0
 def getPaymentMethodInfo(self):
     """
     """
     # method
     customer = ICustomerManagement(self.context).getAuthenticatedCustomer()
     selected_payment_method = customer.selected_payment_method
     
     pm = IPaymentMethodManagement(self.context)
     method = pm.getPaymentMethod(selected_payment_method)
     
     # price
     pp = IPaymentPriceManagement(self.context)
     payment_price = pp.getPriceGross()
     cm = ICurrencyManagement(self.context)
     price = cm.priceToString(payment_price)
     
     return {
         "type"    : method.portal_type,
         "title"   : method.Title(),
         "price"   : price,
         "display" : payment_price != 0,
     }
Example #15
0
    def getPaymentMethodInfo(self):
        """
        """
        # method
        customer = ICustomerManagement(self.context).getAuthenticatedCustomer()
        selected_payment_method = customer.selected_payment_method

        pm = IPaymentMethodManagement(self.context)
        method = pm.getPaymentMethod(selected_payment_method)

        # price
        pp = IPaymentPriceManagement(self.context)
        payment_price = pp.getPriceGross()
        cm = ICurrencyManagement(self.context)
        price = cm.priceToString(payment_price)

        return {
            "type": method.portal_type,
            "title": method.Title(),
            "price": price,
            "display": payment_price != 0,
        }
    def testDeletePaymentMethod(self):
        """
        """
        pm = IPaymentMethodManagement(self.shop)

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

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

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

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

        ids = [p.getId() for p in pm.getPaymentMethods()]
        self.assertEqual(['cash-on-delivery', 'credit-card', 'direct-debit'],
                         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", "credit-card"], ids)

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

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