Class: WebpayBy::Response
- Inherits:
-
Object
- Object
- WebpayBy::Response
- Defined in:
- lib/webpay_by/response.rb
Constant Summary collapse
- SUCCESSFUL_TYPE_INDEXES =
%w( 1 4 )
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#batch_timestamp ⇒ Object
readonly
Returns the value of attribute batch_timestamp.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#currency_id ⇒ Object
readonly
Returns the value of attribute currency_id.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#payment_method ⇒ Object
readonly
Returns the value of attribute payment_method.
-
#payment_type ⇒ Object
readonly
Returns the value of attribute payment_type.
-
#rrn ⇒ Object
readonly
Returns the value of attribute rrn.
-
#site_order_id ⇒ Object
readonly
Returns the value of attribute site_order_id.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Instance Method Summary collapse
- #approved? ⇒ Boolean
-
#initialize(options = {}) ⇒ Response
constructor
A new instance of Response.
- #signature ⇒ Object
-
#valid_signature? ⇒ Boolean
wsb_signature представляет собой hex-последовательность и является результатом выполнения функции MD 5.
Constructor Details
#initialize(options = {}) ⇒ Response
Returns a new instance of Response.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/webpay_by/response.rb', line 34 def initialize( = {}) @client = [:client] @batch_timestamp = [:batch_timestamp] @currency_id = [:currency_id] @amount = [:amount] @payment_method = [:payment_method] @order_id = [:order_id] @site_order_id = [:site_order_id] @transaction_id = [:transaction_id] @payment_type = [:payment_type] @rrn = [:rrn] @wsb_signature = [:wsb_signature] end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def amount @amount end |
#batch_timestamp ⇒ Object (readonly)
Returns the value of attribute batch_timestamp.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def @batch_timestamp end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def client @client end |
#currency_id ⇒ Object (readonly)
Returns the value of attribute currency_id.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def currency_id @currency_id end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def order_id @order_id end |
#payment_method ⇒ Object (readonly)
Returns the value of attribute payment_method.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def payment_method @payment_method end |
#payment_type ⇒ Object (readonly)
Returns the value of attribute payment_type.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def payment_type @payment_type end |
#rrn ⇒ Object (readonly)
Returns the value of attribute rrn.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def rrn @rrn end |
#site_order_id ⇒ Object (readonly)
Returns the value of attribute site_order_id.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def site_order_id @site_order_id end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
31 32 33 |
# File 'lib/webpay_by/response.rb', line 31 def transaction_id @transaction_id end |
Instance Method Details
#approved? ⇒ Boolean
48 49 50 |
# File 'lib/webpay_by/response.rb', line 48 def approved? valid_signature? && @payment_type.in?(SUCCESSFUL_TYPE_INDEXES) end |
#signature ⇒ Object
58 59 60 61 62 63 |
# File 'lib/webpay_by/response.rb', line 58 def signature signed_attrs = [@batch_timestamp, @currency_id, @amount, @payment_method, @order_id, @site_order_id, @transaction_id, @payment_type, @rrn, @client.secret_key].join Digest::MD5.hexdigest signed_attrs end |
#valid_signature? ⇒ Boolean
wsb_signature представляет собой hex-последовательность и является результатом выполнения функции MD 5. В качестве аргумента функции MD5 служит текстовая последовательность, полученная путем простой конкатенации
54 55 56 |
# File 'lib/webpay_by/response.rb', line 54 def valid_signature? @wsb_signature.to_s == signature end |