def add_item(item)
      @xml = nil
      if item.respond_to? :to_google_product
        item = item.to_google_product
      end

      # We need to check that the necessary keys are in the hash,
      # Otherwise the error will happen in the middle of to_xml,
      # and the bug will be harder to track.
      missing_keys = [ :name, :description, :price ].select { |key|
        !item.include? key
      }

      unless missing_keys.empty?
        raise ArgumentError,
        "Required keys missing: #{missing_keys.inspect}"
      end

      @contents << { :quantity => 1, :currency => 'USD' }.merge(item)
      item
    end
def add_item(item)
      @xml = nil
      if item.respond_to? :to_google_product
        item = item.to_google_product
      end

      # We need to check that the necessary keys are in the hash,
      # Otherwise the error will happen in the middle of to_xml,
      # and the bug will be harder to track.
      missing_keys = [ :name, :description, :price ].select { |key|
        !item.include? key
      }

      unless missing_keys.empty?
        raise ArgumentError,
        "Required keys missing: #{missing_keys.inspect}"
      end

      @contents << { :quantity => 1, :currency => 'USD' }.merge(item)
      item
    end
This method puts items in the cart.
 +item+ may be a hash, or have a method named +to_google_product+ that
 returns a hash with the required values.
 * name
 * description (a brief description as it will appear on the bill)
 * price
 You may fill in some optional values as well:
 * quantity (defaults to 1)
 * currency (defaults to 'USD')