def gc_callback(request, input_xml=None, safe_to_raise=False): controller = get_controller() if input_xml is None: if request.method != "POST": return HttpResponseServerError("Incorrect request method") input_xml = request.raw_post_data try: output_xml = controller.receive_xml(input_xml) return HttpResponse(output_xml, mimetype='text/xml') except Exception, exc: if safe_to_raise: raise return HttpResponseServerError(str(exc))
def gc_callback(request, input_xml = None, safe_to_raise = False): controller = get_controller() if input_xml is None: if request.method != "POST": return HttpResponseServerError("Incorrect request method") input_xml = request.raw_post_data try: output_xml = controller.receive_xml(input_xml) return HttpResponse(output_xml, mimetype='text/xml') except Exception, exc: if safe_to_raise: raise return HttpResponseServerError(str(exc))
def get_cart(self): from gchecky.model import * controller = get_controller() return controller.prepare_order( order=checkout_shopping_cart_t( shopping_cart=shopping_cart_t(items=[ item_t(name=item.product.name, description=item.product.short_desc, unit_price=price_t(value=float(item.product.price), currency='USD'), item_weight=item_weight_t(value=float( item.product.weight), unit='LB'), quantity=item.quantity, merchant_item_id=item.product.sku) for item in self.item_set.all() ], merchant_private_data=self.id), checkout_flow_support=checkout_flow_support_t( #XXX edit_cart_url= 'http://sandbox.mjs-publishing.com/store/cart/%s/?action=decheckout' % self.id, continue_shopping_url= 'http://sandbox.mjs-publishing.com/store/', #/XXX #tax_tables = tax_tables_t( # merchant_calculated = False, # default = default_tax_table_t( # tax_rules = [ # default_tax_rule_t( # shipping_taxed = True, # rate = 0.059, # tax_area = tax_area_t( # us_zip_pattern = '805*' # ) # ), # default_tax_rule_t( # shipping_taxed = True, # rate = 0.029, # tax_area = tax_area_t( # us_state = 'CO' # ) # ) # ] # ) # ), shipping_methods=shipping_methods_t( carrier_calculated_shippings=[ carrier_calculated_shipping_t( carrier_calculated_shipping_options=[ carrier_calculated_shipping_option_t( price=price_t(value=( self.total_weight() * 2 + 3), currency='USD'), shipping_company='USPS', carrier_pickup='DROP_OFF', shipping_type='Priority Mail'), carrier_calculated_shipping_option_t( price=price_t(value=( self.total_weight() * 0.5 + 6.79), currency='USD'), shipping_company='FedEx', carrier_pickup='DROP_OFF', shipping_type='Ground') ], shipping_packages=[ shipping_package_t( height=measure_t( value=self.get_height(), units='IN'), length=measure_t( value=self.greatest_length(), units='IN'), width=measure_t( value=self.greatest_width(), units='IN'), ship_from=ship_from_t( id='FOCO', city='Fort Collins', region='CO', postal_code='80425', country_code='US')) ]) ])), ), diagnose=False)
def get_cart(self): from gchecky.model import * controller = get_controller() return controller.prepare_order( order = checkout_shopping_cart_t( shopping_cart = shopping_cart_t( items = [ item_t( name = item.product.name, description = item.product.short_desc, unit_price = price_t( value = float(item.product.price), currency = 'USD' ), item_weight = item_weight_t( value = float(item.product.weight), unit = 'LB' ), quantity = item.quantity, merchant_item_id = item.product.sku ) for item in self.item_set.all() ], merchant_private_data = self.id ), checkout_flow_support = checkout_flow_support_t( #XXX edit_cart_url = 'http://sandbox.mjs-publishing.com/store/cart/%s/?action=decheckout' % self.id, continue_shopping_url = 'http://sandbox.mjs-publishing.com/store/', #/XXX #tax_tables = tax_tables_t( # merchant_calculated = False, # default = default_tax_table_t( # tax_rules = [ # default_tax_rule_t( # shipping_taxed = True, # rate = 0.059, # tax_area = tax_area_t( # us_zip_pattern = '805*' # ) # ), # default_tax_rule_t( # shipping_taxed = True, # rate = 0.029, # tax_area = tax_area_t( # us_state = 'CO' # ) # ) # ] # ) # ), shipping_methods = shipping_methods_t( carrier_calculated_shippings = [ carrier_calculated_shipping_t( carrier_calculated_shipping_options = [ carrier_calculated_shipping_option_t( price = price_t( value = (self.total_weight() * 2 + 3), currency = 'USD' ), shipping_company = 'USPS', carrier_pickup = 'DROP_OFF', shipping_type = 'Priority Mail' ), carrier_calculated_shipping_option_t( price = price_t( value = (self.total_weight() * 0.5 + 6.79), currency = 'USD' ), shipping_company = 'FedEx', carrier_pickup = 'DROP_OFF', shipping_type = 'Ground' ) ], shipping_packages = [ shipping_package_t( height = measure_t( value = self.get_height(), units = 'IN' ), length = measure_t( value = self.greatest_length(), units = 'IN' ), width = measure_t( value = self.greatest_width(), units = 'IN' ), ship_from = ship_from_t( id = 'FOCO', city = 'Fort Collins', region = 'CO', postal_code = '80425', country_code = 'US' ) ) ] ) ] ) ), ), diagnose = False )