paymentrails 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/lib/paymentrails.rb +2 -3
- data/lib/paymentrails/Client.rb +4 -2
- data/lib/paymentrails/Configuration.rb +10 -1
- data/lib/paymentrails/Payment.rb +1 -0
- data/paymentrails.gemspec +2 -2
- data/spec/integration/BatchTest.rb +7 -4
- data/spec/integration/RecipientTest.rb +7 -4
- data/spec/integration/helper.rb +4 -0
- data/spec/unit/ConfigurationTest.rb +15 -0
- data/spec/unit/PaymentRailsTest.rb +8 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44ac83f800a214ab670b0f896817785b08c17a7991c1a9bd709eecefbea624f9
|
4
|
+
data.tar.gz: 8645750959fe8071d3d07e155473a4eb29ded347f44d25ea7bf12b92a71ec46b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17135435e18bda035813a88c3ad821add0a85cdf519e853e49c93ada53f24cd15a0432f5dbba439b7b25ae41bbcc621c7f032ae69ad7f9c4caaba63451d3086b
|
7
|
+
data.tar.gz: 86b59823d94e9d096d13580658b076d5548ac33ec4af4e8f6b6ca7de659c9038a5535f65b72ee0b20721a4e5ba17170af24c4dd21d7b2119a92952ceaf7e4943
|
data/lib/paymentrails.rb
CHANGED
@@ -18,8 +18,7 @@ require 'paymentrails/RecipientAccount'
|
|
18
18
|
require 'paymentrails/OfflinePayment'
|
19
19
|
|
20
20
|
module PaymentRails
|
21
|
-
def self.client(key, secret, environment = 'production')
|
22
|
-
|
23
|
-
return client
|
21
|
+
def self.client(key, secret, environment = 'production', **optionals)
|
22
|
+
Gateway.new(Configuration.new(key, secret, environment, optionals))
|
24
23
|
end
|
25
24
|
end
|
data/lib/paymentrails/Client.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require 'digest'
|
3
3
|
require 'net/http'
|
4
4
|
require 'openssl'
|
5
|
-
require 'rest-client'
|
6
5
|
require 'uri'
|
7
6
|
require 'json'
|
8
7
|
|
@@ -34,7 +33,10 @@ module PaymentRails
|
|
34
33
|
|
35
34
|
def send_request(endPoint, method, body = '')
|
36
35
|
uri = URI.parse(@config.apiBase + endPoint)
|
37
|
-
http = Net::HTTP.new(
|
36
|
+
http = Net::HTTP.new(
|
37
|
+
uri.host, uri.port,
|
38
|
+
@config.proxy&.host, @config.proxy&.port, @config.proxy&.user, @config.proxy&.password
|
39
|
+
)
|
38
40
|
http.use_ssl = @config.useSsl?
|
39
41
|
|
40
42
|
time = Time.now.to_i
|
@@ -1,12 +1,19 @@
|
|
1
1
|
module PaymentRails
|
2
2
|
class Configuration
|
3
|
+
class InvalidProxyAddress < StandardError; end
|
3
4
|
|
4
|
-
def initialize(publicKey, privateKey, environment = 'production')
|
5
|
+
def initialize(publicKey, privateKey, environment = 'production', proxy_uri: nil)
|
5
6
|
raise ArgumentError, 'Both key/secret must be a nonempty string' if publicKey.to_s&.empty? || privateKey.to_s&.empty?
|
6
7
|
|
7
8
|
@publicKey = publicKey
|
8
9
|
@privateKey = privateKey
|
9
10
|
@environment = environment
|
11
|
+
# failfast on a bad proxy
|
12
|
+
begin
|
13
|
+
@proxy = proxy_uri.nil? ? nil : URI.parse(proxy_uri)
|
14
|
+
rescue URI::InvalidURIError
|
15
|
+
raise InvalidProxyAddress, "Invalid proxy provided to configuration: #{proxy_uri}"
|
16
|
+
end
|
10
17
|
end
|
11
18
|
|
12
19
|
def apiBase
|
@@ -26,6 +33,8 @@ module PaymentRails
|
|
26
33
|
apiBase.start_with? 'https'
|
27
34
|
end
|
28
35
|
|
36
|
+
attr_reader :proxy
|
37
|
+
|
29
38
|
attr_reader :publicKey
|
30
39
|
|
31
40
|
attr_writer :publicKey
|
data/lib/paymentrails/Payment.rb
CHANGED
data/paymentrails.gemspec
CHANGED
@@ -4,14 +4,14 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.name = "paymentrails"
|
5
5
|
s.summary = "PaymentRails Ruby SDK"
|
6
6
|
s.description = "Ruby SDK for interacting with the PaymentRails API"
|
7
|
-
s.version = '0.2.
|
7
|
+
s.version = '0.2.4'
|
8
8
|
s.homepage = 'https://www.paymentrails.com/'
|
9
9
|
s.email = ['joshua@paymentrails.com']
|
10
10
|
s.license = "MIT"
|
11
11
|
s.author = "PaymentRails"
|
12
12
|
s.files = Dir.glob ["README.rdoc", "LICENSE", "lib/**/*.{rb,crt}", "spec/**/*", "*.gemspec"]
|
13
13
|
s.required_ruby_version = '>= 2.4'
|
14
|
-
s.
|
14
|
+
s.add_development_dependency 'dotenv', '~> 2'
|
15
15
|
s.add_development_dependency 'rake', '~> 12'
|
16
16
|
s.add_development_dependency "rubocop", '~> 0.77'
|
17
17
|
s.add_development_dependency 'test-unit', '~> 3'
|
@@ -1,10 +1,13 @@
|
|
1
|
-
require_relative '
|
2
|
-
require 'test/unit'
|
3
|
-
require 'securerandom'
|
1
|
+
require_relative 'helper'
|
4
2
|
|
5
3
|
class BatchTest < Test::Unit::TestCase
|
6
4
|
def setup
|
7
|
-
@client = PaymentRails
|
5
|
+
@client = PaymentRails.client(
|
6
|
+
ENV.fetch('SANDBOX_API_KEY'),
|
7
|
+
ENV.fetch('SANDBOX_SECRET_KEY'),
|
8
|
+
'production',
|
9
|
+
proxy_uri: ENV['PROXY_URI']
|
10
|
+
)
|
8
11
|
end
|
9
12
|
|
10
13
|
def create_recipient
|
@@ -1,10 +1,13 @@
|
|
1
|
-
require_relative '
|
2
|
-
require 'test/unit'
|
3
|
-
require 'securerandom'
|
1
|
+
require_relative 'helper'
|
4
2
|
|
5
3
|
class RecipientTest < Test::Unit::TestCase
|
6
4
|
def setup
|
7
|
-
@client = PaymentRails
|
5
|
+
@client = PaymentRails.client(
|
6
|
+
ENV.fetch('SANDBOX_API_KEY'),
|
7
|
+
ENV.fetch('SANDBOX_SECRET_KEY'),
|
8
|
+
'production',
|
9
|
+
proxy_uri: ENV['PROXY_URI']
|
10
|
+
)
|
8
11
|
end
|
9
12
|
|
10
13
|
def test_create
|
@@ -33,4 +33,19 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
33
33
|
assert_equal true, PaymentRails::Configuration.new('key', 'secret', 'development').useSsl?
|
34
34
|
assert_equal true, PaymentRails::Configuration.new('key', 'secret', 'non_standard_environment').useSsl?
|
35
35
|
end
|
36
|
+
|
37
|
+
def test_invalid_proxy_uri
|
38
|
+
proxy_uri = 'not_://*a_valid_proxy'
|
39
|
+
assert_raise PaymentRails::Configuration::InvalidProxyAddress.new("Invalid proxy provided to configuration: #{proxy_uri}") do
|
40
|
+
PaymentRails::Configuration.new('k', 's', 'production', proxy_uri: proxy_uri).proxy
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_vaid_proxy_uri
|
45
|
+
config = PaymentRails::Configuration.new('k', 's', 'production', proxy_uri: 'http://user:pass@gimmeproxy.com:80')
|
46
|
+
assert_equal 'gimmeproxy.com', config.proxy.host
|
47
|
+
assert_equal 80, config.proxy.port
|
48
|
+
assert_equal 'user', config.proxy.user
|
49
|
+
assert_equal 'pass', config.proxy.password
|
50
|
+
end
|
36
51
|
end
|
@@ -3,6 +3,13 @@ require 'test/unit'
|
|
3
3
|
|
4
4
|
class PaymentRailsTest < Test::Unit::TestCase
|
5
5
|
def test_client
|
6
|
-
PaymentRails.client('key', 'secret', 'environment')
|
6
|
+
PaymentRails.client('key', 'secret', 'environment', proxy_uri: 'http://user:pass@gimmeproxy.com:80')
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_client_invalid_proxy_uri
|
10
|
+
proxy_uri = 'not_://*a_valid_proxy'
|
11
|
+
assert_raise PaymentRails::Configuration::InvalidProxyAddress.new("Invalid proxy provided to configuration: #{proxy_uri}") do
|
12
|
+
PaymentRails.client('k', 's', 'production', proxy_uri: proxy_uri)
|
13
|
+
end
|
7
14
|
end
|
8
15
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paymentrails
|
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
|
- PaymentRails
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dotenv
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2
|
20
|
-
type: :
|
19
|
+
version: '2'
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- paymentrails.gemspec
|
96
96
|
- spec/integration/BatchTest.rb
|
97
97
|
- spec/integration/RecipientTest.rb
|
98
|
+
- spec/integration/helper.rb
|
98
99
|
- spec/unit/ConfigurationTest.rb
|
99
100
|
- spec/unit/PaymentRailsTest.rb
|
100
101
|
homepage: https://www.paymentrails.com/
|