Class: Cardgate::Callback
- Inherits:
-
Object
- Object
- Cardgate::Callback
- Defined in:
- lib/cardgate/callback.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#hash_key ⇒ Object
Returns the value of attribute hash_key.
-
#is_test ⇒ Object
Returns the value of attribute is_test.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#status ⇒ Object
Returns the value of attribute status.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Callback
constructor
A new instance of Callback.
- #recurring_failed? ⇒ Boolean
- #refund? ⇒ Boolean
- #response ⇒ Object
- #successful? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Callback
Returns a new instance of Callback.
7 8 9 10 11 |
# File 'lib/cardgate/callback.rb', line 7 def initialize(attributes = {}) attributes.each do |k,v| send("#{k}=", v) end end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def amount @amount end |
#currency ⇒ Object
Returns the value of attribute currency.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def currency @currency end |
#hash ⇒ Object
Returns the value of attribute hash.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def hash @hash end |
#hash_key ⇒ Object
Returns the value of attribute hash_key.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def hash_key @hash_key end |
#is_test ⇒ Object
Returns the value of attribute is_test.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def is_test @is_test end |
#ref ⇒ Object
Returns the value of attribute ref.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def ref @ref end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def status @status end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
5 6 7 |
# File 'lib/cardgate/callback.rb', line 5 def transaction_id @transaction_id end |
Instance Method Details
#failed? ⇒ Boolean
28 29 30 |
# File 'lib/cardgate/callback.rb', line 28 def failed? [300, 301].include?(@status.to_i) end |
#recurring_failed? ⇒ Boolean
32 33 34 |
# File 'lib/cardgate/callback.rb', line 32 def recurring_failed? @status.to_i == 310 end |
#refund? ⇒ Boolean
36 37 38 |
# File 'lib/cardgate/callback.rb', line 36 def refund? @status.to_i == 400 end |
#response ⇒ Object
20 21 22 |
# File 'lib/cardgate/callback.rb', line 20 def response "#{@transaction_id}.#{@status}" end |
#successful? ⇒ Boolean
24 25 26 |
# File 'lib/cardgate/callback.rb', line 24 def successful? [200, 210].include?(@status.to_i) end |
#valid? ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/cardgate/callback.rb', line 13 def valid? hash_elements = [ @transaction_id, @currency, @amount, @ref, @status, @hash_key ] hash_elements.unshift 'TEST' if @is_test.to_i == 1 Digest::MD5.hexdigest(hash_elements.join) == @hash end |