Class: MoneyOnline::Response
- Inherits:
-
Object
- Object
- MoneyOnline::Response
- Defined in:
- lib/money_online/response.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #amount ⇒ Object
- #code ⇒ Object
- #error ⇒ Object
- #generate_signature ⇒ Object
- #generate_signature_string ⇒ Object
-
#initialize(params) ⇒ Response
constructor
A new instance of Response.
- #invalid? ⇒ Boolean
- #money_payment_id ⇒ Object
- #order_id ⇒ Object
- #signature ⇒ Object
- #to_xml(*args) ⇒ Object
- #user_extra ⇒ Object
- #user_id ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/money_online/response.rb', line 5 def initialize(params) @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/money_online/response.rb', line 3 def params @params end |
Instance Method Details
#amount ⇒ Object
9 10 11 |
# File 'lib/money_online/response.rb', line 9 def amount params[:amount].to_i end |
#code ⇒ Object
60 61 62 |
# File 'lib/money_online/response.rb', line 60 def code valid? ? "YES" : "NO" end |
#error ⇒ Object
64 65 66 |
# File 'lib/money_online/response.rb', line 64 def error "Signature is not valid" if invalid? end |
#generate_signature ⇒ Object
37 38 39 |
# File 'lib/money_online/response.rb', line 37 def generate_signature Digest::MD5.hexdigest(generate_signature_string) end |
#generate_signature_string ⇒ Object
33 34 35 |
# File 'lib/money_online/response.rb', line 33 def generate_signature_string [ params[:amount], user_id, money_payment_id, MoneyOnline.config.secret ].join end |
#invalid? ⇒ Boolean
45 46 47 |
# File 'lib/money_online/response.rb', line 45 def invalid? not valid? end |
#money_payment_id ⇒ Object
21 22 23 |
# File 'lib/money_online/response.rb', line 21 def money_payment_id params[:paymentid].to_i end |
#order_id ⇒ Object
25 26 27 |
# File 'lib/money_online/response.rb', line 25 def order_id params[:orderid].to_i end |
#signature ⇒ Object
29 30 31 |
# File 'lib/money_online/response.rb', line 29 def signature params[:key] end |
#to_xml(*args) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/money_online/response.rb', line 49 def to_xml(*args) <<-XML <?xml version="1.0" encoding="UTF-8"?> <result> <id>#{order_id}</id> <code>#{code}</code> <comment>#{error}</comment> </result> XML end |
#user_extra ⇒ Object
17 18 19 |
# File 'lib/money_online/response.rb', line 17 def user_extra params[:userid_extra] end |
#user_id ⇒ Object
13 14 15 |
# File 'lib/money_online/response.rb', line 13 def user_id params[:userid].to_i end |
#valid? ⇒ Boolean
41 42 43 |
# File 'lib/money_online/response.rb', line 41 def valid? generate_signature == signature end |