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 = IShopManagement(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 = IShopManagement(self.context).getShop() pm = IPaymentManagement(shop) return pm.getSelectedPaymentMethod(check_validity) else: return selected_method
def _getPaymentMethodsAsDL(self): """Returns all payment methods as DisplayList. """ dl = DisplayList() pm = IPaymentManagement(IShopManagement(self).getShop()) for payment_method in pm.getPaymentMethods(): dl.add(payment_method.getId(), payment_method.Title()) return dl
def deletePaymentMethod(self): """ """ putils = getToolByName(self.context, "plone_utils") # delete address toDeletepPaymentMethodId = self.context.request.get("id") pm = IPaymentManagement(self.context) pm.deletePaymentMethod(toDeletepPaymentMethodId) # add message putils.addPortalMessage("The payment method has been deleted.") # Redirect to overview url = "%s/manage-payment-methods" % self.context.absolute_url() self.context.request.response.redirect(url)
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 = IShopManagement(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 getBankInformation(self): """ """ customer = self._getCustomer() if customer is None: return [] result = [] pm = IPaymentManagement(customer) for payment_method in pm.getPaymentMethods(IDirectDebit): 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
def getBankInformation(self): """ """ customer = self._getCustomer() if customer is None: return [] result = [] pm = IPaymentManagement(customer) for payment_method in pm.getPaymentMethods(IDirectDebit): 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
def getDirectDebitAccounts(self): """ """ pm = IPaymentManagement(self.context) return pm.getPaymentMethods(IDirectDebit)