onpayruclient 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Manifest +4 -0
  2. data/Rakefile +11 -0
  3. data/lib/onpayruclient.rb +26 -12
  4. data/onpayruclient.gemspec +29 -0
  5. metadata +19 -11
data/Manifest ADDED
@@ -0,0 +1,4 @@
1
+ README
2
+ Rakefile
3
+ lib/onpayruclient.rb
4
+ Manifest
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('onpayruclient', '0.0.2') do |p|
6
+ p.description = "OnPayRu Service Consumer"
7
+ p.url = "http://github.com/kohgpat/onpayruclient"
8
+ p.author = "Nikolay Burlov"
9
+ p.email = "kohgpat@gmail.com"
10
+ p.development_dependencies = []
11
+ end
data/lib/onpayruclient.rb CHANGED
@@ -5,46 +5,53 @@ require 'digest/md5'
5
5
  require 'builder'
6
6
 
7
7
  module OnPayRuClient
8
- VERSION = '0.0.1'
9
-
8
+ VERSION = '0.0.2'
9
+
10
10
  class Client
11
11
  attr_accessor :login, :key, :url
12
-
12
+
13
13
  def initialize(login, key, url)
14
14
  @login = login
15
15
  @key = key
16
16
  @url = url
17
17
  end
18
-
18
+
19
19
  def check(type, pay_for, amount, order_currency, code)
20
20
  md5 = Digest::MD5.hexdigest(
21
21
  type.to_s + ";" + pay_for.to_s + ";" + amount.to_s + ";" +
22
22
  order_currency.to_s + ";" + code.to_s + ";" + @key.to_s
23
23
  ).upcase
24
-
24
+
25
25
  query = String.new
26
26
  xml = Builder::XmlMarkup.new(:target => query)
27
-
27
+
28
28
  xml.result {
29
29
  xml.code code.to_s
30
30
  xml.pay_for pay_for.to_s
31
31
  xml.comment "OK"
32
32
  xml.md5 md5.to_s
33
33
  }
34
-
34
+
35
35
  return query
36
36
  end
37
-
37
+
38
+ def check_md5(type, pay_for, amount, order_currency)
39
+ md5 = Digest::MD5.hexdigest(
40
+ type.to_s + ";" + pay_for.to_s + ";" + amount.to_s + ";" +
41
+ order_currency.to_s + ";" + @key.to_s
42
+ ).upcase
43
+ end
44
+
38
45
  def pay(type, pay_for, onpay_id, order_id, amount, order_currency, code)
39
46
  md5 = Digest::MD5.hexdigest(
40
47
  type.to_s + ";" + pay_for.to_s + ";" + onpay_id.to_s + ";" +
41
48
  order_id.to_s + ";" + amount.to_s + ";" + order_currency.to_s + ";" +
42
49
  code.to_s + ";" + @key.to_s
43
50
  ).upcase
44
-
51
+
45
52
  query = String.new
46
53
  xml = Builder::XmlMarkup.new(:target => query)
47
-
54
+
48
55
  xml.result {
49
56
  xml.code code.to_s
50
57
  xml.comment "OK"
@@ -53,10 +60,17 @@ module OnPayRuClient
53
60
  xml.order_id order_id.to_s
54
61
  xml.md5 md5.to_s
55
62
  }
56
-
63
+
57
64
  return query
58
65
  end
59
-
66
+
67
+ def pay_md5(type, pay_for, onpay_id, amount, order_currency)
68
+ md5 = Digest::MD5.hexdigest(
69
+ type.to_s + ";" + pay_for.to_s + ";" + onpay_id.to_s + ";" +
70
+ amount.to_s + ";" + order_currency.to_s + ";" + @key.to_s
71
+ ).upcase
72
+ end
73
+
60
74
  def get_url(pay_for, amount, email, url_success, url_fail)
61
75
  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=#{url_success}&url_fail=#{url_fail}"
62
76
  end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{onpayruclient}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = [%q{Nikolay Burlov}]
9
+ s.date = %q{2011-08-09}
10
+ s.description = %q{OnPayRu Service Consumer}
11
+ s.email = %q{kohgpat@gmail.com}
12
+ s.extra_rdoc_files = [%q{README}, %q{lib/onpayruclient.rb}]
13
+ s.files = [%q{README}, %q{Rakefile}, %q{lib/onpayruclient.rb}, %q{Manifest}, %q{onpayruclient.gemspec}]
14
+ s.homepage = %q{http://github.com/kohgpat/onpayruclient}
15
+ s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Onpayruclient}, %q{--main}, %q{README}]
16
+ s.require_paths = [%q{lib}]
17
+ s.rubyforge_project = %q{onpayruclient}
18
+ s.rubygems_version = %q{1.8.5}
19
+ s.summary = %q{OnPayRu Service Consumer}
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
metadata CHANGED
@@ -2,35 +2,43 @@
2
2
  name: onpayruclient
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
- - Nikolay BUrlov
8
+ - Nikolay Burlov
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-06 00:00:00 Z
13
+ date: 2011-08-09 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: OnPayRu Service Consumer
17
- email:
18
- - kohgpat@gmail.com
17
+ email: kohgpat@gmail.com
19
18
  executables: []
20
19
 
21
20
  extensions: []
22
21
 
23
- extra_rdoc_files: []
24
-
22
+ extra_rdoc_files:
23
+ - README
24
+ - lib/onpayruclient.rb
25
25
  files:
26
26
  - README
27
+ - Rakefile
27
28
  - lib/onpayruclient.rb
29
+ - Manifest
30
+ - onpayruclient.gemspec
28
31
  homepage: http://github.com/kohgpat/onpayruclient
29
32
  licenses: []
30
33
 
31
34
  post_install_message:
32
- rdoc_options: []
33
-
35
+ rdoc_options:
36
+ - --line-numbers
37
+ - --inline-source
38
+ - --title
39
+ - Onpayruclient
40
+ - --main
41
+ - README
34
42
  require_paths:
35
43
  - lib
36
44
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -44,10 +52,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
52
  requirements:
45
53
  - - ">="
46
54
  - !ruby/object:Gem::Version
47
- version: 1.3.6
55
+ version: "1.2"
48
56
  requirements: []
49
57
 
50
- rubyforge_project:
58
+ rubyforge_project: onpayruclient
51
59
  rubygems_version: 1.8.5
52
60
  signing_key:
53
61
  specification_version: 3