spreedly 2.0.0 → 2.0.1
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.
- data/HISTORY.md +11 -0
- data/README.md +2 -2
- data/lib/spreedly/common/fields.rb +0 -1
- data/lib/spreedly/connection.rb +2 -2
- data/lib/spreedly/environment.rb +34 -5
- data/lib/spreedly/gateway.rb +22 -0
- data/lib/spreedly/payment_methods/bank_account.rb +9 -0
- data/lib/spreedly/payment_methods/payment_method.rb +9 -0
- data/lib/spreedly/transactions/redact_gateway.rb +14 -0
- data/lib/spreedly/transactions/transaction.rb +2 -0
- data/lib/spreedly/urls.rb +22 -2
- data/lib/spreedly/version.rb +1 -1
- data/lib/spreedly.rb +2 -0
- data/test/remote/remote_add_gateway_test.rb +7 -1
- data/test/remote/remote_find_gateway_test.rb +4 -3
- data/test/remote/remote_list_gateways_test.rb +35 -0
- data/test/remote/remote_list_payment_methods_test.rb +34 -0
- data/test/remote/remote_list_transactions_test.rb +29 -1
- data/test/remote/remote_redact_gateway_test.rb +30 -0
- data/test/remote/{remote_redact_test.rb → remote_redact_payment_method_test.rb} +1 -1
- data/test/remote/remote_update_credit_card_test.rb +54 -0
- data/test/unit/add_gateway_test.rb +17 -7
- data/test/unit/find_gateway_test.rb +5 -4
- data/test/unit/find_payment_method_test.rb +23 -0
- data/test/unit/list_gateways_test.rb +47 -0
- data/test/unit/list_payment_methods_test.rb +47 -0
- data/test/unit/list_transactions_test.rb +17 -5
- data/test/unit/redact_gateway_test.rb +42 -0
- data/test/unit/redact_payment_method_test.rb +3 -3
- data/test/unit/response_stubs/find_gateway_stubs.rb +30 -20
- data/test/unit/response_stubs/find_payment_method_stubs.rb +26 -0
- data/test/unit/response_stubs/list_gateways_stubs.rb +75 -0
- data/test/unit/response_stubs/list_payment_methods_stubs.rb +63 -0
- data/test/unit/response_stubs/redact_gateway_stubs.rb +47 -0
- data/test/unit/response_stubs/redact_payment_method_stubs.rb +1 -6
- data/test/unit/response_stubs/update_credit_card_stubs.rb +34 -0
- data/test/unit/update_credit_card_test.rb +59 -0
- metadata +32 -6
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'unit/response_stubs/list_payment_methods_stubs'
|
3
|
+
|
4
|
+
class ListPaymentMethodsTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
include ListPaymentMethodsStubs
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@environment = Spreedly::Environment.new("key", "secret")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_successful_list_payment_methods
|
13
|
+
list = list_using(successful_list_payment_methods_response)
|
14
|
+
|
15
|
+
assert_kind_of(Array, list)
|
16
|
+
assert_equal 2, list.size
|
17
|
+
|
18
|
+
assert_equal 'Perrin Aybara', list.first.full_name
|
19
|
+
assert_equal 'Mat Cauthon', list.last.full_name
|
20
|
+
assert_kind_of Spreedly::CreditCard, list.first
|
21
|
+
assert_kind_of Spreedly::CreditCard, list.last
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_request_url
|
25
|
+
assert_request_url 'https://core.spreedly.com/v1/payment_methods.xml' do
|
26
|
+
@environment.list_payment_methods
|
27
|
+
end
|
28
|
+
|
29
|
+
assert_request_url 'https://core.spreedly.com/v1/payment_methods.xml?since_token=SomeToken' do
|
30
|
+
@environment.list_payment_methods("SomeToken")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def list_using(response)
|
36
|
+
@environment.stubs(:raw_ssl_request).returns(response)
|
37
|
+
@environment.list_payment_methods
|
38
|
+
end
|
39
|
+
|
40
|
+
def assert_request_url(expected_url)
|
41
|
+
actual_url = get_request_url(successful_list_payment_methods_response) do
|
42
|
+
yield
|
43
|
+
end
|
44
|
+
assert_equal expected_url, actual_url
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'unit/response_stubs/list_transactions_stubs'
|
3
3
|
|
4
|
-
class
|
4
|
+
class ListTransactionsTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
include ListTransactionsStubs
|
7
7
|
|
@@ -25,15 +25,21 @@ class FindPaymentMethodTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_request_url
|
28
|
-
|
28
|
+
assert_request_url 'https://core.spreedly.com/v1/transactions.xml' do
|
29
29
|
@environment.list_transactions
|
30
30
|
end
|
31
|
-
assert_equal 'https://core.spreedly.com/v1/transactions.xml', url
|
32
31
|
|
33
|
-
|
32
|
+
assert_request_url 'https://core.spreedly.com/v1/transactions.xml?since_token=SomeToken' do
|
34
33
|
@environment.list_transactions("SomeToken")
|
35
34
|
end
|
36
|
-
|
35
|
+
|
36
|
+
assert_request_url 'https://core.spreedly.com/v1/payment_methods/SomePaymentMethodToken/transactions.xml' do
|
37
|
+
@environment.list_transactions(nil, 'SomePaymentMethodToken')
|
38
|
+
end
|
39
|
+
|
40
|
+
assert_request_url 'https://core.spreedly.com/v1/payment_methods/SomePaymentMethodToken/transactions.xml?since_token=SinceToken' do
|
41
|
+
@environment.list_transactions('SinceToken', 'SomePaymentMethodToken')
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
private
|
@@ -42,5 +48,11 @@ class FindPaymentMethodTest < Test::Unit::TestCase
|
|
42
48
|
@environment.list_transactions
|
43
49
|
end
|
44
50
|
|
51
|
+
def assert_request_url(expected_url)
|
52
|
+
actual_url = get_request_url(successful_list_transactions_response) do
|
53
|
+
yield
|
54
|
+
end
|
55
|
+
assert_equal expected_url, actual_url
|
56
|
+
end
|
45
57
|
|
46
58
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'unit/response_stubs/redact_gateway_stubs'
|
3
|
+
|
4
|
+
class RedactGatewayTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
include RedactGatewayStubs
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@environment = Spreedly::Environment.new("key", "secret")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_successful_redact
|
13
|
+
t = redact_using(successful_redact_gateway_response)
|
14
|
+
|
15
|
+
assert_kind_of(Spreedly::RedactGateway, t)
|
16
|
+
assert_equal 'NXKt1iNkIJhzF5QCDt1qSsuFbcN', t.token
|
17
|
+
assert_equal Time.parse('2013-08-19 17:16:07 UTC'), t.created_at
|
18
|
+
assert_equal Time.parse('2013-08-19 17:16:07 UTC'), t.updated_at
|
19
|
+
assert t.succeeded?
|
20
|
+
assert_equal 'Succeeded!', t.message
|
21
|
+
assert_equal '8zy49qcEUigjYbpPKCjlhDzUqJ', t.gateway.token
|
22
|
+
assert_equal 'Spreedly Test', t.gateway.name
|
23
|
+
assert_equal 'redacted', t.gateway.state
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_empty_request_body_params
|
27
|
+
body = get_request_body(successful_redact_gateway_response) do
|
28
|
+
@environment.redact_gateway("TransactionToken")
|
29
|
+
end
|
30
|
+
|
31
|
+
assert_nil body.root
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
private
|
36
|
+
def redact_using(response)
|
37
|
+
@environment.stubs(:raw_ssl_request).returns(response)
|
38
|
+
@environment.redact_gateway("IgnoredTokenSinceResponseIsStubbed")
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -10,7 +10,7 @@ class RedactPaymentMethodTest < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_successful_redact
|
13
|
-
t = redact_using(
|
13
|
+
t = redact_using(successful_redact_payment_method_response)
|
14
14
|
|
15
15
|
assert_kind_of(Spreedly::RedactPaymentMethod, t)
|
16
16
|
assert_equal '2BSe5T6FHpypph3ensF7m3Nb3qk', t.token
|
@@ -24,7 +24,7 @@ class RedactPaymentMethodTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_empty_request_body_params
|
27
|
-
body = get_request_body(
|
27
|
+
body = get_request_body(successful_redact_payment_method_response) do
|
28
28
|
@environment.redact_payment_method("TransactionToken")
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ class RedactPaymentMethodTest < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_request_body_params
|
35
|
-
body = get_request_body(
|
35
|
+
body = get_request_body(successful_redact_payment_method_response) do
|
36
36
|
@environment.redact_payment_method("TransactionToken", remove_from_gateway: 'ThePassedGatewayToken')
|
37
37
|
end
|
38
38
|
|
@@ -3,36 +3,46 @@ module FindGatewayStubs
|
|
3
3
|
def successful_get_gateway_response
|
4
4
|
StubResponse.succeeded <<-XML
|
5
5
|
<gateway>
|
6
|
-
<token>
|
7
|
-
<gateway_type>
|
8
|
-
<name>
|
6
|
+
<token>5YqAdCL5AaxdbDdo1yZCkB4r74p</token>
|
7
|
+
<gateway_type>wirecard</gateway_type>
|
8
|
+
<name>Wirecard</name>
|
9
|
+
<username>username</username>
|
10
|
+
<business_case_signature>signature</business_case_signature>
|
9
11
|
<characteristics>
|
10
12
|
<supports_purchase type="boolean">true</supports_purchase>
|
11
13
|
<supports_authorize type="boolean">true</supports_authorize>
|
12
14
|
<supports_capture type="boolean">true</supports_capture>
|
13
|
-
<supports_credit type="boolean">
|
14
|
-
<supports_void type="boolean">
|
15
|
-
<supports_reference_purchase type="boolean">
|
16
|
-
<supports_purchase_via_preauthorization type="boolean">
|
17
|
-
<supports_offsite_purchase type="boolean">
|
18
|
-
<supports_offsite_authorize type="boolean">
|
19
|
-
<supports_3dsecure_purchase type="boolean">
|
20
|
-
<supports_3dsecure_authorize type="boolean">
|
21
|
-
<supports_store type="boolean">
|
22
|
-
<supports_remove type="boolean">
|
15
|
+
<supports_credit type="boolean">false</supports_credit>
|
16
|
+
<supports_void type="boolean">false</supports_void>
|
17
|
+
<supports_reference_purchase type="boolean">false</supports_reference_purchase>
|
18
|
+
<supports_purchase_via_preauthorization type="boolean">false</supports_purchase_via_preauthorization>
|
19
|
+
<supports_offsite_purchase type="boolean">false</supports_offsite_purchase>
|
20
|
+
<supports_offsite_authorize type="boolean">false</supports_offsite_authorize>
|
21
|
+
<supports_3dsecure_purchase type="boolean">false</supports_3dsecure_purchase>
|
22
|
+
<supports_3dsecure_authorize type="boolean">false</supports_3dsecure_authorize>
|
23
|
+
<supports_store type="boolean">false</supports_store>
|
24
|
+
<supports_remove type="boolean">false</supports_remove>
|
23
25
|
</characteristics>
|
24
|
-
<
|
26
|
+
<credentials>
|
27
|
+
<credential>
|
28
|
+
<name>username</name>
|
29
|
+
<value>UsernameOfAwesome</value>
|
30
|
+
</credential>
|
31
|
+
<credential>
|
32
|
+
<name>business_case_signature</name>
|
33
|
+
<value>Super Sig</value>
|
34
|
+
</credential>
|
35
|
+
</credentials>
|
36
|
+
<gateway_specific_fields/>
|
25
37
|
<payment_methods>
|
26
38
|
<payment_method>credit_card</payment_method>
|
27
|
-
<payment_method>sprel</payment_method>
|
28
|
-
<payment_method>third_party_token</payment_method>
|
29
|
-
<payment_method>bank_account</payment_method>
|
30
39
|
</payment_methods>
|
31
|
-
<
|
40
|
+
<state>redacted</state>
|
32
41
|
<redacted type="boolean">false</redacted>
|
33
|
-
<created_at type="datetime">2013-08-
|
34
|
-
<updated_at type="datetime">2013-08-
|
42
|
+
<created_at type="datetime">2013-08-23T14:52:25Z</created_at>
|
43
|
+
<updated_at type="datetime">2013-08-23T14:52:25Z</updated_at>
|
35
44
|
</gateway>
|
36
45
|
XML
|
37
46
|
end
|
47
|
+
|
38
48
|
end
|
@@ -105,4 +105,30 @@ module FindPaymentMethodStubs
|
|
105
105
|
XML
|
106
106
|
end
|
107
107
|
|
108
|
+
def successful_get_bank_account_response
|
109
|
+
StubResponse.succeeded <<-XML
|
110
|
+
<payment_method>
|
111
|
+
<token>seeQDV0jwJwFa1FUUsph6kPMTj</token>
|
112
|
+
<created_at type="datetime">2013-08-16T17:20:33Z</created_at>
|
113
|
+
<updated_at type="datetime">2013-08-16T17:20:33Z</updated_at>
|
114
|
+
<email>daniel@waterhouse.com</email>
|
115
|
+
<data>GeekyNote</data>
|
116
|
+
<storage_state>cached</storage_state>
|
117
|
+
<full_name>Daniel Waterhouse</full_name>
|
118
|
+
<bank_name>First Bank of Crypto</bank_name>
|
119
|
+
<account_type>checking</account_type>
|
120
|
+
<account_holder_type>personal</account_holder_type>
|
121
|
+
<routing_number_display_digits>021</routing_number_display_digits>
|
122
|
+
<account_number_display_digits>4321</account_number_display_digits>
|
123
|
+
<first_name>Daniel</first_name>
|
124
|
+
<last_name>Waterhouse</last_name>
|
125
|
+
<payment_method_type>bank_account</payment_method_type>
|
126
|
+
<errors>
|
127
|
+
</errors>
|
128
|
+
<routing_number>021*</routing_number>
|
129
|
+
<account_number>*4321</account_number>
|
130
|
+
</payment_method>
|
131
|
+
XML
|
132
|
+
end
|
133
|
+
|
108
134
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module ListGatewaysStubs
|
2
|
+
|
3
|
+
def successful_list_gateways_response
|
4
|
+
StubResponse.succeeded <<-XML
|
5
|
+
<gateways>
|
6
|
+
<gateway>
|
7
|
+
<token>OJUFe5ZR6pFfL4i4ZGVmvGWkZUY</token>
|
8
|
+
<gateway_type>test</gateway_type>
|
9
|
+
<name>Spreedly Test</name>
|
10
|
+
<characteristics>
|
11
|
+
<supports_purchase type="boolean">true</supports_purchase>
|
12
|
+
<supports_authorize type="boolean">true</supports_authorize>
|
13
|
+
<supports_capture type="boolean">true</supports_capture>
|
14
|
+
<supports_credit type="boolean">true</supports_credit>
|
15
|
+
<supports_void type="boolean">true</supports_void>
|
16
|
+
<supports_reference_purchase type="boolean">true</supports_reference_purchase>
|
17
|
+
<supports_purchase_via_preauthorization type="boolean">true</supports_purchase_via_preauthorization>
|
18
|
+
<supports_offsite_purchase type="boolean">true</supports_offsite_purchase>
|
19
|
+
<supports_offsite_authorize type="boolean">true</supports_offsite_authorize>
|
20
|
+
<supports_3dsecure_purchase type="boolean">true</supports_3dsecure_purchase>
|
21
|
+
<supports_3dsecure_authorize type="boolean">true</supports_3dsecure_authorize>
|
22
|
+
<supports_store type="boolean">true</supports_store>
|
23
|
+
<supports_remove type="boolean">true</supports_remove>
|
24
|
+
</characteristics>
|
25
|
+
<credentials>
|
26
|
+
</credentials>
|
27
|
+
<gateway_specific_fields/>
|
28
|
+
<payment_methods>
|
29
|
+
<payment_method>credit_card</payment_method>
|
30
|
+
<payment_method>sprel</payment_method>
|
31
|
+
<payment_method>third_party_token</payment_method>
|
32
|
+
<payment_method>bank_account</payment_method>
|
33
|
+
</payment_methods>
|
34
|
+
<state>retained</state>
|
35
|
+
<redacted type="boolean">false</redacted>
|
36
|
+
<created_at type="datetime">2013-08-23T19:36:00Z</created_at>
|
37
|
+
<updated_at type="datetime">2013-08-23T19:36:00Z</updated_at>
|
38
|
+
</gateway>
|
39
|
+
<gateway>
|
40
|
+
<token>52wqOssuKZSXEYde30AGTG6xl8v</token>
|
41
|
+
<gateway_type>test</gateway_type>
|
42
|
+
<name>Spreedly Test</name>
|
43
|
+
<characteristics>
|
44
|
+
<supports_purchase type="boolean">true</supports_purchase>
|
45
|
+
<supports_authorize type="boolean">true</supports_authorize>
|
46
|
+
<supports_capture type="boolean">true</supports_capture>
|
47
|
+
<supports_credit type="boolean">true</supports_credit>
|
48
|
+
<supports_void type="boolean">true</supports_void>
|
49
|
+
<supports_reference_purchase type="boolean">true</supports_reference_purchase>
|
50
|
+
<supports_purchase_via_preauthorization type="boolean">true</supports_purchase_via_preauthorization>
|
51
|
+
<supports_offsite_purchase type="boolean">true</supports_offsite_purchase>
|
52
|
+
<supports_offsite_authorize type="boolean">true</supports_offsite_authorize>
|
53
|
+
<supports_3dsecure_purchase type="boolean">true</supports_3dsecure_purchase>
|
54
|
+
<supports_3dsecure_authorize type="boolean">true</supports_3dsecure_authorize>
|
55
|
+
<supports_store type="boolean">true</supports_store>
|
56
|
+
<supports_remove type="boolean">true</supports_remove>
|
57
|
+
</characteristics>
|
58
|
+
<credentials>
|
59
|
+
</credentials>
|
60
|
+
<gateway_specific_fields/>
|
61
|
+
<payment_methods>
|
62
|
+
<payment_method>credit_card</payment_method>
|
63
|
+
<payment_method>sprel</payment_method>
|
64
|
+
<payment_method>third_party_token</payment_method>
|
65
|
+
<payment_method>bank_account</payment_method>
|
66
|
+
</payment_methods>
|
67
|
+
<state>retained</state>
|
68
|
+
<redacted type="boolean">false</redacted>
|
69
|
+
<created_at type="datetime">2013-08-23T19:36:00Z</created_at>
|
70
|
+
<updated_at type="datetime">2013-08-23T19:36:00Z</updated_at>
|
71
|
+
</gateway>
|
72
|
+
</gateways>
|
73
|
+
XML
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module ListPaymentMethodsStubs
|
2
|
+
|
3
|
+
def successful_list_payment_methods_response
|
4
|
+
StubResponse.succeeded <<-XML
|
5
|
+
<payment_methods>
|
6
|
+
<payment_method>
|
7
|
+
<token>VICAwZCgWukqVVpBWJlCT4mNAoG</token>
|
8
|
+
<created_at type="datetime">2013-08-13T19:57:05Z</created_at>
|
9
|
+
<updated_at type="datetime">2013-08-13T19:57:05Z</updated_at>
|
10
|
+
<email>perrin@wot.com</email>
|
11
|
+
<data nil="true"/>
|
12
|
+
<storage_state>retained</storage_state>
|
13
|
+
<last_four_digits>4444</last_four_digits>
|
14
|
+
<card_type>master</card_type>
|
15
|
+
<first_name>Perrin</first_name>
|
16
|
+
<last_name>Aybara</last_name>
|
17
|
+
<month type="integer">1</month>
|
18
|
+
<year type="integer">2019</year>
|
19
|
+
<address1 nil="true"/>
|
20
|
+
<address2 nil="true"/>
|
21
|
+
<city nil="true"/>
|
22
|
+
<state nil="true"/>
|
23
|
+
<zip nil="true"/>
|
24
|
+
<country nil="true"/>
|
25
|
+
<phone_number nil="true"/>
|
26
|
+
<full_name>Perrin Aybara</full_name>
|
27
|
+
<payment_method_type>credit_card</payment_method_type>
|
28
|
+
<errors>
|
29
|
+
</errors>
|
30
|
+
<verification_value></verification_value>
|
31
|
+
<number>XXXX-XXXX-XXXX-4444</number>
|
32
|
+
</payment_method>
|
33
|
+
<payment_method>
|
34
|
+
<token>RAZy9RHW377y5MTtpb537CxLtwE</token>
|
35
|
+
<created_at type="datetime">2013-08-13T19:57:06Z</created_at>
|
36
|
+
<updated_at type="datetime">2013-08-13T19:57:06Z</updated_at>
|
37
|
+
<email>perrin@wot.com</email>
|
38
|
+
<data nil="true"/>
|
39
|
+
<storage_state>retained</storage_state>
|
40
|
+
<last_four_digits>4444</last_four_digits>
|
41
|
+
<card_type>master</card_type>
|
42
|
+
<first_name>Mat</first_name>
|
43
|
+
<last_name>Cauthon</last_name>
|
44
|
+
<month type="integer">1</month>
|
45
|
+
<year type="integer">2019</year>
|
46
|
+
<address1 nil="true"/>
|
47
|
+
<address2 nil="true"/>
|
48
|
+
<city nil="true"/>
|
49
|
+
<state nil="true"/>
|
50
|
+
<zip nil="true"/>
|
51
|
+
<country nil="true"/>
|
52
|
+
<phone_number nil="true"/>
|
53
|
+
<full_name>Mat Cauthon</full_name>
|
54
|
+
<payment_method_type>credit_card</payment_method_type>
|
55
|
+
<errors>
|
56
|
+
</errors>
|
57
|
+
<verification_value></verification_value>
|
58
|
+
<number>XXXX-XXXX-XXXX-4444</number>
|
59
|
+
</payment_method>
|
60
|
+
</payment_methods>
|
61
|
+
XML
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module RedactGatewayStubs
|
2
|
+
|
3
|
+
def successful_redact_gateway_response
|
4
|
+
StubResponse.succeeded <<-XML
|
5
|
+
<transaction>
|
6
|
+
<token>NXKt1iNkIJhzF5QCDt1qSsuFbcN</token>
|
7
|
+
<created_at type="datetime">2013-08-19T17:16:07Z</created_at>
|
8
|
+
<updated_at type="datetime">2013-08-19T17:16:07Z</updated_at>
|
9
|
+
<succeeded type="boolean">true</succeeded>
|
10
|
+
<transaction_type>RedactGateway</transaction_type>
|
11
|
+
<message key="messages.transaction_succeeded">Succeeded!</message>
|
12
|
+
<gateway>
|
13
|
+
<token>8zy49qcEUigjYbpPKCjlhDzUqJ</token>
|
14
|
+
<gateway_type>test</gateway_type>
|
15
|
+
<name>Spreedly Test</name>
|
16
|
+
<characteristics>
|
17
|
+
<supports_purchase type="boolean">true</supports_purchase>
|
18
|
+
<supports_authorize type="boolean">true</supports_authorize>
|
19
|
+
<supports_capture type="boolean">true</supports_capture>
|
20
|
+
<supports_credit type="boolean">true</supports_credit>
|
21
|
+
<supports_void type="boolean">true</supports_void>
|
22
|
+
<supports_reference_purchase type="boolean">true</supports_reference_purchase>
|
23
|
+
<supports_purchase_via_preauthorization type="boolean">true</supports_purchase_via_preauthorization>
|
24
|
+
<supports_offsite_purchase type="boolean">true</supports_offsite_purchase>
|
25
|
+
<supports_offsite_authorize type="boolean">true</supports_offsite_authorize>
|
26
|
+
<supports_3dsecure_purchase type="boolean">true</supports_3dsecure_purchase>
|
27
|
+
<supports_3dsecure_authorize type="boolean">true</supports_3dsecure_authorize>
|
28
|
+
<supports_store type="boolean">true</supports_store>
|
29
|
+
<supports_remove type="boolean">true</supports_remove>
|
30
|
+
</characteristics>
|
31
|
+
<state>redacted</state>
|
32
|
+
<payment_methods>
|
33
|
+
<payment_method>credit_card</payment_method>
|
34
|
+
<payment_method>sprel</payment_method>
|
35
|
+
<payment_method>third_party_token</payment_method>
|
36
|
+
<payment_method>bank_account</payment_method>
|
37
|
+
</payment_methods>
|
38
|
+
<gateway_specific_fields/>
|
39
|
+
<redacted type="boolean">true</redacted>
|
40
|
+
<created_at type="datetime">2013-08-19T17:16:06Z</created_at>
|
41
|
+
<updated_at type="datetime">2013-08-19T17:16:07Z</updated_at>
|
42
|
+
</gateway>
|
43
|
+
</transaction>
|
44
|
+
XML
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module RedactPaymentMethodStubs
|
2
2
|
|
3
|
-
def
|
3
|
+
def successful_redact_payment_method_response
|
4
4
|
StubResponse.succeeded <<-XML
|
5
5
|
<transaction>
|
6
6
|
<on_test_gateway type="boolean">false</on_test_gateway>
|
@@ -46,9 +46,4 @@ module RedactPaymentMethodStubs
|
|
46
46
|
XML
|
47
47
|
end
|
48
48
|
|
49
|
-
def failed_redact_response
|
50
|
-
StubResponse.failed <<-XML
|
51
|
-
XML
|
52
|
-
end
|
53
|
-
|
54
49
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module UpdateCreditCardStubs
|
2
|
+
|
3
|
+
def successful_update_credit_card_response
|
4
|
+
StubResponse.succeeded <<-XML
|
5
|
+
<payment_method>
|
6
|
+
<token>LagdXxK2VXC6DQ5XxP6UdjRJXBn</token>
|
7
|
+
<created_at type="datetime">2013-08-13T21:33:09Z</created_at>
|
8
|
+
<updated_at type="datetime">2013-08-13T21:33:10Z</updated_at>
|
9
|
+
<email>cauthon@wot.com</email>
|
10
|
+
<data nil="true"/>
|
11
|
+
<storage_state>retained</storage_state>
|
12
|
+
<last_four_digits>4444</last_four_digits>
|
13
|
+
<card_type>master</card_type>
|
14
|
+
<first_name>Mat</first_name>
|
15
|
+
<last_name>Cauthon</last_name>
|
16
|
+
<month type="integer">1</month>
|
17
|
+
<year type="integer">2019</year>
|
18
|
+
<address1 nil="true"/>
|
19
|
+
<address2 nil="true"/>
|
20
|
+
<city nil="true"/>
|
21
|
+
<state nil="true"/>
|
22
|
+
<zip nil="true"/>
|
23
|
+
<country nil="true"/>
|
24
|
+
<phone_number nil="true"/>
|
25
|
+
<full_name>Mat Cauthon</full_name>
|
26
|
+
<payment_method_type>credit_card</payment_method_type>
|
27
|
+
<errors>
|
28
|
+
</errors>
|
29
|
+
<verification_value></verification_value>
|
30
|
+
<number>XXXX-XXXX-XXXX-4444</number>
|
31
|
+
</payment_method>
|
32
|
+
XML
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'unit/response_stubs/update_credit_card_stubs'
|
3
|
+
|
4
|
+
class UpdateCreditCreditCardTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
include UpdateCreditCardStubs
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@environment = Spreedly::Environment.new("key", "secret")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_successful_update_credit_card
|
13
|
+
c = update_card_using(successful_update_credit_card_response)
|
14
|
+
|
15
|
+
assert_kind_of(Spreedly::CreditCard, c)
|
16
|
+
|
17
|
+
assert_equal 'LagdXxK2VXC6DQ5XxP6UdjRJXBn', c.token
|
18
|
+
assert_equal 'Mat Cauthon', c.full_name
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_request_body_params
|
22
|
+
body = get_request_body(successful_update_credit_card_response) do
|
23
|
+
@environment.update_credit_card('card_token', full_card_details)
|
24
|
+
end
|
25
|
+
|
26
|
+
payment_method = body.xpath('./payment_method')
|
27
|
+
assert_xpaths_in payment_method,
|
28
|
+
[ './email', 'leavenworth@free.com' ],
|
29
|
+
[ './first_name', 'Leavenworth' ],
|
30
|
+
[ './last_name', 'Smedry' ],
|
31
|
+
[ './month', '3' ],
|
32
|
+
[ './year', '2021' ],
|
33
|
+
[ './address1', '10 Dragon Lane' ],
|
34
|
+
[ './address2', 'Suite 9' ],
|
35
|
+
[ './city', 'Tuki Tuki' ],
|
36
|
+
[ './state', 'Mokia' ],
|
37
|
+
[ './zip', '1122' ],
|
38
|
+
[ './country', 'Free Kingdoms' ],
|
39
|
+
[ './phone_number', '81Ab' ]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def update_card_using(response)
|
44
|
+
@environment.stubs(:raw_ssl_request).returns(response)
|
45
|
+
@environment.update_credit_card('card_token', ignored: "Because response is stubbed")
|
46
|
+
end
|
47
|
+
|
48
|
+
def full_card_details
|
49
|
+
{
|
50
|
+
email: 'leavenworth@free.com', month: 3, year: 2021,
|
51
|
+
last_name: 'Smedry', first_name: 'Leavenworth',
|
52
|
+
address1: '10 Dragon Lane', address2: 'Suite 9', city: 'Tuki Tuki', state: 'Mokia',
|
53
|
+
zip: '1122', country: 'Free Kingdoms', phone_number: '81Ab'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|