コード例 #1
1
ファイル: payment.py プロジェクト: Easyshop/Easyshop
    def handle_next_action(self, action, data):
        """
        """        
        customer = ICustomerManagement(self.context).getAuthenticatedCustomer()
        id = self.request.get("form.id")

        # figure out payment method type
        if id.startswith("bank_account"):
            payment_method = "direct-debit"
        elif id.startswith("credit_card"):
            payment_method = "credit-card"
        else:
            payment_method = id
        
        if id == "bank_account_new":
            depositor = self.request.get("form.depositor", u"")
            account_number = self.request.get("form.account_number", u"")
            bank_identification_code = self.request.get("form.bank_identification_code", u"")
            bank_name = self.request.get("form.bank_name", u"")

            id = self.context.generateUniqueId("BankAccount")
            bank_account = BankAccount(id)
            bank_account.account_number = account_number
            bank_account.bank_identification_code = bank_identification_code
            bank_account.bank_name = bank_name
            bank_account.depositor = depositor
        
            customer._setObject(id, bank_account)

        if id == "credit_card_new":            
            card_type = self.request.get("form.card_type", u"")
            card_number = self.request.get("form.card_number", u"")
            card_owner = self.request.get("form.card_owner", u"")
            card_expiration_date_month = self.request.get("form.card_expiration_date_month", u"")
            card_expiration_date_year = self.request.get("form.card_expiration_date_year", u"")
            
            id = self.context.generateUniqueId("CreditCard")
            credit_card = CreditCard(id)
            credit_card.card_type = card_type
            credit_card.card_number = card_number
            credit_card.card_owner = card_owner
            credit_card.card_expiration_date_month = card_expiration_date_month
            credit_card.card_expiration_date_year  = card_expiration_date_year
            
            customer._setObject(id, credit_card)
            
        elif id.startswith("bank_account_existing") or \
             id.startswith("credit_card_existing"):
            id = id.split(":")[1]
                
        customer.selected_payment_method      = payment_method
        customer.selected_payment_information = id
                    
        ICheckoutManagement(self.context).redirectToNextURL("SELECTED_PAYMENT_METHOD")
コード例 #2
0
    def testAdapters(self):
        """
        """
        adapter = IValidity(BankAccount("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(GenericPaymentMethod("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(PaymentPrice("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(CustomerTax("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(DefaultTax("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(ShippingPrice("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")
コード例 #3
0
    def handle_next_action(self, action, data):
        """
        """
        customer = ICustomerManagement(self.context).getAuthenticatedCustomer()
        id = self.request.get("form.id")

        # figure out payment method type
        if id.startswith("bank_account"):
            payment_method = "direct-debit"
        elif id.startswith("credit_card"):
            payment_method = "credit-card"
        else:
            payment_method = id

        if id == "bank_account_new":
            depositor = self.request.get("form.depositor", u"")
            account_number = self.request.get("form.account_number", u"")
            bank_identification_code = self.request.get(
                "form.bank_identification_code", u"")
            bank_name = self.request.get("form.bank_name", u"")

            id = self.context.generateUniqueId("BankAccount")
            bank_account = BankAccount(id)
            bank_account.account_number = account_number
            bank_account.bank_identification_code = bank_identification_code
            bank_account.bank_name = bank_name
            bank_account.depositor = depositor

            customer._setObject(id, bank_account)

        if id == "credit_card_new":
            card_type = self.request.get("form.card_type", u"")
            card_number = self.request.get("form.card_number", u"")
            card_owner = self.request.get("form.card_owner", u"")
            card_expiration_date_month = self.request.get(
                "form.card_expiration_date_month", u"")
            card_expiration_date_year = self.request.get(
                "form.card_expiration_date_year", u"")

            id = self.context.generateUniqueId("CreditCard")
            credit_card = CreditCard(id)
            credit_card.card_type = card_type
            credit_card.card_number = card_number
            credit_card.card_owner = card_owner
            credit_card.card_expiration_date_month = card_expiration_date_month
            credit_card.card_expiration_date_year = card_expiration_date_year

            customer._setObject(id, credit_card)

        elif id.startswith("bank_account_existing") or \
             id.startswith("credit_card_existing"):
            id = id.split(":")[1]

        customer.selected_payment_method = payment_method
        customer.selected_payment_information = id

        ICheckoutManagement(
            self.context).redirectToNextURL("SELECTED_PAYMENT_METHOD")
コード例 #4
0
    def createAndAdd(self, data):
        """
        """
        # add address
        id = self.context.generateUniqueId("BankAccount")

        direct_debit = BankAccount(id)
        direct_debit.account_number = data.get("account_number")
        direct_debit.bank_identification_code = data.get(
            "bank_identification_code")
        direct_debit.depositor = data.get("depositor")
        direct_debit.bank_name = data.get("bank_name")

        self.context._setObject(id, direct_debit)

        direct_debit.reindexObject()
        self.nextUrl()
コード例 #5
0
ファイル: bank_account.py プロジェクト: Easyshop/Easyshop
    def createAndAdd(self, data):
        """
        """
        # add address
        id = self.context.generateUniqueId("BankAccount")

        direct_debit = BankAccount(id)
        direct_debit.account_number = data.get("account_number")
        direct_debit.bank_identification_code = data.get("bank_identification_code")
        direct_debit.depositor = data.get("depositor")
        direct_debit.bank_name = data.get("bank_name")
        
        self.context._setObject(id, direct_debit)

        direct_debit.reindexObject()
        self.nextUrl()
コード例 #6
0
ファイル: copy_management.py プロジェクト: viona/Easyshop
    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