Class: Chargify2::Direct::SecureParameters
- Inherits:
-
Object
- Object
- Chargify2::Direct::SecureParameters
- Defined in:
- lib/chargify2/direct.rb
Overview
There is no need to instantiate a SecureParameters instance directly. Use Direct#secure_parameters instead.
Instance Attribute Summary collapse
-
#api_id ⇒ Object
readonly
Returns the value of attribute api_id.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#nonce ⇒ Object
readonly
Returns the value of attribute nonce.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #encoded_data ⇒ Object
-
#initialize(hash, client) ⇒ SecureParameters
constructor
A new instance of SecureParameters.
- #signature ⇒ Object
- #to_form_inputs ⇒ Object
Constructor Details
#initialize(hash, client) ⇒ SecureParameters
Returns a new instance of SecureParameters.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/chargify2/direct.rb', line 39 def initialize(hash, client) args = hash.recursive_symbolize_keys @api_id = client.api_id @secret = client.api_secret @timestamp = args[:timestamp] @nonce = args[:nonce] @data = args[:data] validate_args end |
Instance Attribute Details
#api_id ⇒ Object (readonly)
Returns the value of attribute api_id.
33 34 35 |
# File 'lib/chargify2/direct.rb', line 33 def api_id @api_id end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
36 37 38 |
# File 'lib/chargify2/direct.rb', line 36 def data @data end |
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
35 36 37 |
# File 'lib/chargify2/direct.rb', line 35 def nonce @nonce end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
37 38 39 |
# File 'lib/chargify2/direct.rb', line 37 def secret @secret end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
34 35 36 |
# File 'lib/chargify2/direct.rb', line 34 def @timestamp end |
Instance Method Details
#encoded_data ⇒ Object
69 70 71 72 |
# File 'lib/chargify2/direct.rb', line 69 def encoded_data hash = data? ? data : {} Rack::Utils.build_nested_query(hash) end |
#signature ⇒ Object
74 75 76 77 |
# File 'lib/chargify2/direct.rb', line 74 def signature = "#{api_id}#{}#{nonce}#{encoded_data}" Direct.signature(, secret) end |
#to_form_inputs ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/chargify2/direct.rb', line 52 def to_form_inputs output = [] output << %{<input type="hidden" name="secure[api_id]" value="#{h(api_id)}"/>} output << %{<input type="hidden" name="secure[timestamp]" value="#{h()}"/>} if output << %{<input type="hidden" name="secure[nonce]" value="#{h(nonce)}"/>} if nonce? output << %{<input type="hidden" name="secure[data]" value="#{h(encoded_data)}"/>} if data? output << %{<input type="hidden" name="secure[signature]" value="#{h(signature)}"/>} output.join("\n") end |