def shipping_json
      render :json => { :error => 'Not logged in.'          } and return if !logged_in?
      render :json => { :error => 'No shippable items.'     } and return if !@invoice.has_shippable_items?
      render :json => { :error => 'Empty shipping address.' } and return if @invoice.shipping_address.nil?      
      
      @invoice.calculate
      
      #ops = @invoice.invoice_packages      
      #if params[:recalculate_invoice_packages] || ops.count == 0
      #  # Remove any invoice packages      
      #  LineItem.where(:invoice_id => @invoice.id).update_all(:invoice_package_id => nil)
      #  InvoicePackage.where(:invoice_id => @invoice.id).destroy_all      
      #    
      #  # Calculate what shipping packages we'll need            
      #  InvoicePackage.create_for_invoice(@invoice)
      #end

      # Now get the rates for those packages            
      rates = ShippingCalculator.rates(@invoice)      
      render :json => rates                  
    end
def shipping_json
      render :json => { :error => 'Not logged in.'          } and return if !logged_in?
      render :json => { :error => 'No shippable items.'     } and return if !@invoice.has_shippable_items?
      render :json => { :error => 'Empty shipping address.' } and return if @invoice.shipping_address.nil?      
      
      @invoice.calculate
      
      #ops = @invoice.invoice_packages      
      #if params[:recalculate_invoice_packages] || ops.count == 0
      #  # Remove any invoice packages      
      #  LineItem.where(:invoice_id => @invoice.id).update_all(:invoice_package_id => nil)
      #  InvoicePackage.where(:invoice_id => @invoice.id).destroy_all      
      #    
      #  # Calculate what shipping packages we'll need            
      #  InvoicePackage.create_for_invoice(@invoice)
      #end

      # Now get the rates for those packages            
      rates = ShippingCalculator.rates(@invoice)      
      render :json => rates                  
    end
Step 3 - Shipping method
 @route GET /checkout/shipping/json