Class: Remit::IpnRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/remit/ipn_request.rb

Overview

Encapsulates the logic for IPN request validation and attribute retrieval.

Note: if your responses from Amazon are not validating, please pass the :version parameter to your original CBUI request.

Constant Summary collapse

SIGNATURE_KEY =

Signature key name used by AmazonFPS IPNs

'signature'

Instance Method Summary collapse

Constructor Details

#initialize(params, secret_key) ⇒ IpnRequest

params should be your controllers request parameters.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/remit/ipn_request.rb', line 14

def initialize(params, secret_key)
  raise ArgumentError, "Expected the request params hash, received: #{params.inspect}" unless params.kind_of?(Hash)
  @params             = strip_keys_from(params, 'action', 'controller')
  @supplied_signature = @params.delete(SIGNATURE_KEY)
  @secret_key         = secret_key
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

:nodoc:



26
27
28
29
30
31
32
# File 'lib/remit/ipn_request.rb', line 26

def method_missing(method, *args) #:nodoc:
  if @params.has_key?(method.to_s)
    @params[method.to_s]
  else
    super(method, *args)
  end
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/remit/ipn_request.rb', line 21

def valid?
  return false unless @supplied_signature
  generate_signature_for(@params) == @supplied_signature
end