Class: PayPal::SDK::Core::API::IPN::Message

Inherits:
Object
  • Object
show all
Includes:
Util::HTTPHelper
Defined in:
lib/paypal-sdk/core/api/ipn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::HTTPHelper

#configure_ssl, #create_http_connection, #default_ca_file, #encode_www_form, #handle_response, #http_call, #log_http_call, #map_header_value, #new_http, #url_join

Methods included from PayPal::SDK::Core::Authentication

#add_certificate, #base_credential, #base_credential_type, #credential, #set_config, #third_party_credential

Methods included from Configuration

#config, #set_config

Methods included from Logging

#log_event, #logger, logger, logger=

Constructor Details

#initialize(message, env = nil, options = {}) ⇒ Message

Returns a new instance of Message.


19
20
21
22
# File 'lib/paypal-sdk/core/api/ipn.rb', line 19

def initialize(message, env = nil, options = {})
  @message = message
  set_config(env, options)
end

Instance Attribute Details

#messageObject

Returns the value of attribute message


17
18
19
# File 'lib/paypal-sdk/core/api/ipn.rb', line 17

def message
  @message
end

Instance Method Details

#default_ipn_endpointObject

Default IPN end point


30
31
32
33
# File 'lib/paypal-sdk/core/api/ipn.rb', line 30

def default_ipn_endpoint
  endpoint = END_POINTS[(config.mode || :sandbox).to_sym] rescue nil
  endpoint || END_POINTS[:sandbox]
end

#ipn_endpointObject

Fetch end point


25
26
27
# File 'lib/paypal-sdk/core/api/ipn.rb', line 25

def ipn_endpoint
  config.ipn_endpoint || default_ipn_endpoint
end

#requestObject

Request IPN service for validating the content

Return

return http response object


38
39
40
41
42
# File 'lib/paypal-sdk/core/api/ipn.rb', line 38

def request
  uri  = URI(ipn_endpoint)
  query_string = "cmd=_notify-validate&#{message}"
  http_call(:method => :post, :uri => uri, :body => query_string)
end

#valid?Boolean

Validate the given content

Return

return true or false

Returns:

  • (Boolean)

47
48
49
# File 'lib/paypal-sdk/core/api/ipn.rb', line 47

def valid?
  request.body == VERIFIED
end