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.



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

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

Instance Attribute Details

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

Instance Method Details

#default_ipn_endpointObject

Default IPN end point



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

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

#ipn_endpointObject

Fetch end point



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

def ipn_endpoint
  config.ipn_endpoint || default_ipn_endpoint
end

#requestObject

Request IPN service for validating the content

Return

return http response object



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

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)


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

def valid?
  request.body == VERIFIED
end