def getEmail(self): """ """ # Todo: Create an adapter Address Management for IOrder customer = self.context.getCustomer() am = IAddressManagement(customer) address = am.getShippingAddress() return address.email
def getEmail(self): """ """ # Todo: Create an adapter Address Management for IOrder customer = self.context.getCustomer() am = IAddressManagement(customer) address = am.getShippingAddress() return address.email
def getShippingAddress(self): """ """ cm = ICustomerManagement(self.context) customer = cm.getAuthenticatedCustomer() am = IAddressManagement(customer) address = am.getShippingAddress() return addressToDict(address)
def getShippingAddress(self): """ """ cm = ICustomerManagement(self.context) customer = cm.getAuthenticatedCustomer() am = IAddressManagement(customer) address = am.getShippingAddress() return addressToDict(address)
def process(self, order): """ """ info = dict() pc = IPrices(order) customer = order.getCustomer() am = IAddressManagement(customer) invoice_address = am.getInvoiceAddress() shipping_address = am.getShippingAddress() info = { "cmd" : "_cart", "upload" : "1", "business" : "*****@*****.**", "currency_code" : "EUR", "notify_url" : "", "return" : "", "last_name" : shipping_address.getName(), "address1" : shipping_address.address_1, "city" : shipping_address.city, "state" : shipping_address.country_title(), "zip" : shipping_address.zip_code, "shipping_1" : order.getShippingPriceNet(), "tax_1" : pc.getPriceGross() - pc.getPriceNet() } im = IItemManagement(order) for i, item in enumerate(im.getItems()): j = i + 1 name = "item_name_%s" % j quantity = "quantity_%s" % j amount = "amount_%s" % j product = item.getProduct() info[name] = product.Title() info[quantity] = str(int(item.getProductQuantity())) info[amount] = str(item.getProductPriceGross()) # redirect to paypal parameters = "&".join(["%s=%s" % (k, v) for (k, v) in info.items()]) url = PAYPAL_URL + "?" + parameters self.context.REQUEST.RESPONSE.redirect(url) return PaymentResult(NOT_PAYED)
def process(self, order=None): """ """ info = dict() shop = IShopManagement(self.context).getShop() notify_url = "%s/paypal?order=%s" % (shop.absolute_url(), order.UID()) return_url = "%s/thank-you" % shop.absolute_url() pc = IPrices(order) price_net = "%.2f" % pc.getPriceNet() tax = "%.2f" % (pc.getPriceGross() - float(price_net)) customer = order.getCustomer() am = IAddressManagement(customer) invoice_address = am.getInvoiceAddress() shipping_address = am.getShippingAddress() site_encoding = self.context.plone_utils.getSiteEncoding() info = { "cmd" : "_xclick", "upload" : "1", "business" : shop.getPayPalId(), "currency_code" : "EUR", "notify_url" : notify_url, "return" : return_url, "first_name" : invoice_address.firstname.encode(site_encoding), "last_name" : invoice_address.lastname.encode(site_encoding), "address1" : invoice_address.address_1.encode(site_encoding), "address2" : "", "city" : invoice_address.city.encode(site_encoding), "state" : invoice_address.country_title().encode(site_encoding), "zip" : invoice_address.zip_code.encode(site_encoding), "no_shipping" : "1", "item_name" : shop.getShopOwner(), "amount" : price_net, "tax" : tax, } # redirect to paypal parameters = "&".join(["%s=%s" % (k, v) for (k, v) in info.items()]) url = PAYPAL_URL + "?" + parameters self.context.REQUEST.RESPONSE.redirect(url) return PaymentResult(NOT_PAYED)
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 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 getShippingAddress(self): """ """ # Todo: Create an adapter Address Management for IOrder customer = self.context.getCustomer() am = IAddressManagement(customer) address = am.getShippingAddress() return { "name": address.getName(), "company_name": address.company_name, "address1": address.address_1, "zipcode": address.zip_code, "city": address.city, "country": address.country_title(), "phone": address.phone }
def getShippingAddress(self): """ """ # Todo: Create an adapter Address Management for IOrder customer = self.context.getCustomer() am = IAddressManagement(customer) address = am.getShippingAddress() return { "name" : address.getName(), "company_name" : address.company_name, "address1" : address.address_1, "zipcode" : address.zip_code, "city": address.city, "country" : address.country_title(), "phone" : address.phone }
def getMailInfo(self): """ """ cm = ICustomerManagement(self.context) customer = cm.getAuthenticatedCustomer() am = IAddressManagement(customer) shipping_address = am.getShippingAddress() mtool = getToolByName(self.context, "portal_membership") member = mtool.getAuthenticatedMember() name = shipping_address.getFirstname() + " " name += shipping_address.getLastname() return { "email" : member.getProperty("email"), "name" : name, }
def testGetShippingAddress(self): """ """ am = IAddressManagement(self.customer) self.assertEqual(am.getShippingAddress().getId(), "address_2")
def testGetShippingAddress(self): """ """ am = IAddressManagement(self.customer) self.assertEqual(am.getShippingAddress().getId(), "address_2")