Class: FormProfiles::VA0994

Inherits:
FormProfile
  • Object
show all
Defined in:
app/models/form_profiles/va_0994.rb

Instance Method Summary collapse

Instance Method Details

#initialize_payment_informationObject (private)



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/models/form_profiles/va_0994.rb', line 36

def initialize_payment_information
  return {} unless user.authorize(:ppiu, :access?) && user.authorize(:evss, :access?)

  service = EVSS::PPIU::Service.new(user)
  response = service.get_payment_information
   = response.responses.first&.

  if 
    VA0994::FormPaymentAccountInformation.new(
      account_type: &.&.capitalize,
      account_number: mask(&.),
      routing_number: mask(&.financial_institution_routing_number),
      bank_name: &.financial_institution_name
    )
  else
    {}
  end
rescue => e
  Rails.logger.error "Failed to retrieve PPIU data: #{e.message}"
  {}
end

#mask(number) ⇒ Object (private)



58
59
60
# File 'app/models/form_profiles/va_0994.rb', line 58

def mask(number)
  number.gsub(/.(?=.{4})/, '*')
end

#metadataObject



26
27
28
29
30
31
32
# File 'app/models/form_profiles/va_0994.rb', line 26

def 
  {
    version: 0,
    prefill: true,
    returnUrl: '/applicant/information'
  }
end

#prefillObject



21
22
23
24
# File 'app/models/form_profiles/va_0994.rb', line 21

def prefill
  @payment_information = initialize_payment_information
  super
end