Class: SallieMaeGateway::Response

Inherits:
Object
  • Object
show all
Defined in:
app/models/sallie_mae_gateway/response.rb

Constant Summary collapse

SUCCESS_INDICATOR =
{
  'A' => 'Credit Card Accepted',
  'S' => 'ACH Scheduled',
  'D' => 'Declined',
  'P' => 'Pending',
  'C' => 'Canceled'
}.freeze
PAYMENT_INDICATOR =
{
  'AX' => 'American Express',
  'DI' => 'Discover Card',
  'DN' => 'Diners Club',
  'CB' => 'Carte Blanche',
  'JC' => 'JCB',
  'MC' => 'Master Card',
  'VI' => 'Visa',
  'CK' => 'Checking Account',
  'SV' => 'Savings Account'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ Response

Returns a new instance of Response.



28
29
30
31
32
33
# File 'app/models/sallie_mae_gateway/response.rb', line 28

def initialize(args=nil)
  if args.is_a? Hash
    @raw_response = args 
    process_response
  end      
end

Instance Attribute Details

#raw_responseObject

Returns the value of attribute raw_response.



26
27
28
# File 'app/models/sallie_mae_gateway/response.rb', line 26

def raw_response
  @raw_response
end

Instance Method Details

#canceled?Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'app/models/sallie_mae_gateway/response.rb', line 40

def canceled?
  raise 'Unable to determine status. Has a response been provided?' unless self.respond_to? :success_indicator
  self.success_indicator.eql? CANCELED
end

#payment_methodObject



55
56
57
58
# File 'app/models/sallie_mae_gateway/response.rb', line 55

def payment_method
  raise 'Unable to determine payment method. Has a response been provided?' unless self.respond_to? :pmt_indicator
  PAYMENT_INDICATOR[self.pmt_indicator]
end

#success?Boolean

Returns:

  • (Boolean)


45
46
47
48
# File 'app/models/sallie_mae_gateway/response.rb', line 45

def success?
  raise 'Unable to determine status. Has a response been provided?' unless self.respond_to? :success_indicator
  self.success_indicator.eql? SUCCESS
end

#success_messageObject



50
51
52
53
# File 'app/models/sallie_mae_gateway/response.rb', line 50

def success_message
  raise 'Unable to determine status. Has a response been provided?' unless self.respond_to? :success_indicator
  SUCCESS_INDICATOR[self.success_indicator]
end