vsafe-ruby 0.2.3 → 0.2.4
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.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/lib/vsafe/client.rb +6 -9
- data/lib/vsafe/config.rb +15 -9
- data/lib/vsafe/version.rb +1 -1
- data/spec/vsafe/client_spec.rb +20 -31
- data/spec/vsafe/config_spec.rb +43 -6
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bb461c8893fc84ffecfe88bfcb4e8214e1fb6b8
|
4
|
+
data.tar.gz: f69e5b442e90cc57110050243a5fb95f18e993d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 910cf1504160cbcad1ed41e2ad3b6ddd5f6046b118647eb07e506492eff34f11978d5ed66232ed9a866a96990198ca916b11643bcee1ed2eaed49377bb0f3412
|
7
|
+
data.tar.gz: 582cbed640f692d515ce09841d005881a87a467473cb11616dcd5e887fb57ddecefb011d19ac3ede373a8c421d8c90e29a857a4706889395b6349f5c8351c6b1
|
data/README.md
CHANGED
@@ -38,6 +38,29 @@ client = VSafe::Client.new do |config|
|
|
38
38
|
end
|
39
39
|
```
|
40
40
|
|
41
|
+
### Vesta URLs
|
42
|
+
|
43
|
+
All four Vesta URLs can be specified in config:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
VSafe.configure do |config|
|
47
|
+
config.sandbox_url = 'https://my.sandbox.url/GatewayV4Proxy/Service'
|
48
|
+
config.sandbox_jsonp_url = 'https://my.sandboxtoken.url/GatewayV4ProxyJSON/Service'
|
49
|
+
config.production_url = 'https://my.production.url/GatewayV4Proxy/Service'
|
50
|
+
config.production_jsonp_url = 'https://my.production.url/GatewayV4ProxyJSON/Service'
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
### Logging
|
55
|
+
|
56
|
+
The logger passed to HTTParty can be specified in config:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
VSafe.configure do |config|
|
60
|
+
config.logger = Rails.logger
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
41
64
|
## Request & Response
|
42
65
|
|
43
66
|
First, Setup a client for making request:
|
data/lib/vsafe/client.rb
CHANGED
@@ -59,17 +59,13 @@ module VSafe
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def service_url(endpoint = nil, jsonp = false)
|
62
|
-
|
63
|
-
|
64
|
-
jsonp ? config.jsonp_service_path : config.service_path
|
65
|
-
]
|
66
|
-
parts << endpoint if endpoint
|
67
|
-
|
68
|
-
File.join(parts)
|
62
|
+
base_uri = jsonp ? config.jsonp_url : config.url
|
63
|
+
endpoint.nil? ? base_uri : File.join(base_uri, endpoint)
|
69
64
|
end
|
70
65
|
|
71
66
|
def fingerprint_url
|
72
|
-
|
67
|
+
base_uri = URI.join(config.jsonp_url, '/')
|
68
|
+
@_fingerprint_url ||= URI.join(base_uri, config.sandbox ? SANDBOX_FINGERPRINT_PATH : FINGERPRINT_PATH).to_s
|
73
69
|
end
|
74
70
|
|
75
71
|
private
|
@@ -83,7 +79,8 @@ module VSafe
|
|
83
79
|
).to_json,
|
84
80
|
headers: {
|
85
81
|
"Content-Type" => REQUEST_CONTENT_TYPE
|
86
|
-
}
|
82
|
+
},
|
83
|
+
logger: @config.logger
|
87
84
|
}
|
88
85
|
|
89
86
|
# The HTTPS endpoint for VSafe Sandbox has an outdated SSL version.
|
data/lib/vsafe/config.rb
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
module VSafe
|
2
2
|
class Config
|
3
3
|
DEFAULT_REQUEST_TIMEOUT = 20 # seconds
|
4
|
-
DEFAULT_SANDBOX_URL = "https://paysafesandbox.ecustomersupport.com".freeze
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
DEFAULT_SANDBOX_URL = "https://paysafesandbox.ecustomersupport.com/GatewayProxy/Service".freeze
|
5
|
+
DEFAULT_SANDBOX_JSONP_URL = "https://paysafesandbox.ecustomersupport.com/GatewayProxyJSON/Service".freeze
|
6
|
+
|
7
|
+
DEFAULT_PRODUCTION_URL = "https://paysafe.ecustomerpayments.com/GatewayProxy/Service".freeze
|
8
|
+
DEFAULT_PRODUCTION_JSONP_URL = "https://paysafe.ecustomerpayments.com/GatewayProxyJSON/Service".freeze
|
8
9
|
|
9
10
|
attr_accessor :sandbox_url,
|
10
11
|
:production_url,
|
12
|
+
:sandbox_jsonp_url,
|
13
|
+
:production_jsonp_url,
|
11
14
|
:sandbox,
|
12
15
|
:account_name,
|
13
16
|
:password,
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:request_timeout
|
17
|
+
:request_timeout,
|
18
|
+
:logger
|
17
19
|
|
18
20
|
def initialize
|
19
21
|
# Set sandbox to true by default
|
20
22
|
@sandbox = true
|
21
|
-
@service_path = DEFAULT_SERVICE_PATH
|
22
|
-
@jsonp_service_path = DEFAULT_JSONP_SERVICE_PATH
|
23
23
|
@request_timeout = DEFAULT_REQUEST_TIMEOUT
|
24
24
|
@sandbox_url = DEFAULT_SANDBOX_URL
|
25
25
|
@production_url = DEFAULT_PRODUCTION_URL
|
26
|
+
@sandbox_jsonp_url = DEFAULT_SANDBOX_JSONP_URL
|
27
|
+
@production_jsonp_url = DEFAULT_PRODUCTION_JSONP_URL
|
26
28
|
end
|
27
29
|
|
28
30
|
def url
|
29
31
|
sandbox ? @sandbox_url : @production_url
|
30
32
|
end
|
33
|
+
|
34
|
+
def jsonp_url
|
35
|
+
sandbox ? @sandbox_jsonp_url : @production_jsonp_url
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
data/lib/vsafe/version.rb
CHANGED
data/spec/vsafe/client_spec.rb
CHANGED
@@ -136,7 +136,7 @@ RSpec.describe VSafe::Client do
|
|
136
136
|
let(:endpoint) { "foo" }
|
137
137
|
|
138
138
|
it "returns endpoint url" do
|
139
|
-
expect(client.service_url(endpoint, jsonp)).to eq("#{
|
139
|
+
expect(client.service_url(endpoint, jsonp)).to eq("#{base_uri}/#{endpoint}")
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
@@ -144,42 +144,24 @@ RSpec.describe VSafe::Client do
|
|
144
144
|
let(:endpoint) { nil }
|
145
145
|
|
146
146
|
it "returns base url" do
|
147
|
-
expect(client.service_url(endpoint, jsonp)).to eq(
|
147
|
+
expect(client.service_url(endpoint, jsonp)).to eq(base_uri)
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
152
|
context "when jsonp is false" do
|
153
|
-
let(:
|
154
|
-
|
153
|
+
let(:base_uri) { 'https://base.url/GatewayProxy/Service'}
|
154
|
+
before do
|
155
|
+
expect(client.config).to receive(:url).and_return(base_uri)
|
156
|
+
end
|
155
157
|
it_behaves_like "returns url"
|
156
158
|
end
|
157
159
|
|
158
160
|
context "when jsonp is true" do
|
159
|
-
let(:
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
context "when custom service_path is set" do
|
165
|
-
let(:service_path) { "__custom_service" }
|
166
|
-
let(:client) {
|
167
|
-
VSafe::Client.new do |config|
|
168
|
-
config.service_path = "__custom_service"
|
169
|
-
end
|
170
|
-
}
|
171
|
-
|
172
|
-
it_behaves_like "returns url"
|
173
|
-
end
|
174
|
-
|
175
|
-
context "when custom jsonp_service_path is set" do
|
176
|
-
let(:service_path) { "__custom_jsonp" }
|
177
|
-
let(:client) {
|
178
|
-
VSafe::Client.new do |config|
|
179
|
-
config.jsonp_service_path = "__custom_jsonp"
|
180
|
-
end
|
181
|
-
}
|
182
|
-
|
161
|
+
let(:base_uri) { 'https://base.url/GatewayProxyJSON/Service'}
|
162
|
+
before do
|
163
|
+
expect(client.config).to receive(:jsonp_url).and_return(base_uri)
|
164
|
+
end
|
183
165
|
it_behaves_like "returns url", true
|
184
166
|
end
|
185
167
|
end
|
@@ -190,8 +172,14 @@ RSpec.describe VSafe::Client do
|
|
190
172
|
allow(client.config).to receive(:sandbox).and_return(true)
|
191
173
|
end
|
192
174
|
|
193
|
-
it "
|
194
|
-
|
175
|
+
it "use url when jsonp url is not set" do
|
176
|
+
client.config.sandbox_jsonp_url = 'https://sandbox.url/GatewayProxy/Service'
|
177
|
+
expect(client.fingerprint_url).to eq("https://sandbox.url/#{VSafe::Client::SANDBOX_FINGERPRINT_PATH}")
|
178
|
+
end
|
179
|
+
|
180
|
+
it "uses the jsonp_url when set" do
|
181
|
+
client.config.sandbox_jsonp_url = 'https://google.com/'
|
182
|
+
expect(client.fingerprint_url).to eq("https://google.com/#{VSafe::Client::SANDBOX_FINGERPRINT_PATH}")
|
195
183
|
end
|
196
184
|
end
|
197
185
|
|
@@ -201,7 +189,8 @@ RSpec.describe VSafe::Client do
|
|
201
189
|
end
|
202
190
|
|
203
191
|
it "returns url" do
|
204
|
-
|
192
|
+
allow(client.config).to receive(:jsonp_url).and_return('https://google.com/')
|
193
|
+
expect(client.fingerprint_url).to eq("https://google.com/#{VSafe::Client::FINGERPRINT_PATH}")
|
205
194
|
end
|
206
195
|
end
|
207
196
|
end
|
data/spec/vsafe/config_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require "vsafe/config"
|
|
3
3
|
|
4
4
|
RSpec.describe VSafe::Config do
|
5
5
|
let (:config) { VSafe::Config.new }
|
6
|
-
|
6
|
+
|
7
7
|
describe ".new" do
|
8
8
|
it "sets default configs" do
|
9
9
|
expect(config.sandbox).to eq(true)
|
@@ -11,32 +11,69 @@ RSpec.describe VSafe::Config do
|
|
11
11
|
expect(config.url).not_to be_empty
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
describe "#url" do
|
16
16
|
context "sandbox is true" do
|
17
17
|
it "uses default sandbox_url" do
|
18
18
|
expect(config.url).to eq(VSafe::Config::DEFAULT_SANDBOX_URL)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it "uses custom sandbox_url when sandbox" do
|
22
22
|
config.sandbox_url = "https://www.google.com"
|
23
23
|
expect(config.url).to eq("https://www.google.com")
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
context "sandbox is not true" do
|
28
28
|
before do
|
29
29
|
config.sandbox = false
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "uses default production_url when not sandbox" do
|
33
33
|
expect(config.url).to eq(VSafe::Config::DEFAULT_PRODUCTION_URL)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "uses custom production_url when not sandbox" do
|
37
37
|
config.production_url = "https://www.google.com"
|
38
38
|
expect(config.url).to eq("https://www.google.com")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
describe "#jsonp_url" do
|
44
|
+
context "sandbox is true" do
|
45
|
+
it "uses default sandbox_url" do
|
46
|
+
expect(config.jsonp_url).to eq(VSafe::Config::DEFAULT_SANDBOX_JSONP_URL)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "uses custom sandbox_jsonp_url when set" do
|
50
|
+
config.sandbox_jsonp_url = "https://www.googlesandbox.com"
|
51
|
+
expect(config.jsonp_url).to eq("https://www.googlesandbox.com")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "sandbox is not true" do
|
56
|
+
before do
|
57
|
+
config.sandbox = false
|
58
|
+
end
|
59
|
+
|
60
|
+
it "uses custom production_url when not sandbox" do
|
61
|
+
config.production_jsonp_url = "https://www.googlesandbox.com"
|
62
|
+
expect(config.jsonp_url).to eq("https://www.googlesandbox.com")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#jsonp_url" do
|
68
|
+
context "sandbox is true" do
|
69
|
+
it "uses default sandbox_url" do
|
70
|
+
expect(config.jsonp_url).to eq(VSafe::Config::DEFAULT_SANDBOX_JSONP_URL)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "uses custom sandbox_jsonp_url when set" do
|
74
|
+
config.sandbox_jsonp_url = "https://www.googlesandbox.com"
|
75
|
+
expect(config.jsonp_url).to eq("https://www.googlesandbox.com")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
42
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vsafe-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xiaoming Lu
|
@@ -10,90 +10,90 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0.13'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0.13'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: bundler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '1.9'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1.9'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rake
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '10.0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ~>
|
54
|
+
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '10.0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rspec
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - ~>
|
61
|
+
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '3.4'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- - ~>
|
68
|
+
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '3.4'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: webmock
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - ~>
|
75
|
+
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '1.24'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - ~>
|
82
|
+
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '1.24'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: byebug
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
description: Ruby API Library for Vesta's vSafe Payment Gateway.
|
@@ -157,12 +157,12 @@ require_paths:
|
|
157
157
|
- lib
|
158
158
|
required_ruby_version: !ruby/object:Gem::Requirement
|
159
159
|
requirements:
|
160
|
-
- -
|
160
|
+
- - ">="
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
|
-
- -
|
165
|
+
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|