Class: Rack::Payment::Response
- Inherits:
-
Object
- Object
- Rack::Payment::Response
- Defined in:
- lib/rack-payment/response.rb
Overview
Represents the response you get when you try to make a purchase from ActiveMerchant
Instance Attribute Summary collapse
-
#raw_authorize_response ⇒ Object
(also: #auth)
Returns the value of attribute raw_authorize_response.
-
#raw_capture_response ⇒ Object
(also: #capture)
Returns the value of attribute raw_capture_response.
-
#raw_express_response ⇒ Object
(also: #express)
Returns the value of attribute raw_express_response.
Instance Method Summary collapse
- #amount_paid ⇒ Object
- #express? ⇒ Boolean
- #express_amound_paid ⇒ Object
- #express_success? ⇒ Boolean
- #has_responses? ⇒ Boolean
- #success? ⇒ Boolean
Instance Attribute Details
#raw_authorize_response ⇒ Object Also known as: auth
Returns the value of attribute raw_authorize_response.
8 9 10 |
# File 'lib/rack-payment/response.rb', line 8 def @raw_authorize_response end |
#raw_capture_response ⇒ Object Also known as: capture
Returns the value of attribute raw_capture_response.
9 10 11 |
# File 'lib/rack-payment/response.rb', line 9 def raw_capture_response @raw_capture_response end |
#raw_express_response ⇒ Object Also known as: express
Returns the value of attribute raw_express_response.
10 11 12 |
# File 'lib/rack-payment/response.rb', line 10 def raw_express_response @raw_express_response end |
Instance Method Details
#amount_paid ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rack-payment/response.rb', line 24 def amount_paid if success? if express? express_amound_paid else if raw_capture_response.params['paid_amount'] # Sometimes we get this (like 995) (raw_capture_response.params['paid_amount'].to_f / 100) elsif raw_capture_response.params['gross_amount'] # PayPal likes to return this (like 9.95) raw_capture_response.params['gross_amount'].to_d end end end end |
#express? ⇒ Boolean
20 21 22 |
# File 'lib/rack-payment/response.rb', line 20 def express? express != nil end |
#express_amound_paid ⇒ Object
40 41 42 43 44 |
# File 'lib/rack-payment/response.rb', line 40 def express_amound_paid if success? raw_express_response.params['gross_amount'].to_f end end |
#express_success? ⇒ Boolean
54 55 56 |
# File 'lib/rack-payment/response.rb', line 54 def express_success? raw_express_response.success? end |
#has_responses? ⇒ Boolean
16 17 18 |
# File 'lib/rack-payment/response.rb', line 16 def has_responses? auth or capture or express end |
#success? ⇒ Boolean
46 47 48 49 50 51 52 |
# File 'lib/rack-payment/response.rb', line 46 def success? if express? express_success? else auth and auth.success? and capture and capture.success? end end |