onpayruclient 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6862dee9d7822dd29ba697f2adddb9984c48f13
4
+ data.tar.gz: 21b634b49c6f218094a925649a70cacf1adbabef
5
+ SHA512:
6
+ metadata.gz: a28d1cedc5bf847fac144894bc82154289c18a19eced678ec45e1a08495122143330c6022b5d1ea152064333f1859b7c2566ec9436c16896eda96adca3299c34
7
+ data.tar.gz: e440192dadfd96cb462eb713ae082e2ada3d08f03e482f8597a48ada309e53371ef4cf520e99a92ad94b369485fcf312deb710c9d37d2f0cb6d49111f336640d
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ onpayruclient (0.1.0)
5
+ builder
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ builder (3.2.2)
11
+ diff-lcs (1.2.4)
12
+ rake (10.1.0)
13
+ rspec (2.14.1)
14
+ rspec-core (~> 2.14.0)
15
+ rspec-expectations (~> 2.14.0)
16
+ rspec-mocks (~> 2.14.0)
17
+ rspec-core (2.14.2)
18
+ rspec-expectations (2.14.0)
19
+ diff-lcs (>= 1.1.3, < 2.0)
20
+ rspec-mocks (2.14.1)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ onpayruclient!
27
+ rake
28
+ rspec
data/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010-2013 Nikolay Burlov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # OnPayRuClient
2
+
3
+ OnPayRuClient is a gem that provides an interface for onpay.ru API.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ require 'onpayruclient'
9
+
10
+ onpayru = OnPayRuClient::Client.new('username', 'key', 'api_url')
11
+ onpayru.get_url('payment_id', 'payment_amount', 'user_email', 'success_url', 'fail_url')
12
+ onpayru.check_md5('check', 'payment_id', 'payment_amount', 'RUR')
13
+ onpayru.check('check', 'payment_id', 'payment_amount', 'RUR', 0)
14
+ onpayru.pay_md5('pay', 'payment_id', 'onpay_id', 'payment_amount', 'RUR')
15
+ ```
16
+
17
+ ## Installation
18
+
19
+ gem install onpayruclient
20
+
21
+ ## Changelog
22
+
23
+ 0.1.0 - Refactor client and add tests
data/lib/onpayruclient.rb CHANGED
@@ -1,19 +1,20 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'rubygems'
4
3
  require 'digest/md5'
5
4
  require 'builder'
6
5
 
7
6
  module OnPayRuClient
8
- VERSION = '0.0.2'
7
+ VERSION = '0.1.0'
9
8
 
10
9
  class Client
11
- attr_accessor :login, :key, :url
10
+ attr_reader :login, :key, :url, :success_url, :fail_url
12
11
 
13
- def initialize(login, key, url)
12
+ def initialize(login, key, url, success_url, fail_url)
14
13
  @login = login
15
14
  @key = key
16
15
  @url = url
16
+ @success_url = success_url
17
+ @fail_url = fail_url
17
18
  end
18
19
 
19
20
  def check(type, pay_for, amount, order_currency, code)
@@ -71,8 +72,8 @@ module OnPayRuClient
71
72
  ).upcase
72
73
  end
73
74
 
74
- def get_url(pay_for, amount, email, url_success, url_fail)
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}"
75
+ def get_url(pay_for, amount, email)
76
+ 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}"
76
77
  end
77
78
  end
78
- end
79
+ end
@@ -1,29 +1,22 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
2
 
3
- Gem::Specification.new do |s|
4
- s.name = %q{onpayruclient}
5
- s.version = "0.0.2"
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'onpayruclient'
5
+ spec.description = %q{A gem that provides an interface to onpay.ru API.}
6
+ spec.authors = ['Nikolay Burlov']
7
+ spec.email = ['kohgpat@gmail.com']
6
8
 
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}
9
+ spec.add_dependency 'builder'
20
10
 
21
- if s.respond_to? :specification_version then
22
- s.specification_version = 3
11
+ spec.add_development_dependency 'rake'
12
+ spec.add_development_dependency 'rspec'
23
13
 
24
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- else
26
- end
27
- else
28
- end
14
+ spec.version = '0.1.0'
15
+ spec.files = `git ls-files`.split("\n")
16
+ spec.homepage = 'http://github.com/kohgpat/onpayruclient'
17
+ spec.licenses = ['MIT']
18
+ spec.require_paths = ['lib']
19
+ spec.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
20
+ spec.summary = %q{A gem that provides an interface to onpay.ru API.}
21
+ spec.test_files = `git ls-files -- {test,spec,feature}/*`.split("\n")
29
22
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe OnPayRuClient::Client do
4
+ class Payment < Struct.new(:id, :amount, :email); end
5
+
6
+ let(:success_url) { "http://site.com/payments/success" }
7
+ let(:fail_url) { "http://site.com/payments/failure" }
8
+ let(:onpayru) { OnPayRuClient::Client.new('a', 'b', 'c', success_url, fail_url) }
9
+
10
+ let(:payment) { Payment.new('1', '100.0', 'user@example.com') }
11
+
12
+ it 'gets initialization params' do
13
+ expect(onpayru.login).to eq('a')
14
+ expect(onpayru.key).to eq('b')
15
+ expect(onpayru.url).to eq('c')
16
+ end
17
+
18
+ it 'returns payment url' do
19
+ expect(onpayru.get_url(payment.id, payment.amount, payment.email)).to\
20
+ eq("http://secure.onpay.ru/pay/#{onpayru.login}?pay_mode=fix&price=#{payment.amount}&pay_for=#{payment.id}&user_email=#{payment.email}&url_success=#{onpayru.success_url}&url_fail=#{onpayru.fail_url}")
21
+ end
22
+
23
+ it 'checks check md5' do
24
+ md5 = Digest::MD5.hexdigest("check;#{payment.id};#{payment.amount};RUR;0;#{onpayru.key}").upcase
25
+ expect(md5).to eq("C24217C61CB831C1028F52DA63C691CC")
26
+ end
27
+
28
+ it 'checks pay md5' do
29
+ md5 = Digest::MD5.hexdigest("pay;#{payment.id};1;#{payment.amount};RUR;0").upcase
30
+ expect(md5).to eq("4164761F594B072ABDDD1492C648F2E0")
31
+ end
32
+
33
+ it 'returns check request' do
34
+ md5 = Digest::MD5.hexdigest("check;#{payment.id};#{payment.amount};RUR;0;#{onpayru.key}").upcase
35
+ expect(onpayru.check("check", payment.id, payment.amount, "RUR", 0)).to\
36
+ eq("<result><code>0</code><pay_for>#{payment.id}</pay_for><comment>OK</comment><md5>#{md5}</md5></result>")
37
+ end
38
+
39
+ it 'returns pay request' do
40
+ md5 = Digest::MD5.hexdigest("pay;#{payment.id};1;#{payment.amount};RUR;0").upcase
41
+ expect(onpayru.pay("pay", payment.id, 1, payment.id, payment.amount, "RUR", 0)).to\
42
+ eq("<result><code>0</code><comment>OK</comment><onpay_id>1</onpay_id><pay_for>1</pay_for><order_id>1</order_id><md5>ABA5F57C42FD5AD6FF49AD690CBC08BE</md5></result>")
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib/'))
2
+
3
+ require 'onpayruclient'
metadata CHANGED
@@ -1,64 +1,98 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: onpayruclient
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Nikolay Burlov
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-08-09 00:00:00 Z
14
- dependencies: []
15
-
16
- description: OnPayRu Service Consumer
17
- email: kohgpat@gmail.com
11
+ date: 2013-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: builder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A gem that provides an interface to onpay.ru API.
56
+ email:
57
+ - kohgpat@gmail.com
18
58
  executables: []
19
-
20
59
  extensions: []
21
-
22
- extra_rdoc_files:
23
- - README
24
- - lib/onpayruclient.rb
25
- files:
26
- - README
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .rspec
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE.md
66
+ - README.md
27
67
  - Rakefile
28
68
  - lib/onpayruclient.rb
29
- - Manifest
30
69
  - onpayruclient.gemspec
70
+ - spec/onpayruclient_spec.rb
71
+ - spec/spec_helper.rb
31
72
  homepage: http://github.com/kohgpat/onpayruclient
32
- licenses: []
33
-
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
34
76
  post_install_message:
35
- rdoc_options:
36
- - --line-numbers
37
- - --inline-source
38
- - --title
39
- - Onpayruclient
40
- - --main
41
- - README
42
- require_paths:
77
+ rdoc_options: []
78
+ require_paths:
43
79
  - lib
44
- required_ruby_version: !ruby/object:Gem::Requirement
45
- none: false
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: "0"
50
- required_rubygems_version: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "1.2"
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.6
56
90
  requirements: []
57
-
58
- rubyforge_project: onpayruclient
59
- rubygems_version: 1.8.5
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.5
60
93
  signing_key:
61
- specification_version: 3
62
- summary: OnPayRu Service Consumer
63
- test_files: []
64
-
94
+ specification_version: 4
95
+ summary: A gem that provides an interface to onpay.ru API.
96
+ test_files:
97
+ - spec/onpayruclient_spec.rb
98
+ - spec/spec_helper.rb
data/Manifest DELETED
@@ -1,4 +0,0 @@
1
- README
2
- Rakefile
3
- lib/onpayruclient.rb
4
- Manifest
data/README DELETED
File without changes