def _get_redirect_url(self, **kwargs): basket = self.request.basket if basket.is_empty: raise EmptyBasketException() params = {'basket': self.request.basket} user = self.request.user if self.as_payment_method: shipping_addr = self.get_shipping_address() if not shipping_addr: raise MissingShippingAddressException() shipping_method = self.get_shipping_method() if not shipping_method: raise MissingShippingMethodException() params['shipping_address'] = shipping_addr params['shipping_method'] = shipping_method params['shipping_methods'] = [] else: shipping_methods = Repository().get_shipping_methods(user, basket) params['shipping_methods'] = shipping_methods if settings.DEBUG: # Determine the localserver's hostname to use when # in testing mode params['host'] = self.request.META['HTTP_HOST'] params['scheme'] = 'http' if user.is_authenticated(): params['user'] = user return get_paypal_url(**params)
def _get_redirect_url(self, basket, **kwargs): if basket.is_empty: raise EmptyBasketException() params = {'basket': basket} user = self.request.user if self.as_payment_method: if basket.is_shipping_required(): # Only check for shipping details if required. shipping_addr = self.get_shipping_address(basket) if not shipping_addr: raise MissingShippingAddressException() shipping_method = self.get_shipping_method( basket, shipping_addr) if not shipping_method: raise MissingShippingMethodException() params['shipping_address'] = shipping_addr params['shipping_method'] = shipping_method if settings.DEBUG: # Determine the local server's hostname to use when in testing mode params['host'] = self.request.META['HTTP_HOST'] if user.is_authenticated: params['user'] = user return get_paypal_url(**params)
def _get_redirect_url(self, basket, **kwargs): if basket.is_empty: raise EmptyBasketException() params = { 'basket': basket, 'shipping_methods': [] # setup a default empty list } # to support no_shipping user = self.request.user if self.as_payment_method: if basket.is_shipping_required(): # Only check for shipping details if required. shipping_addr = self.get_shipping_address(basket) if not shipping_addr: raise MissingShippingAddressException() shipping_method = self.get_shipping_method( basket, shipping_addr) if not shipping_method: raise MissingShippingMethodException() params['shipping_address'] = shipping_addr params['shipping_method'] = shipping_method params['shipping_methods'] = [] else: # Maik doubts that this code ever worked. Assigning # shipping method instances to Paypal params # isn't going to work, is it? shipping_methods = Repository().get_shipping_methods( user=user, basket=basket, request=self.request) params['shipping_methods'] = shipping_methods if settings.DEBUG: # Determine the localserver's hostname to use when # in testing mode params['host'] = self.request.META['HTTP_HOST'] print("HEY") print(self.request) print(self.request.META['HTTP_HOST']) if user.is_authenticated: params['user'] = user params['paypal_params'] = self._get_paypal_params() return get_paypal_url(**params)
def _get_redirect_url(self, basket, **kwargs): if basket.is_empty: raise EmptyBasketException() params = { 'basket': basket, 'shipping_methods': [] # setup a default empty list } # to support no_shipping user = self.request.user if self.as_payment_method: if basket.is_shipping_required(): # Only check for shipping details if required. shipping_addr = self.get_shipping_address(basket) if not shipping_addr: raise MissingShippingAddressException() shipping_method = self.get_shipping_method( basket, shipping_addr) if not shipping_method: raise MissingShippingMethodException() params['shipping_address'] = shipping_addr params['shipping_method'] = shipping_method params['shipping_methods'] = [] else: # Maik doubts that this code ever worked. Assigning # shipping method instances to Paypal params # isn't going to work, is it? shipping_methods = Repository().get_shipping_methods( user=user, basket=basket, request=self.request) params['shipping_methods'] = shipping_methods # Returns the originating host of the request using information from the HTTP_X_FORWARDED_HOST # (if USE_X_FORWARDED_HOST is enabled) and HTTP_HOST headers, in that order. # If they don’t provide a value, the method uses a combination of SERVER_NAME and SERVER_PORT # as detailed in PEP 3333. # # Example: "127.0.0.1:8000" params['host'] = self.request.get_host() if user.is_authenticated: params['user'] = user params['paypal_params'] = self._get_paypal_params() return get_paypal_url(**params)
def _get_redirect_url(self, **kwargs): basket = self.request.basket if basket.is_empty: raise EmptyBasketException() params = { 'basket': self.request.basket, 'shipping_methods': [] # setup a default empty list } # to support no_shipping user = self.request.user if self.as_payment_method: if basket.is_shipping_required(): # Only check for shipping details if required. shipping_addr = self.get_shipping_address(basket) if not shipping_addr: raise MissingShippingAddressException() shipping_method = self.get_shipping_method( basket, shipping_addr) if not shipping_method: raise MissingShippingMethodException() params['shipping_address'] = shipping_addr params['shipping_method'] = shipping_method params['shipping_methods'] = [] else: shipping_methods = Repository().get_shipping_methods(user, basket) params['shipping_methods'] = shipping_methods if settings.DEBUG: # Determine the localserver's hostname to use when # in testing mode params['host'] = self.request.META['HTTP_HOST'] if getattr(settings, 'PAYPAL_SANDBOX_MODE', False): params['scheme'] = 'http' else: params['scheme'] = 'https' if user.is_authenticated(): params['user'] = user params['paypal_params'] = self._get_paypal_params() return get_paypal_url(**params)