Class: Paypal::Response
- Inherits:
-
Object
- Object
- Paypal::Response
- Defined in:
- lib/paypal_api/support/response.rb,
lib/paypal_api/support/response.rb
Direct Known Subclasses
Constant Summary collapse
- @@error_codes =
{ '10527' => :acct, '10525' => :amt, '10508' => :exp_date, '10504' => :cvv2, '10502' => :acct, '10501' => :reference_id, '10509' => :ip_address, '10510' => :acct, '10519' => :acct, '10521' => :acct, '10526' => :currency_code }
- @@human_readable =
{ :acct => "credit card number", :amt => "charge amount", :exp_date => "expiration date", :cvv2 => "security code", :reference_id => "billing agreement", :currency_code => "currency code" }
Instance Attribute Summary collapse
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#parsed_response ⇒ Object
Returns the value of attribute parsed_response.
-
#paypal_error_field ⇒ Object
Returns the value of attribute paypal_error_field.
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #error_field ⇒ Object
- #error_input ⇒ Object
- #error_message ⇒ Object
-
#initialize(stringio) ⇒ Response
constructor
A new instance of Response.
- #method_missing?(key) ⇒ Boolean
- #success? ⇒ Boolean
Constructor Details
#initialize(stringio) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/paypal_api/support/response.rb', line 6 def initialize(stringio) @raw_response = stringio.class == StringIO ? stringio.read : stringio @parsed_response = CGI.parse(@raw_response) @success = @parsed_response["ACK"] == ["Success"] unless @success @error_message = @parsed_response["L_LONGMESSAGE0"][0] @error_code = @parsed_response["L_ERRORCODE0"][0] end end |
Instance Attribute Details
#error_code ⇒ Object
Returns the value of attribute error_code.
4 5 6 |
# File 'lib/paypal_api/support/response.rb', line 4 def error_code @error_code end |
#parsed_response ⇒ Object
Returns the value of attribute parsed_response.
4 5 6 |
# File 'lib/paypal_api/support/response.rb', line 4 def parsed_response @parsed_response end |
#paypal_error_field ⇒ Object
Returns the value of attribute paypal_error_field.
4 5 6 |
# File 'lib/paypal_api/support/response.rb', line 4 def paypal_error_field @paypal_error_field end |
#raw_response ⇒ Object
Returns the value of attribute raw_response.
4 5 6 |
# File 'lib/paypal_api/support/response.rb', line 4 def raw_response @raw_response end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/paypal_api/support/response.rb', line 18 def [](key) if key.class == Symbol @parsed_response[symbol_to_key(key)][0] else @parsed_response[key][0] end end |
#error_field ⇒ Object
38 39 40 |
# File 'lib/paypal_api/support/response.rb', line 38 def error_field @paypal_error_field || (@@error_codes[@error_code] ? @@human_readable[@@error_codes[@error_code]] : nil) end |
#error_input ⇒ Object
34 35 36 |
# File 'lib/paypal_api/support/response.rb', line 34 def error_input @@error_codes[@error_code] end |
#error_message ⇒ Object
42 43 44 |
# File 'lib/paypal_api/support/response.rb', line 42 def @error_message + "[#{@error_code}]" end |
#method_missing?(key) ⇒ Boolean
30 31 32 |
# File 'lib/paypal_api/support/response.rb', line 30 def method_missing?(key) return @parsed_response[symbol_to_key(key)] end |
#success? ⇒ Boolean
26 27 28 |
# File 'lib/paypal_api/support/response.rb', line 26 def success? return @success end |