示例#1
0
    def testGetPaymentInformations(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentInformationManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual(["bank-account"], ids)
示例#2
0
    def getBankAccounts(self):
        """
        """
        if self._isValid("direct-debit") == False:
            return []

        cm = ICustomerManagement(self.context)
        customer = cm.getAuthenticatedCustomer()

        result = []
        pm = IPaymentInformationManagement(customer)

        for bank_account in pm.getPaymentInformations(interface=IBankAccount,
                                                      check_validity=True):

            selected_payment_information = \
                pm.getSelectedPaymentInformation(check_validity=True)

            if selected_payment_information and \
               selected_payment_information.getId() == bank_account.getId():
                checked = True
            else:
                checked = False

            result.append({
                "id": bank_account.getId(),
                "bic": bank_account.bank_identification_code,
                "account_no": bank_account.account_number,
                "depositor": bank_account.depositor,
                "bank_name": bank_account.bank_name,
                "checked": checked,
            })

        return result
    def testGetPaymentInformations(self):
        """Get all payment methods (without parameter)
        """
        pm = IPaymentInformationManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual(["bank-account"], ids)
示例#4
0
    def getCreditCards(self):
        """
        """
        if self._isValid("credit-card") == False:
            return []

        cm = ICustomerManagement(self.context)
        customer = cm.getAuthenticatedCustomer()

        result = []
        pm = IPaymentInformationManagement(customer)
        for credit_card in pm.getPaymentInformations(interface=ICreditCard,
                                                     check_validity=True):

            selected_payment_information = \
                pm.getSelectedPaymentInformation(check_validity=True)

            if selected_payment_information and \
               selected_payment_information.getId() == credit_card.getId():
                checked = True
            else:
                checked = False

            exp_date = "%s/%s" % (credit_card.card_expiration_date_month,
                                  credit_card.card_expiration_date_year)
            result.append({
                "id": credit_card.getId(),
                "type": credit_card.card_type,
                "owner": credit_card.card_owner,
                "number": credit_card.card_number,
                "expiration_date": exp_date,
                "checked": checked,
            })

        return result
示例#5
0
    def getBankAccounts(self):
        """
        """
        if self._isValid("direct-debit") == False:
            return []
        
        cm = ICustomerManagement(self.context)
        customer = cm.getAuthenticatedCustomer()
                
        result = []        
        pm = IPaymentInformationManagement(customer)

        for bank_account in pm.getPaymentInformations(
            interface=IBankAccount, check_validity=True):

            selected_payment_information = \
                pm.getSelectedPaymentInformation(check_validity=True)
                
            if selected_payment_information and \
               selected_payment_information.getId() == bank_account.getId():
                checked = True
            else:
                checked = False            
            
            result.append({
                "id"         : bank_account.getId(),
                "bic"        : bank_account.bank_identification_code,
                "account_no" : bank_account.account_number,
                "depositor"  : bank_account.depositor,
                "bank_name"  : bank_account.bank_name,
                "checked"    : checked,
            })
        
        return result
示例#6
0
    def getCreditCards(self):
        """
        """
        if self._isValid("credit-card") == False:
            return []
        
        cm = ICustomerManagement(self.context)
        customer = cm.getAuthenticatedCustomer()

        result = []        
        pm = IPaymentInformationManagement(customer)
        for credit_card in pm.getPaymentInformations(
            interface=ICreditCard, check_validity=True):

            selected_payment_information = \
                pm.getSelectedPaymentInformation(check_validity=True)
                
            if selected_payment_information and \
               selected_payment_information.getId() == credit_card.getId():
                checked = True
            else:
                checked = False            
            
            exp_date = "%s/%s" % (credit_card.card_expiration_date_month, 
                                  credit_card.card_expiration_date_year)
            result.append({
                "id"               : credit_card.getId(),
                "type"             : credit_card.card_type,
                "owner"            : credit_card.card_owner,
                "number"           : credit_card.card_number,
                "expiration_date"  : exp_date,
                "checked"          : checked,
            })
        
        return result
示例#7
0
    def testDeletePaymentInformations(self):
        """
        """
        pm = IPaymentInformationManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual(["bank-account"], ids)

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

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

        # still all there?
        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual(["bank-account"], ids)

        result = pm.deletePaymentInformation("bank-account")
        self.assertEqual(result, True)

        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual([], ids)
    def testDeletePaymentInformations(self):
        """
        """
        pm = IPaymentInformationManagement(self.customer)

        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual(["bank-account"], ids)

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

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

        # still all there?
        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual(["bank-account"], ids)

        result = pm.deletePaymentInformation("bank-account")
        self.assertEqual(result, True)

        ids = [p.getId() for p in pm.getPaymentInformations()]
        self.assertEqual([], ids)
示例#9
0
    def copyTo(self, target=None, new_id=None):
        """
        """
        if target is None:
            target = self.context.aq_inner.aq_parent

        if new_id is None:
            new_id = self.context.id

        wftool = getToolByName(self.context, "portal_workflow")

        new_customer = Customer(new_id)
        for field in ICustomer.names():
            setattr(new_customer, field, getattr(self.context, field))

        # Set object
        target._setObject(new_id, new_customer)
        new_customer = target[new_id]

        # NOTE: I know this is not really nice but it helps as there are some
        # permission problems with Zope's copy and paste, when it comes to
        # copying content as anonymous user, which is needed for anonymous
        # checkout -> copy the customer object to the new order.

        new_customer.firstname = self.context.firstname
        new_customer.lastname = self.context.lastname
        new_customer.email = self.context.email

        new_customer.selected_invoice_address = self.context.selected_invoice_address
        new_customer.selected_shipping_address = self.context.selected_shipping_address
        new_customer.selected_payment_method = self.context.selected_payment_method
        new_customer.selected_payment_information = self.context.selected_payment_information
        new_customer.selected_shipping_method = self.context.selected_shipping_method
        new_customer.selected_country = self.context.selected_country

        # Copy addresses
        session_addresses = IAddressManagement(self.context).getAddresses()
        for session_address in session_addresses:
            new_address = Address(session_address.id)
            for field in IAddress.names():
                setattr(new_address, field, getattr(session_address, field))
            new_customer._setObject(new_address.id, new_address)
            new_address = new_customer[new_address.id]
            wftool.notifyCreated(new_address)

        # Copy customer payment methods.
        pm = IPaymentInformationManagement(self.context)
        for session_direct_debit in pm.getPaymentInformations(IBankAccount):
            new_direct_debit = BankAccount(session_direct_debit.id)
            for field in IBankAccount.names():
                setattr(new_direct_debit, field,
                        getattr(session_direct_debit, field))
            new_customer._setObject(new_direct_debit.id, new_direct_debit)
            new_direct_debit = new_customer[new_direct_debit.id]
            wftool.notifyCreated(new_direct_debit)

        for session_credit_card in pm.getPaymentInformations(ICreditCard):
            new_credit_card = CreditCard(session_credit_card.id)
            for field in ICreditCard.names():
                setattr(new_credit_card, field,
                        getattr(session_credit_card, field))
            new_customer._setObject(new_credit_card.id, new_credit_card)
            new_credit_card = new_customer[new_credit_card.id]
            wftool.notifyCreated(new_credit_card)

        new_customer.reindexObject()
        wftool.notifyCreated(new_customer)

        return new_customer
示例#10
0
 def getCreditCards(self):
     """
     """
     pm  = IPaymentInformationManagement(self.context)
     return pm.getPaymentInformations(ICreditCard)
示例#11
0
 def getDirectDebitAccounts(self):
     """
     """
     pm  = IPaymentInformationManagement(self.context)
     return pm.getPaymentInformations(IBankAccount)
示例#12
0
    def copyTo(self, target=None, new_id=None):
        """
        """
        if target is None:
            target = self.context.aq_inner.aq_parent

        if new_id is None:
            new_id = self.context.id

        wftool = getToolByName(self.context, "portal_workflow")
        
        new_customer = Customer(new_id)
        for field in ICustomer.names():
            setattr(new_customer, field, getattr(self.context, field))

        # Set object
        target._setObject(new_id, new_customer)
        new_customer = target[new_id]
        
        # NOTE: I know this is not really nice but it helps as there are some
        # permission problems with Zope's copy and paste, when it comes to 
        # copying content as anonymous user, which is needed for anonymous 
        # checkout -> copy the customer object to the new order.

        new_customer.firstname = self.context.firstname
        new_customer.lastname  = self.context.lastname
        new_customer.email     = self.context.email
    
        new_customer.selected_invoice_address     = self.context.selected_invoice_address
        new_customer.selected_shipping_address    = self.context.selected_shipping_address
        new_customer.selected_payment_method      = self.context.selected_payment_method
        new_customer.selected_payment_information = self.context.selected_payment_information
        new_customer.selected_shipping_method     = self.context.selected_shipping_method
        new_customer.selected_country             = self.context.selected_country
        
        # Copy addresses    
        session_addresses = IAddressManagement(self.context).getAddresses()
        for session_address in session_addresses:
            new_address = Address(session_address.id)
            for field in IAddress.names():
                setattr(new_address, field, getattr(session_address, field))
            new_customer._setObject(new_address.id, new_address)
            new_address = new_customer[new_address.id]
            wftool.notifyCreated(new_address)

        # Copy customer payment methods.
        pm = IPaymentInformationManagement(self.context)
        for session_direct_debit in pm.getPaymentInformations(IBankAccount):
            new_direct_debit = BankAccount(session_direct_debit.id)
            for field in IBankAccount.names():
                setattr(new_direct_debit, field, getattr(session_direct_debit, field))
            new_customer._setObject(new_direct_debit.id, new_direct_debit)
            new_direct_debit = new_customer[new_direct_debit.id]
            wftool.notifyCreated(new_direct_debit)

        for session_credit_card in pm.getPaymentInformations(ICreditCard):
            new_credit_card = CreditCard(session_credit_card.id)
            for field in ICreditCard.names():
                setattr(new_credit_card, field, getattr(session_credit_card, field))
            new_customer._setObject(new_credit_card.id, new_credit_card)
            new_credit_card = new_customer[new_credit_card.id]
            wftool.notifyCreated(new_credit_card)
        
        new_customer.reindexObject()
        wftool.notifyCreated(new_customer)
        
        return new_customer
示例#13
0
 def getCreditCards(self):
     """
     """
     pm = IPaymentInformationManagement(self.context)
     return pm.getPaymentInformations(ICreditCard)
示例#14
0
 def getDirectDebitAccounts(self):
     """
     """
     pm = IPaymentInformationManagement(self.context)
     return pm.getPaymentInformations(IBankAccount)