public function confirm_resource($params) {

    // Define confirm endpoint
    $endpoint = '/confirm';

    // First validate signature
    // Then send confirm request

    // List of required params
    $required_params = array(
      'resource_id', 'resource_type'
    );

    // Loop through required params
    // Add to $data or throw exception if missing
    foreach ($required_params as $key => $value) {
      if ( ! isset($params[$value])) {
        throw new GoCardless_ArgumentsException("$value missing");
      }
      $data[$value] = $params[$value];
    }

    // state is optional
    if (isset($params['state'])) {
      $data['state'] = $params['state'];
    }

    // resource_uri is optional
    if (isset($params['resource_uri'])) {
      $data['resource_uri'] = $params['resource_uri'];
    }

    $sig_validation_data = array(
      'data'      => $data,
      'secret'    => $this->account_details['app_secret'],
      'signature' => $params['signature']
    );

    if ($this->validate_signature($sig_validation_data) == false) {
      throw new GoCardless_SignatureException();
    }

    // Sig valid, now send confirm request
    $confirm_params = array(
      'resource_id'   => $params['resource_id'],
      'resource_type' => $params['resource_type']
    );

    // Use HTTP Basic Authorization
    $confirm_params['http_authorization'] = $this->account_details['app_id']
      . ':' . $this->account_details['app_secret'];

    // If no method-specific redirect sent, use class level if available
    if ( ! isset($params['redirect_uri']) && isset($this->redirect_uri)) {
      $confirm_params['redirect_uri'] = $this->redirect_uri;
    }

    // Do query
    $response = $this->request('post', $endpoint, $confirm_params);

    if ($response['success'] == true) {

      $endpoint = '/' . $params['resource_type'] . 's/' .
        $params['resource_id'];

      $class_name = 'GoCardless_' .
        GoCardless_Utils::camelize($params['resource_type']);

      return new $class_name($this, $this->request('get', $endpoint));

    } else {

      throw new GoCardless_ClientException('Failed to fetch the confirmed
        resource.');

    }

  }
public function confirm_resource($params) {

    // Define confirm endpoint
    $endpoint = '/confirm';

    // First validate signature
    // Then send confirm request

    // List of required params
    $required_params = array(
      'resource_id', 'resource_type'
    );

    // Loop through required params
    // Add to $data or throw exception if missing
    foreach ($required_params as $key => $value) {
      if ( ! isset($params[$value])) {
        throw new GoCardless_ArgumentsException("$value missing");
      }
      $data[$value] = $params[$value];
    }

    // state is optional
    if (isset($params['state'])) {
      $data['state'] = $params['state'];
    }

    // resource_uri is optional
    if (isset($params['resource_uri'])) {
      $data['resource_uri'] = $params['resource_uri'];
    }

    $sig_validation_data = array(
      'data'      => $data,
      'secret'    => $this->account_details['app_secret'],
      'signature' => $params['signature']
    );

    if ($this->validate_signature($sig_validation_data) == false) {
      throw new GoCardless_SignatureException();
    }

    // Sig valid, now send confirm request
    $confirm_params = array(
      'resource_id'   => $params['resource_id'],
      'resource_type' => $params['resource_type']
    );

    // Use HTTP Basic Authorization
    $confirm_params['http_authorization'] = $this->account_details['app_id']
      . ':' . $this->account_details['app_secret'];

    // If no method-specific redirect sent, use class level if available
    if ( ! isset($params['redirect_uri']) && isset($this->redirect_uri)) {
      $confirm_params['redirect_uri'] = $this->redirect_uri;
    }

    // Do query
    $response = $this->request('post', $endpoint, $confirm_params);

    if ($response['success'] == true) {

      $endpoint = '/' . $params['resource_type'] . 's/' .
        $params['resource_id'];

      $class_name = 'GoCardless_' .
        GoCardless_Utils::camelize($params['resource_type']);

      return new $class_name($this, $this->request('get', $endpoint));

    } else {

      throw new GoCardless_ClientException('Failed to fetch the confirmed
        resource.');

    }

  }
public function confirm_resource ( $ params ) { // Define confirm endpoint $ endpoint = '/confirm' ; // First validate signature // Then send confirm request // List of required params $ required_params = array ( 'resource_id' , 'resource_type' ) ; // Loop through required params // Add to $data or throw exception if missing foreach ( $ required_params as $ key => $ value ) { if ( ! isset ( $ params [ $ value ] ) ) { throw new GoCardless_ArgumentsException ( "$value missing" ) ; } $ data [ $ value ] = $ params [ $ value ] ; } // state is optional if ( isset ( $ params [ 'state' ] ) ) { $ data [ 'state' ] = $ params [ 'state' ] ; } // resource_uri is optional if ( isset ( $ params [ 'resource_uri' ] ) ) { $ data [ 'resource_uri' ] = $ params [ 'resource_uri' ] ; } $ sig_validation_data = array ( 'data' => $ data , 'secret' => $ this -> account_details [ 'app_secret' ] , 'signature' => $ params [ 'signature' ] ) ; if ( $ this -> validate_signature ( $ sig_validation_data ) == false ) { throw new GoCardless_SignatureException ( ) ; } // Sig valid, now send confirm request $ confirm_params = array ( 'resource_id' => $ params [ 'resource_id' ] , 'resource_type' => $ params [ 'resource_type' ] ) ; // Use HTTP Basic Authorization $ confirm_params [ 'http_authorization' ] = $ this -> account_details [ 'app_id' ] . ':' . $ this -> account_details [ 'app_secret' ] ; // If no method-specific redirect sent, use class level if available if ( ! isset ( $ params [ 'redirect_uri' ] ) && isset ( $ this -> redirect_uri ) ) { $ confirm_params [ 'redirect_uri' ] = $ this -> redirect_uri ; } // Do query $ response = $ this -> request ( 'post' , $ endpoint , $ confirm_params ) ; if ( $ response [ 'success' ] == true ) { $ endpoint = '/' . $ params [ 'resource_type' ] . 's/' . $ params [ 'resource_id' ] ; $ class_name = 'GoCardless_' . GoCardless_Utils :: camelize ( $ params [ 'resource_type' ] ) ; return new $ class_name ( $ this , $ this -> request ( 'get' , $ endpoint ) ) ; } else { throw new GoCardless_ClientException ( 'Failed to fetch the confirmed
        resource.' ) ; } }
Send an HTTP request to confirm the creation of a new payment resource

@param array $params Parameters to send with the request

@return Bill/Subscription/PreAuthorization The confirmed resource
Send an HTTP request to confirm the creation of a new payment resource