Class: PaypalAdaptive::Response
- Inherits:
-
Hash
- Object
- Hash
- PaypalAdaptive::Response
- Defined in:
- lib/response.rb
Instance Method Summary collapse
- #approve_paypal_payment_url ⇒ Object
- #error_message ⇒ Object
- #errors ⇒ Object
-
#initialize(response, env = nil) ⇒ Response
constructor
A new instance of Response.
- #preapproval_paypal_payment_url ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response, env = nil) ⇒ Response
Returns a new instance of Response.
3 4 5 6 7 8 |
# File 'lib/response.rb', line 3 def initialize(response, env=nil) @@config ||= PaypalAdaptive::Config.new(env) @@paypal_base_url ||= @@config.paypal_base_url self.merge!(response) end |
Instance Method Details
#approve_paypal_payment_url ⇒ Object
30 31 32 |
# File 'lib/response.rb', line 30 def approve_paypal_payment_url self['payKey'].nil? ? nil : "#{@@paypal_base_url}/webscr?cmd=_ap-payment&paykey=#{self['payKey']}" end |
#error_message ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/response.rb', line 22 def if success? return nil else self['error'].first['message'] rescue nil end end |
#errors ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/response.rb', line 14 def errors if success? return [] else self['error'] end end |
#preapproval_paypal_payment_url ⇒ Object
34 35 36 |
# File 'lib/response.rb', line 34 def preapproval_paypal_payment_url self['preapprovalKey'].nil? ? nil : "#{@@paypal_base_url}/webscr?cmd=_ap-preapproval&preapprovalkey=#{self['preapprovalKey']}" end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/response.rb', line 10 def success? self['responseEnvelope']['ack'] == 'Success' end |