spreedly 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +5 -1
- data/lib/spreedly.rb +2 -0
- data/lib/spreedly/auth_mode.rb +16 -0
- data/lib/spreedly/credential.rb +12 -0
- data/lib/spreedly/environment.rb +2 -2
- data/lib/spreedly/gateway_class.rb +10 -2
- data/lib/spreedly/version.rb +1 -1
- data/test/remote/remote_gateway_options_test.rb +4 -1
- data/test/unit/gateway_options_test.rb +24 -0
- metadata +6 -4
data/HISTORY.md
CHANGED
data/lib/spreedly.rb
CHANGED
@@ -5,6 +5,8 @@ require 'spreedly/connection'
|
|
5
5
|
require 'spreedly/common/fields'
|
6
6
|
require 'spreedly/common/errors_parser'
|
7
7
|
require 'spreedly/model'
|
8
|
+
require 'spreedly/auth_mode'
|
9
|
+
require 'spreedly/credential'
|
8
10
|
require 'spreedly/payment_methods/payment_method'
|
9
11
|
require 'spreedly/payment_methods/credit_card'
|
10
12
|
require 'spreedly/payment_methods/paypal'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Spreedly
|
2
|
+
class AuthMode
|
3
|
+
include Fields
|
4
|
+
|
5
|
+
field :auth_mode_type, :name
|
6
|
+
attr_reader :auth_mode_type, :credentials
|
7
|
+
|
8
|
+
def initialize(xml_doc)
|
9
|
+
initialize_fields(xml_doc)
|
10
|
+
|
11
|
+
@credentials = xml_doc.xpath('.//credentials/credential').map do |each|
|
12
|
+
Spreedly::Credential.new(each)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/spreedly/environment.rb
CHANGED
@@ -174,8 +174,8 @@ module Spreedly
|
|
174
174
|
build_xml_request('payment_method') do |doc|
|
175
175
|
add_to_doc(doc, options, :data, :retained, :email)
|
176
176
|
doc.credit_card do
|
177
|
-
add_to_doc(doc, options, :number, :month, :first_name, :last_name,
|
178
|
-
:address1, :address2, :city, :state, :zip, :country, :phone_number)
|
177
|
+
add_to_doc(doc, options, :number, :verification_value, :month, :first_name, :last_name,
|
178
|
+
:year, :address1, :address2, :city, :state, :zip, :country, :phone_number)
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module Spreedly
|
2
2
|
|
3
3
|
class GatewayClass
|
4
|
-
|
5
4
|
include Fields
|
5
|
+
|
6
6
|
field :gateway_type, :name, :supported_countries, :homepage
|
7
|
-
attr_reader :supported_countries, :payment_methods
|
7
|
+
attr_reader :supported_countries, :payment_methods, :auth_modes
|
8
8
|
|
9
9
|
def initialize(xml_doc)
|
10
10
|
initialize_fields(xml_doc)
|
11
11
|
init_supported_countries(xml_doc)
|
12
12
|
init_payment_methods(xml_doc)
|
13
|
+
init_auth_modes(xml_doc)
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.new_list_from(xml_doc)
|
@@ -20,6 +21,7 @@ module Spreedly
|
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
24
|
+
|
23
25
|
def init_supported_countries(xml_doc)
|
24
26
|
list = xml_doc.at_xpath(".//supported_countries").inner_html.strip
|
25
27
|
@supported_countries = list.split(/\s*,\s*/)
|
@@ -31,6 +33,12 @@ module Spreedly
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
36
|
+
def init_auth_modes(xml_doc)
|
37
|
+
@auth_modes = xml_doc.xpath(".//auth_modes/auth_mode").map do |each|
|
38
|
+
Spreedly::AuthMode.new(each)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
34
42
|
end
|
35
43
|
|
36
44
|
end
|
data/lib/spreedly/version.rb
CHANGED
@@ -10,7 +10,10 @@ class RemoteGatewayOptionsTest < Test::Unit::TestCase
|
|
10
10
|
gateway_classes = @environment.gateway_options
|
11
11
|
braintree = gateway_classes.select { |each| each.name == "Braintree" }.first
|
12
12
|
assert_equal "http://www.braintreepaymentsolutions.com/", braintree.homepage
|
13
|
-
assert_equal
|
13
|
+
assert_equal %w(credit_card third_party_token), braintree.payment_methods
|
14
|
+
assert_equal %w(orange blue), braintree.auth_modes.map { |e| e.auth_mode_type }
|
15
|
+
assert_equal %w(login password), braintree.auth_modes.first.credentials.map { |e| e.name }
|
16
|
+
assert_equal [ true, false ], braintree.auth_modes.first.credentials.map { |e| e.safe }
|
14
17
|
end
|
15
18
|
|
16
19
|
end
|
@@ -25,4 +25,28 @@ class ListGatewaysTest < Test::Unit::TestCase
|
|
25
25
|
assert_kind_of Spreedly::GatewayClass, list.last
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_successful_gateway_auth_modes
|
29
|
+
@environment.stubs(:raw_ssl_request).returns(successful_gateway_options_response)
|
30
|
+
list = @environment.gateway_options.first.auth_modes
|
31
|
+
|
32
|
+
assert_kind_of Array, list
|
33
|
+
assert_equal 3, list.size
|
34
|
+
|
35
|
+
assert_equal "signature", list.first.auth_mode_type
|
36
|
+
assert_equal "Signature", list.first.name
|
37
|
+
assert_kind_of Array, list.first.credentials
|
38
|
+
assert_equal 3, list.first.credentials.size
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_successful_gateway_auth_mode_credentials
|
42
|
+
@environment.stubs(:raw_ssl_request).returns(successful_gateway_options_response)
|
43
|
+
list = @environment.gateway_options.first.auth_modes.first.credentials
|
44
|
+
|
45
|
+
assert_kind_of Array, list
|
46
|
+
assert_equal 3, list.size
|
47
|
+
|
48
|
+
assert_equal "login", list.first.name
|
49
|
+
assert_equal "Login", list.first.label
|
50
|
+
assert_equal true, list.first.safe
|
51
|
+
end
|
28
52
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: spreedly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.0.
|
5
|
+
version: 2.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Spreedly
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -123,9 +123,11 @@ files:
|
|
123
123
|
- Rakefile
|
124
124
|
- lib/certs/cacert.pem
|
125
125
|
- lib/spreedly.rb
|
126
|
+
- lib/spreedly/auth_mode.rb
|
126
127
|
- lib/spreedly/common/errors_parser.rb
|
127
128
|
- lib/spreedly/common/fields.rb
|
128
129
|
- lib/spreedly/connection.rb
|
130
|
+
- lib/spreedly/credential.rb
|
129
131
|
- lib/spreedly/environment.rb
|
130
132
|
- lib/spreedly/error.rb
|
131
133
|
- lib/spreedly/gateway.rb
|
@@ -231,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
233
|
- !ruby/object:Gem::Version
|
232
234
|
segments:
|
233
235
|
- 0
|
234
|
-
hash:
|
236
|
+
hash: -2834738228651493214
|
235
237
|
version: '0'
|
236
238
|
none: false
|
237
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -240,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
242
|
- !ruby/object:Gem::Version
|
241
243
|
segments:
|
242
244
|
- 0
|
243
|
-
hash:
|
245
|
+
hash: -2834738228651493214
|
244
246
|
version: '0'
|
245
247
|
none: false
|
246
248
|
requirements: []
|