webmoney 0.0.4.2 → 0.0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/README +11 -0
- data/lib/messenger.rb +0 -1
- data/lib/webmoney.rb +99 -31
- data/lib/wmid.rb +3 -1
- data/rakefile +3 -16
- data/spec/unit/passport_spec.rb +1 -1
- metadata +31 -30
data/ChangeLog
CHANGED
data/README
ADDED
data/lib/messenger.rb
CHANGED
data/lib/webmoney.rb
CHANGED
@@ -1,3 +1,66 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
== About Webmoney library
|
3
|
+
|
4
|
+
This library help to make requests to WebMoney Transfer http://www.wmtransfer.com
|
5
|
+
XML-interfaces: http://www.wmtransfer.com/eng/developers/interfaces/index.shtml
|
6
|
+
|
7
|
+
Gem have built-in native *wmsigner*.
|
8
|
+
|
9
|
+
Author:: Alexander Oryol (mailto:eagle.alex@gmail.com)
|
10
|
+
License:: MIT License
|
11
|
+
|
12
|
+
== Request types
|
13
|
+
|
14
|
+
- create_invoice - x1
|
15
|
+
- create_transaction - x2
|
16
|
+
- operation_history - x3
|
17
|
+
- outgoing_invoices - x4
|
18
|
+
- finish_protect - x5
|
19
|
+
- send_message - x6
|
20
|
+
- check_sign - x7
|
21
|
+
- find_wm - x8
|
22
|
+
- balance - x9
|
23
|
+
- incoming_invoices - x10
|
24
|
+
- get_passport - x11
|
25
|
+
- reject_protection - x13
|
26
|
+
- transaction_moneyback - x14
|
27
|
+
- i_trust - x15
|
28
|
+
- trust_me - x15
|
29
|
+
- trust_save - x15
|
30
|
+
- create_purse - x16
|
31
|
+
- bussines_level
|
32
|
+
|
33
|
+
Please, see relative documentation and parameters on wiki:
|
34
|
+
|
35
|
+
http://wiki.wmtransfer.com/wiki/list/XML-Interfaces
|
36
|
+
|
37
|
+
http://wiki.webmoney.ru/wiki/list/XML-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D1%84%D0%B5%D0%B9%D1%81%D1%8B (in russian)
|
38
|
+
|
39
|
+
or official sites:
|
40
|
+
|
41
|
+
http://www.wmtransfer.com/eng/developers/interfaces/xml/index.shtml
|
42
|
+
|
43
|
+
http://www.webmoney.ru/rus/developers/interfaces/xml/index.shtml (in russian)
|
44
|
+
|
45
|
+
== Examples
|
46
|
+
|
47
|
+
@wm = Webmoney.new(:wmid => '123456789012', :password => 'my_pass', :key => 'gQABAIR6...2cC8FZTyKyjBM=')
|
48
|
+
|
49
|
+
passport = @wm.request(:get_passport, :wmid => @wm.wmid)
|
50
|
+
|
51
|
+
bl = @wm.request(:bussines_level, :wmid => '123456789012')
|
52
|
+
|
53
|
+
@wm.request(:send_message, :wmid => @wm.wmid, :subj => 'Subject', :text => 'Body of \<b>message\</b>')
|
54
|
+
|
55
|
+
|
56
|
+
Also, see examples into spec's.
|
57
|
+
=end
|
58
|
+
|
59
|
+
|
60
|
+
# :title:Webmoney library Documentation
|
61
|
+
# :main:lib/webmoney.rb
|
62
|
+
# :include:README
|
63
|
+
|
1
64
|
require File.dirname(__FILE__) +'/wmsigner'
|
2
65
|
require 'time'
|
3
66
|
require 'net/http'
|
@@ -7,15 +70,9 @@ require 'iconv'
|
|
7
70
|
require 'builder'
|
8
71
|
require 'hpricot'
|
9
72
|
|
10
|
-
class Object
|
11
|
-
def blank?
|
12
|
-
respond_to?(:empty?) ? empty? : !self
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
73
|
# Main class for Webmoney lib. Instance contain info
|
17
|
-
# for
|
18
|
-
# Implement
|
74
|
+
# for WMT-interfaces requests (wmid, key, etc).
|
75
|
+
# Implement general requests.
|
19
76
|
class Webmoney
|
20
77
|
|
21
78
|
# Error classes
|
@@ -32,14 +89,20 @@ class Webmoney
|
|
32
89
|
attr_reader :wmid, :error, :errormsg, :last_request, :messenger
|
33
90
|
|
34
91
|
# Required options:
|
35
|
-
#
|
36
|
-
# :
|
37
|
-
# :key
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
92
|
+
#
|
93
|
+
# - :wmid - WMID
|
94
|
+
# - :password - on Classic key or Light X509 certificate & key
|
95
|
+
# - :key - Base64 string for Classic key
|
96
|
+
#
|
97
|
+
# OR
|
98
|
+
# #TODO
|
99
|
+
# - :key - OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object
|
100
|
+
# - :cert - OpenSSL::X509::Certificate object
|
101
|
+
#
|
41
102
|
# Optional:
|
42
|
-
#
|
103
|
+
#
|
104
|
+
# - :ca_cert - path of a CA certification file in PEM format
|
105
|
+
|
43
106
|
def initialize(opt = {})
|
44
107
|
@wmid = Wmid.new(opt[:wmid])
|
45
108
|
|
@@ -76,7 +139,7 @@ class Webmoney
|
|
76
139
|
'incoming_invoices' => URI.parse( w3s + 'XMLInInvoices.asp'), # x10
|
77
140
|
'get_passport' => URI.parse( 'https://passport.webmoney.ru/asp/XMLGetWMPassport.asp'), # x11
|
78
141
|
'reject_protection' => URI.parse( w3s + 'XMLRejectProtect.asp'), # x13
|
79
|
-
'transaction_moneyback' => URI.parse( w3s + 'XMLTransMoneyback.asp'), #
|
142
|
+
'transaction_moneyback' => URI.parse( w3s + 'XMLTransMoneyback.asp'), # x14
|
80
143
|
'i_trust' => URI.parse( w3s + 'XMLTrustList.asp'), # x15
|
81
144
|
'trust_me' => URI.parse( w3s + 'XMLTrustList2.asp'), # x15
|
82
145
|
'trust_save' => URI.parse( w3s + 'XMLTrustSave2.asp'), # x15
|
@@ -87,21 +150,24 @@ class Webmoney
|
|
87
150
|
@ic_in = Iconv.new('UTF-8', 'CP1251')
|
88
151
|
@ic_out = Iconv.new('CP1251', 'UTF-8')
|
89
152
|
end
|
90
|
-
|
153
|
+
|
154
|
+
# Webmoney instance is classic type?
|
155
|
+
|
91
156
|
def classic?
|
92
157
|
! @signer.nil?
|
93
158
|
end
|
94
159
|
|
95
160
|
# Send message through Queue and Thread
|
96
|
-
#
|
161
|
+
#
|
162
|
+
# Params: { :wmid, :subj, :text }
|
163
|
+
|
97
164
|
def send_message(params)
|
98
165
|
@messenger = Messenger.new(self) if @messenger.nil?
|
99
166
|
@messenger.push(params)
|
100
167
|
end
|
101
168
|
|
102
|
-
#
|
103
|
-
|
104
|
-
# ================================================
|
169
|
+
# Generic function for request to WMT-interfaces
|
170
|
+
|
105
171
|
def request(iface, opt ={})
|
106
172
|
reqn = reqn()
|
107
173
|
raise ArgumentError unless opt.kind_of?(Hash)
|
@@ -150,7 +216,7 @@ class Webmoney
|
|
150
216
|
end
|
151
217
|
end
|
152
218
|
|
153
|
-
#
|
219
|
+
# Do request
|
154
220
|
res = https_request(iface, x.target!)
|
155
221
|
|
156
222
|
# Parse response
|
@@ -170,16 +236,18 @@ class Webmoney
|
|
170
236
|
return {:id => doc.at('//message')['id'], :date => time}
|
171
237
|
end
|
172
238
|
end
|
173
|
-
|
174
|
-
protected
|
175
239
|
|
176
|
-
# Signing string by instance wmid's
|
177
|
-
#
|
240
|
+
# Signing string by instance wmid's,
|
241
|
+
# return signed string
|
242
|
+
|
178
243
|
def sign(str)
|
179
|
-
@signer.sign(str) unless str.
|
244
|
+
@signer.sign(str) unless str.nil? || str.empty?
|
180
245
|
end
|
181
|
-
|
246
|
+
|
247
|
+
protected
|
248
|
+
|
182
249
|
# Make HTTPS request, return result body if 200 OK
|
250
|
+
|
183
251
|
def https_request(iface, xml)
|
184
252
|
url = case iface
|
185
253
|
when Symbol
|
@@ -209,7 +277,7 @@ class Webmoney
|
|
209
277
|
end
|
210
278
|
end
|
211
279
|
|
212
|
-
def parse_retval(response_xml)
|
280
|
+
def parse_retval(response_xml) # :nodoc:
|
213
281
|
doc = Hpricot.XML(response_xml)
|
214
282
|
retval_element = doc.at('//retval')
|
215
283
|
# Workaround for passport interface
|
@@ -227,8 +295,8 @@ class Webmoney
|
|
227
295
|
end
|
228
296
|
end
|
229
297
|
|
230
|
-
# Create unique Request Number based on time
|
231
|
-
#
|
298
|
+
# Create unique Request Number based on time,
|
299
|
+
# return 16 digits string
|
232
300
|
def reqn
|
233
301
|
t = Time.now
|
234
302
|
t.strftime('%Y%m%d%H%M%S') + t.to_f.to_s.match(/\.(\d\d)/)[1]
|
data/lib/wmid.rb
CHANGED
data/rakefile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/clean'
|
4
|
-
require 'rake/gempackagetask'
|
5
4
|
require 'tools/rakehelp'
|
6
5
|
require 'spec/rake/spectask'
|
7
6
|
|
8
|
-
GEM_VERSION="0.0.4.
|
7
|
+
GEM_VERSION="0.0.4.3"
|
9
8
|
|
10
9
|
setup_extension('wmsigner', 'wmsigner')
|
11
10
|
|
@@ -36,6 +35,7 @@ gemspec = Gem::Specification.new do |gemspec|
|
|
36
35
|
gemspec.require_path = 'lib'
|
37
36
|
gemspec.add_dependency('hpricot')
|
38
37
|
gemspec.add_dependency('builder')
|
38
|
+
gemspec.add_dependency('iconv')
|
39
39
|
|
40
40
|
if RUBY_PLATFORM.match("win32")
|
41
41
|
gemspec.platform = Gem::Platform::WIN32
|
@@ -46,18 +46,5 @@ gemspec = Gem::Specification.new do |gemspec|
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
Rake::GemPackageTask.new( gemspec ) do |task|
|
51
|
-
task.gem_spec = gemspec
|
52
|
-
task.need_tar = true
|
53
|
-
end
|
54
|
-
|
55
|
-
setup_clean ["ext/wmsigner/*.{so,o}", "ext/wmsigner/Makefile", "lib/wmsigner.so", "pkg", "*.gem"]
|
49
|
+
CLEAN.include ["ext/wmsigner/*.{so,o}", "ext/wmsigner/Makefile", "lib/wmsigner.so", "pkg", "*.gem"]
|
56
50
|
|
57
|
-
task :install => [:default, :package] do
|
58
|
-
sh %{ sudo gem install pkg/webmoney-#{GEM_VERSION}.gem }
|
59
|
-
end
|
60
|
-
|
61
|
-
task :uninstall do
|
62
|
-
sh %{ sudo gem uninstall webmoney }
|
63
|
-
end
|
data/spec/unit/passport_spec.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmoney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.
|
4
|
+
version: 0.0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Oryol
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-22 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -38,42 +38,37 @@ executables: []
|
|
38
38
|
|
39
39
|
extensions:
|
40
40
|
- ext/wmsigner/extconf.rb
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
41
|
+
extra_rdoc_files:
|
42
|
+
- ChangeLog
|
43
|
+
- README
|
43
44
|
files:
|
44
45
|
- rakefile
|
45
46
|
- ChangeLog
|
47
|
+
- README
|
46
48
|
- lib/WebMoneyCA.crt
|
47
49
|
- lib/messenger.rb
|
48
50
|
- lib/passport.rb
|
49
|
-
- lib/wmid.rb
|
50
51
|
- lib/webmoney.rb
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
- spec/unit/webmoney_spec.rb
|
57
|
-
- spec/unit/wmid_spec.rb
|
58
|
-
- ext/wmsigner/md4.h
|
52
|
+
- lib/wmid.rb
|
53
|
+
- ext/wmsigner/extconf.rb
|
54
|
+
- ext/wmsigner/base64.cpp
|
55
|
+
- ext/wmsigner/base64.h
|
56
|
+
- ext/wmsigner/cmdbase.cpp
|
59
57
|
- ext/wmsigner/cmdbase.h
|
58
|
+
- ext/wmsigner/crypto.cpp
|
60
59
|
- ext/wmsigner/crypto.h
|
61
|
-
- ext/wmsigner/
|
62
|
-
- ext/wmsigner/
|
60
|
+
- ext/wmsigner/md4.cpp
|
61
|
+
- ext/wmsigner/md4.h
|
62
|
+
- ext/wmsigner/rsalib1.cpp
|
63
63
|
- ext/wmsigner/rsalib1.h
|
64
|
+
- ext/wmsigner/signer.cpp
|
65
|
+
- ext/wmsigner/signer.h
|
66
|
+
- ext/wmsigner/stdafx.cpp
|
64
67
|
- ext/wmsigner/stdafx.h
|
65
|
-
- ext/wmsigner/base64.cpp
|
66
|
-
- ext/wmsigner/rsalib1.cpp
|
67
|
-
- ext/wmsigner/md4.cpp
|
68
68
|
- ext/wmsigner/wmsigner.cpp
|
69
|
-
- ext/wmsigner/cmdbase.cpp
|
70
|
-
- ext/wmsigner/crypto.cpp
|
71
|
-
- ext/wmsigner/stdafx.cpp
|
72
|
-
- ext/wmsigner/signer.cpp
|
73
|
-
- ext/wmsigner/extconf.rb
|
74
69
|
- tools/rakehelp.rb
|
75
|
-
has_rdoc:
|
76
|
-
homepage:
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: http://github.com/eagleas/webmoney
|
77
72
|
post_install_message:
|
78
73
|
rdoc_options: []
|
79
74
|
|
@@ -93,10 +88,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
88
|
version:
|
94
89
|
requirements: []
|
95
90
|
|
96
|
-
rubyforge_project:
|
97
|
-
rubygems_version: 1.
|
91
|
+
rubyforge_project: webmoney
|
92
|
+
rubygems_version: 1.3.1
|
98
93
|
signing_key:
|
99
94
|
specification_version: 2
|
100
95
|
summary: Webmoney interfaces and native wmsigner
|
101
|
-
test_files:
|
102
|
-
|
96
|
+
test_files:
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
- spec/unit/messenger_spec.rb
|
99
|
+
- spec/unit/passport_spec.rb
|
100
|
+
- spec/unit/signer_spec.rb
|
101
|
+
- spec/unit/time_spec.rb
|
102
|
+
- spec/unit/webmoney_spec.rb
|
103
|
+
- spec/unit/wmid_spec.rb
|