platidoma 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/platidoma/client.rb +59 -0
- data/lib/platidoma/client_proxy.rb +12 -0
- data/lib/platidoma/response/get_status.rb +22 -0
- data/lib/platidoma/version.rb +3 -0
- data/lib/platidoma.rb +10 -0
- data/platidoma.gemspec +25 -0
- data/test/fixtures/response.xml +14 -0
- data/test/lib/platidoma/client_test.rb +38 -0
- data/test/lib/platidoma/response/get_status_test.rb +0 -0
- data/test/test_helper.rb +13 -0
- metadata +115 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 PanfilovDenis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Platidoma
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'platidoma'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install platidoma
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Platidoma
|
2
|
+
|
3
|
+
class Client
|
4
|
+
attr_accessor :shop_id, :login, :gate_password, :url
|
5
|
+
|
6
|
+
def initialize(args)
|
7
|
+
self.shop_id = args[:shop_id]
|
8
|
+
self.login = args[:login]
|
9
|
+
self.gate_password = args[:gate_password]
|
10
|
+
self.url = args[:url]
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_payment_sign(args)
|
14
|
+
amount = args[:amount]
|
15
|
+
rnd = args[:rnd]
|
16
|
+
#FIXME преоброзование суммы к формату .xx
|
17
|
+
Digest::MD5.hexdigest("#{shop_id}:#{login}:#{gate_password}:#{rnd}:#{amount}.00")
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_status_sign(args)
|
21
|
+
amount = args[:amount]
|
22
|
+
rnd = args[:rnd]
|
23
|
+
trans_id = args[:trans_id]
|
24
|
+
order_id = args[:order_id]
|
25
|
+
Digest::MD5.hexdigest("#{shop_id}:#{login}:#{gate_password}:#{rnd}:#{trans_id}:#{order_id}:#{amount}.00")
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_payment_url(args)
|
29
|
+
params = {
|
30
|
+
pd_shop_id: shop_id,
|
31
|
+
pd_login: login,
|
32
|
+
pd_amount: "#{args[:amount]}.00",
|
33
|
+
pd_order_id: args[:order_id],
|
34
|
+
pd_email: args[:email],
|
35
|
+
pd_rnd: args[:rnd],
|
36
|
+
pd_sign: args[:sign]
|
37
|
+
}
|
38
|
+
|
39
|
+
uri = ::Addressable::URI.new
|
40
|
+
uri.query_values = params
|
41
|
+
|
42
|
+
"#{url}?#{uri.query}"
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def get_status(args)
|
48
|
+
response = client_proxy.get_status(args).perform
|
49
|
+
Response::GetStatus.parse(response.body).pd_status if response.success?
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def client_proxy
|
54
|
+
@client_proxy ||= ClientProxy.new
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Platidoma
|
2
|
+
module Response
|
3
|
+
class GetStatus
|
4
|
+
include HappyMapper
|
5
|
+
|
6
|
+
tag 'transaction'
|
7
|
+
|
8
|
+
element :pd_trans_id, Integer
|
9
|
+
element :pd_order_id, Integer
|
10
|
+
element :pd_amount, String
|
11
|
+
element :pd_status, String
|
12
|
+
element :pd_payment_number, String
|
13
|
+
element :pd_auth_code, String
|
14
|
+
element :pd_rnd, String
|
15
|
+
element :pd_sign, String
|
16
|
+
element :pd_creation_time, String
|
17
|
+
element :pd_paid_time, String
|
18
|
+
element :pd_reversed_time, String
|
19
|
+
element :pd_declined_time, String
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/platidoma.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
autoload :Version, 'platidoma/version'
|
2
|
+
require "addressable/uri"
|
3
|
+
require "weary"
|
4
|
+
require 'happymapper'
|
5
|
+
|
6
|
+
module Platidoma
|
7
|
+
autoload 'Client', 'platidoma/client'
|
8
|
+
autoload 'ClientProxy', 'platidoma/client_proxy'
|
9
|
+
autoload 'Response', 'platidoma/response/get_status'
|
10
|
+
end
|
data/platidoma.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'platidoma/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "platidoma"
|
8
|
+
gem.version = Platidoma::VERSION
|
9
|
+
gem.authors = ["Panfilov Denis", "Frank Alexey"]
|
10
|
+
gem.email = ["panf.denis@gmail.com", "alexeyfrank@gmail.com"]
|
11
|
+
gem.description = %q{Platidoma.ru API}
|
12
|
+
gem.summary = %q{platidoma}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "weary", '1.1.2'
|
21
|
+
gem.add_runtime_dependency "addressable"
|
22
|
+
gem.add_runtime_dependency "happymapper"
|
23
|
+
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<transaction>
|
2
|
+
<pd_trans_id>14</pd_trans_id>
|
3
|
+
<pd_order_id>123</pd_order_id>
|
4
|
+
<pd_amount>120.56</pd_amount>
|
5
|
+
<pd_status>paid</pd_status>
|
6
|
+
<pd_payment_number>77260</pd_payment_number>
|
7
|
+
<pd_auth_code>391650</pd_auth_code>
|
8
|
+
<pd_rnd>z7K0gSp0</pd_rnd>
|
9
|
+
<pd_sign>58ceeaa86f761f31af52036a4fb77660</pd_sign>
|
10
|
+
<pd_creation_time>2011-12-13 16:46:20</pd_creation_time>
|
11
|
+
<pd_paid_time>2011-12-13 16:46:48</pd_paid_time>
|
12
|
+
<pd_reversed_time></pd_reversed_time>
|
13
|
+
<pd_declined_time></pd_declined_time>
|
14
|
+
</transaction>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ClientTest < TestCase
|
4
|
+
def setup
|
5
|
+
@stub = stub_request(:post, "https://pg-test.platidoma.ru/status.php").
|
6
|
+
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
7
|
+
to_return(:status => 200, :body => load_fixture('response.xml'), :headers => {})
|
8
|
+
|
9
|
+
@parms = { shop_id: 1, login: "test", gate_password: "test" }
|
10
|
+
@client = Platidoma::Client.new(@parms)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_get_status
|
14
|
+
@request_params = {pd_shop_id: 1, pd_trans_id: 1, pd_rnd: "test", pd_sign: "qq"}
|
15
|
+
response_status = @client.get_status(@request_params)
|
16
|
+
expected_response = Platidoma::Response::GetStatus.parse(load_fixture('response.xml'))
|
17
|
+
assert_equal response_status, expected_response.pd_status
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_build_payment_url
|
21
|
+
params = {
|
22
|
+
shop_id: 1,
|
23
|
+
login: "test",
|
24
|
+
amount: 1,
|
25
|
+
order_id: 1,
|
26
|
+
description: "descr",
|
27
|
+
email: "email",
|
28
|
+
rnd: "rnd",
|
29
|
+
sign: "sign",
|
30
|
+
}
|
31
|
+
|
32
|
+
url = @client.build_payment_url params
|
33
|
+
expected_url = "?pd_amount=1.00&pd_email=email&pd_login=test&pd_order_id=1&pd_rnd=rnd&pd_shop_id=1&pd_sign=sign"
|
34
|
+
assert_equal expected_url, url
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
File without changes
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: platidoma
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Panfilov Denis
|
9
|
+
- Frank Alexey
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: weary
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - '='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.1.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - '='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.1.2
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: addressable
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: happymapper
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
description: Platidoma.ru API
|
64
|
+
email:
|
65
|
+
- panf.denis@gmail.com
|
66
|
+
- alexeyfrank@gmail.com
|
67
|
+
executables: []
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files: []
|
70
|
+
files:
|
71
|
+
- .gitignore
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- lib/platidoma.rb
|
77
|
+
- lib/platidoma/client.rb
|
78
|
+
- lib/platidoma/client_proxy.rb
|
79
|
+
- lib/platidoma/response/get_status.rb
|
80
|
+
- lib/platidoma/version.rb
|
81
|
+
- platidoma.gemspec
|
82
|
+
- test/fixtures/response.xml
|
83
|
+
- test/lib/platidoma/client_test.rb
|
84
|
+
- test/lib/platidoma/response/get_status_test.rb
|
85
|
+
- test/test_helper.rb
|
86
|
+
homepage: ''
|
87
|
+
licenses: []
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.24
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: platidoma
|
110
|
+
test_files:
|
111
|
+
- test/fixtures/response.xml
|
112
|
+
- test/lib/platidoma/client_test.rb
|
113
|
+
- test/lib/platidoma/response/get_status_test.rb
|
114
|
+
- test/test_helper.rb
|
115
|
+
has_rdoc:
|