Class: ActiveMerchant::Billing::AdaptivePaymentResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb

Constant Summary collapse

SUCCESS =
'Success'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, xml_request = nil, action = nil) ⇒ AdaptivePaymentResponse

Returns a new instance of AdaptivePaymentResponse.



14
15
16
17
18
19
20
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 14

def initialize(json, xml_request = nil, action = nil)
  @json = json
  @response = Hashie::Rash.new(MultiJson.decode(json))
  @xml_request = xml_request
  @request =  Hashie::Rash.from_xml(xml_request)
  @action = action
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



22
23
24
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 22

def method_missing(method, *args, &block)
  @response.send(method, *args, &block)
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



10
11
12
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 10

def action
  @action
end

#jsonObject (readonly) Also known as: raw

Returns the value of attribute json.



10
11
12
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 10

def json
  @json
end

#requestObject (readonly)

Returns the value of attribute request.



10
11
12
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 10

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 10

def response
  @response
end

#xml_requestObject (readonly) Also known as: raw_request

Returns the value of attribute xml_request.



10
11
12
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 10

def xml_request
  @xml_request
end

Instance Method Details

#ackObject

def redirect_url_for

Base.gateway_mode == :test ? (TEST_REDIRECT_URL + pay_key) : (REDIRECT_URL + pay_key)

end



30
31
32
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 30

def ack
  response_envelope.ack
end

#buildObject



38
39
40
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 38

def build
  response_envelope.build
end

#correlation_idObject Also known as: correlationId



42
43
44
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 42

def correlation_id
  response_envelope.correlation_id
end

#success?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 47

def success?
  ack == SUCCESS
end

#timestampObject



34
35
36
# File 'lib/active_merchant/billing/gateways/paypal_adaptive_payments/adaptive_payment_response.rb', line 34

def timestamp
  response_envelope.timestamp
end