def confirm_resource(params)
      params = prepare_params(params)

      if signature_valid?(params)
        data = {
          :resource_id => params[:resource_id],
          :resource_type => params[:resource_type],
        }

        credentials = Base64.encode64("#{@app_id}:#{@app_secret}")
        credentials = credentials.gsub(/\s/, '')
        headers = {
          'Authorization' => "Basic #{credentials}"
        }
        request(:post, "#{api_url}/confirm", :data => data,
                                                  :headers => headers)

        # Initialize the correct class according to the resource's type
        klass = GoCardless.const_get(Utils.camelize(params[:resource_type]))
        klass.find_with_client(self, params[:resource_id])
      else
        raise SignatureError, 'An invalid signature was detected'
      end
    end
def confirm_resource(params)
      params = prepare_params(params)

      if signature_valid?(params)
        data = {
          :resource_id => params[:resource_id],
          :resource_type => params[:resource_type],
        }

        credentials = Base64.encode64("#{@app_id}:#{@app_secret}")
        credentials = credentials.gsub(/\s/, '')
        headers = {
          'Authorization' => "Basic #{credentials}"
        }
        request(:post, "#{api_url}/confirm", :data => data,
                                                  :headers => headers)

        # Initialize the correct class according to the resource's type
        klass = GoCardless.const_get(Utils.camelize(params[:resource_type]))
        klass.find_with_client(self, params[:resource_id])
      else
        raise SignatureError, 'An invalid signature was detected'
      end
    end
Confirm a newly-created subscription, pre-authorzation or one-off
 bill. This method also checks that the resource response data includes
 a valid signature and will raise a {SignatureError} if the signature is
 invalid.

 @param [Hash] params the response parameters returned by the API server
 @return [Resource] the confirmed resource object