lib/gocardless/client.rb
# 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
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.
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 .
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)
        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 ) 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.
Confirm a newly - created subscription pre - authorzation or one - off bill .
# Initialize the correct class according to the resource's type
the confirmed resource object
the confirmed resource object
Resource
params
<not_specific>
<not_specific>
params the response parameters returned by the API server
params the response parameters returned by the API server