Class: GoCardlessPro::Services::BankAccountHolderVerificationsService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/gocardless_pro/services/bank_account_holder_verifications_service.rb

Overview

Service for making requests to the BankAccountHolderVerification endpoints

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #make_request, #sub_url

Constructor Details

This class inherits a constructor from GoCardlessPro::Services::BaseService

Instance Method Details

#create(options = {}) ⇒ Object

Verify the account holder of the bank account. A complete verification can be attached when creating an outbound payment. This endpoint allows partner merchants to create Confirmation of Payee checks on customer bank accounts before sending outbound payments. Example URL: /bank_account_holder_verifications

Parameters:

  • options (Hash) (defaults to: {})

    parameters as a hash, under a params key.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gocardless_pro/services/bank_account_holder_verifications_service.rb', line 19

def create(options = {})
  path = '/bank_account_holder_verifications'

  params = options.delete(:params) || {}
  options[:params] = {}
  options[:params][envelope_key] = params

  options[:retry_failures] = true

  begin
    response = make_request(:post, path, options)

    # Response doesn't raise any errors until #body is called
    response.tap(&:body)
  rescue InvalidStateError => e
    if e.idempotent_creation_conflict?
      case @api_service.on_idempotency_conflict
      when :raise
        raise IdempotencyConflict.new(e.error)
      when :fetch
        return get(e.conflicting_resource_id)
      end
    end

    raise e
  end

  return if response.body.nil?

  Resources::BankAccountHolderVerification.new(unenvelope_body(response.body), response)
end

#get(identity, options = {}) ⇒ Object

Fetches a bank account holder verification by ID. Example URL: /bank_account_holder_verifications/:identity

e.g. "BAHV123".

Parameters:

  • identity

    The unique identifier for the bank account holder verification resource,

  • options (Hash) (defaults to: {})

    parameters as a hash, under a params key.



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/gocardless_pro/services/bank_account_holder_verifications_service.rb', line 57

def get(identity, options = {})
  path = sub_url('/bank_account_holder_verifications/:identity', {
                   'identity' => identity,
                 })

  options[:retry_failures] = true

  response = make_request(:get, path, options)

  return if response.body.nil?

  Resources::BankAccountHolderVerification.new(unenvelope_body(response.body), response)
end