Class: OnPayRuClient::Client
- Inherits:
-
Object
- Object
- OnPayRuClient::Client
- Defined in:
- lib/onpayruclient.rb
Instance Attribute Summary collapse
-
#fail_url ⇒ Object
readonly
Returns the value of attribute fail_url.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#success_url ⇒ Object
readonly
Returns the value of attribute success_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #check(type, pay_for, amount, order_currency, code) ⇒ Object
- #check_md5(type, pay_for, amount, order_currency) ⇒ Object
- #get_url(pay_for, amount, email) ⇒ Object
-
#initialize(login, key, url, success_url, fail_url) ⇒ Client
constructor
A new instance of Client.
- #pay(type, pay_for, onpay_id, order_id, amount, order_currency, code) ⇒ Object
- #pay_md5(type, pay_for, onpay_id, amount, order_currency) ⇒ Object
Constructor Details
#initialize(login, key, url, success_url, fail_url) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 |
# File 'lib/onpayruclient.rb', line 12 def initialize(login, key, url, success_url, fail_url) @login = login @key = key @url = url @success_url = success_url @fail_url = fail_url end |
Instance Attribute Details
#fail_url ⇒ Object (readonly)
Returns the value of attribute fail_url.
10 11 12 |
# File 'lib/onpayruclient.rb', line 10 def fail_url @fail_url end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/onpayruclient.rb', line 10 def key @key end |
#login ⇒ Object (readonly)
Returns the value of attribute login.
10 11 12 |
# File 'lib/onpayruclient.rb', line 10 def login @login end |
#success_url ⇒ Object (readonly)
Returns the value of attribute success_url.
10 11 12 |
# File 'lib/onpayruclient.rb', line 10 def success_url @success_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/onpayruclient.rb', line 10 def url @url end |
Instance Method Details
#check(type, pay_for, amount, order_currency, code) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/onpayruclient.rb', line 20 def check(type, pay_for, amount, order_currency, code) md5 = Digest::MD5.hexdigest( type.to_s + ";" + pay_for.to_s + ";" + amount.to_s + ";" + order_currency.to_s + ";" + code.to_s + ";" + @key.to_s ).upcase query = String.new xml = Builder::XmlMarkup.new(:target => query) xml.result { xml.code code.to_s xml.pay_for pay_for.to_s xml.comment "OK" xml.md5 md5.to_s } return query end |
#check_md5(type, pay_for, amount, order_currency) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/onpayruclient.rb', line 39 def check_md5(type, pay_for, amount, order_currency) md5 = Digest::MD5.hexdigest( type.to_s + ";" + pay_for.to_s + ";" + amount.to_s + ";" + order_currency.to_s + ";" + @key.to_s ).upcase end |
#get_url(pay_for, amount, email) ⇒ Object
75 76 77 |
# File 'lib/onpayruclient.rb', line 75 def get_url(pay_for, amount, email) return "http://secure.onpay.ru/pay/#{@login}?pay_mode=fix&price=#{amount.to_s}&pay_for=#{pay_for.to_s}&user_email=#{email}&url_success=#{@success_url}&url_fail=#{@fail_url}" end |
#pay(type, pay_for, onpay_id, order_id, amount, order_currency, code) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/onpayruclient.rb', line 46 def pay(type, pay_for, onpay_id, order_id, amount, order_currency, code) md5 = Digest::MD5.hexdigest( type.to_s + ";" + pay_for.to_s + ";" + onpay_id.to_s + ";" + order_id.to_s + ";" + amount.to_s + ";" + order_currency.to_s + ";" + code.to_s + ";" + @key.to_s ).upcase query = String.new xml = Builder::XmlMarkup.new(:target => query) xml.result { xml.code code.to_s xml.comment "OK" xml.onpay_id onpay_id.to_s xml.pay_for pay_for.to_s xml.order_id order_id.to_s xml.md5 md5.to_s } return query end |
#pay_md5(type, pay_for, onpay_id, amount, order_currency) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/onpayruclient.rb', line 68 def pay_md5(type, pay_for, onpay_id, amount, order_currency) md5 = Digest::MD5.hexdigest( type.to_s + ";" + pay_for.to_s + ";" + onpay_id.to_s + ";" + amount.to_s + ";" + order_currency.to_s + ";" + @key.to_s ).upcase end |