payson_api 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -2
- data/lib/payson_api.rb +10 -2
- data/lib/payson_api/client.rb +12 -8
- data/lib/payson_api/config.rb +7 -8
- data/lib/payson_api/version.rb +1 -1
- data/payson_api.gemspec +2 -3
- metadata +50 -40
- data/lib/payson_api/errors/config_error.rb +0 -13
data/Gemfile
CHANGED
data/lib/payson_api.rb
CHANGED
@@ -1,2 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'payson_api/config'
|
2
|
+
require 'payson_api/client'
|
3
|
+
require 'payson_api/errors/payson_api_error'
|
4
|
+
require 'payson_api/errors/remote_error'
|
5
|
+
require 'payson_api/order_item'
|
6
|
+
require 'payson_api/pay_data'
|
7
|
+
require 'payson_api/receiver'
|
8
|
+
require 'payson_api/response'
|
9
|
+
require 'payson_api/sender'
|
10
|
+
require 'payson_api/version'
|
data/lib/payson_api/client.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
-
require '
|
1
|
+
require 'httpclient'
|
2
2
|
|
3
3
|
module PaysonAPI
|
4
4
|
class Client
|
5
5
|
def self.pay(pay_data)
|
6
6
|
action = '/%s/%s/' % [PAYSON_API_VERSION, PAYSON_API_PAY_ACTION]
|
7
|
+
response = post(PAYSON_API_ENDPOINT + action, pay_data.to_hash)
|
8
|
+
Response.new(response.body)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def self.post(url, data)
|
7
14
|
headers = {
|
8
|
-
|
9
|
-
|
15
|
+
'PAYSON-SECURITY-USERID' => PaysonAPI.config.api_user_id,
|
16
|
+
'PAYSON-SECURITY-PASSWORD' => PaysonAPI.config.api_password,
|
17
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
10
18
|
}
|
11
|
-
|
12
|
-
pay_data.to_hash,
|
13
|
-
headers
|
14
|
-
)
|
15
|
-
Response.new(response)
|
19
|
+
HTTPClient.post(url, :body => data, :header => headers)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
data/lib/payson_api/config.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module PaysonAPI
|
2
|
-
|
3
|
-
# Some hard constants
|
2
|
+
extend self
|
4
3
|
|
5
4
|
PAYSON_WWW_HOST = "https://www.payson.se"
|
6
5
|
PAYSON_WWW_PAY_FORWARD_URL = "/paysecure/?token=%s"
|
@@ -19,21 +18,21 @@ module PaysonAPI
|
|
19
18
|
# PaysonAPI.configure do |config|
|
20
19
|
# config.api_user = 12345
|
21
20
|
# end
|
22
|
-
def
|
23
|
-
yield @config ||=
|
21
|
+
def configure(&block)
|
22
|
+
yield @config ||= Configuration.new
|
24
23
|
end
|
25
24
|
|
26
|
-
def
|
25
|
+
def config
|
27
26
|
@config
|
28
27
|
end
|
29
28
|
|
30
29
|
class Configuration
|
31
|
-
attr_accessor :
|
30
|
+
attr_accessor :api_user_id, :api_password
|
32
31
|
end
|
33
32
|
|
34
33
|
configure do |config|
|
35
|
-
config.
|
36
|
-
config.
|
34
|
+
config.api_user_id = 'XXXX'
|
35
|
+
config.api_password = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
|
37
36
|
end
|
38
37
|
|
39
38
|
end
|
data/lib/payson_api/version.rb
CHANGED
data/payson_api.gemspec
CHANGED
@@ -17,10 +17,9 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
s.add_dependency '
|
21
|
-
s.add_dependency 'rest-client'
|
20
|
+
s.add_dependency 'httpclient'
|
22
21
|
|
23
22
|
# specify any dependencies here; for example:
|
24
23
|
# s.add_development_dependency "rspec"
|
25
|
-
# s.add_runtime_dependency "
|
24
|
+
# s.add_runtime_dependency "httpclient"
|
26
25
|
end
|
metadata
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: payson_api
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Christopher Svensson
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
17
|
+
|
18
|
+
date: 2012-07-25 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: httpclient
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rest-client
|
27
|
-
requirement: &70104901657500 !ruby/object:Gem::Requirement
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
28
24
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
33
32
|
type: :runtime
|
34
|
-
|
35
|
-
version_requirements: *70104901657500
|
33
|
+
version_requirements: *id001
|
36
34
|
description: Client that enables access to the Payson payment gateway API.
|
37
|
-
email:
|
35
|
+
email:
|
38
36
|
- stoffus@stoffus.com
|
39
37
|
executables: []
|
38
|
+
|
40
39
|
extensions: []
|
40
|
+
|
41
41
|
extra_rdoc_files: []
|
42
|
-
|
42
|
+
|
43
|
+
files:
|
43
44
|
- .gitignore
|
44
45
|
- Gemfile
|
45
46
|
- README.rdoc
|
46
47
|
- lib/payson_api.rb
|
47
48
|
- lib/payson_api/client.rb
|
48
49
|
- lib/payson_api/config.rb
|
49
|
-
- lib/payson_api/errors/config_error.rb
|
50
50
|
- lib/payson_api/errors/payson_api_error.rb
|
51
51
|
- lib/payson_api/errors/remote_error.rb
|
52
52
|
- lib/payson_api/order_item.rb
|
@@ -58,26 +58,36 @@ files:
|
|
58
58
|
- payson_api.gemspec
|
59
59
|
homepage: https://github.com/stoffus/payson_api
|
60
60
|
licenses: []
|
61
|
+
|
61
62
|
post_install_message:
|
62
63
|
rdoc_options: []
|
63
|
-
|
64
|
+
|
65
|
+
require_paths:
|
64
66
|
- lib
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
68
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
77
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
77
85
|
requirements: []
|
86
|
+
|
78
87
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.8.
|
88
|
+
rubygems_version: 1.8.15
|
80
89
|
signing_key:
|
81
90
|
specification_version: 3
|
82
91
|
summary: Client for Payson API
|
83
92
|
test_files: []
|
93
|
+
|