spreedly 2.0.14 → 2.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +7 -0
  3. data/lib/spreedly.rb +1 -0
  4. data/lib/spreedly/environment.rb +14 -4
  5. data/lib/spreedly/gateway_class.rb +2 -1
  6. data/lib/spreedly/payment_methods/credit_card.rb +1 -1
  7. data/lib/spreedly/transactions/gateway_transaction.rb +1 -1
  8. data/lib/spreedly/transactions/store.rb +20 -0
  9. data/lib/spreedly/transactions/transaction.rb +2 -0
  10. data/lib/spreedly/urls.rb +4 -0
  11. data/lib/spreedly/version.rb +1 -1
  12. data/spreedly.gemspec +1 -0
  13. data/test/remote/remote_add_receiver_test.rb +7 -8
  14. data/test/remote/remote_gateway_options_test.rb +1 -1
  15. data/test/remote/remote_store_test.rb +47 -0
  16. data/test/unit/gateway_options_test.rb +2 -1
  17. data/test/unit/purchase_test.rb +1 -0
  18. data/test/unit/response_stubs/add_credit_card_stubs.rb +1 -0
  19. data/test/unit/response_stubs/add_gateway_stubs.rb +1 -0
  20. data/test/unit/response_stubs/authorization_stubs.rb +4 -0
  21. data/test/unit/response_stubs/capture_stubs.rb +2 -0
  22. data/test/unit/response_stubs/deliver_payment_method_stubs.rb +1 -0
  23. data/test/unit/response_stubs/find_gateway_stubs.rb +1 -0
  24. data/test/unit/response_stubs/find_payment_method_stubs.rb +2 -0
  25. data/test/unit/response_stubs/find_transaction_stubs.rb +2 -0
  26. data/test/unit/response_stubs/gateway_options_stubs.rb +2 -0
  27. data/test/unit/response_stubs/list_gateways_stubs.rb +1 -0
  28. data/test/unit/response_stubs/list_payment_methods_stubs.rb +2 -0
  29. data/test/unit/response_stubs/list_transactions_stubs.rb +3 -0
  30. data/test/unit/response_stubs/purchase_stubs.rb +4 -0
  31. data/test/unit/response_stubs/redact_payment_method_stubs.rb +1 -0
  32. data/test/unit/response_stubs/refund_stubs.rb +2 -0
  33. data/test/unit/response_stubs/retain_payment_method_stubs.rb +2 -0
  34. data/test/unit/response_stubs/store_stubs.rb +158 -0
  35. data/test/unit/response_stubs/update_credit_card_stubs.rb +1 -0
  36. data/test/unit/response_stubs/verification_stubs.rb +4 -0
  37. data/test/unit/response_stubs/void_stubs.rb +2 -0
  38. data/test/unit/store_test.rb +60 -0
  39. metadata +24 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab2b935117b1a317e75e3a6d4047b286b9ed06e7
4
- data.tar.gz: eaeb49ca9cf5fac4fc679a7147d4acc108d554e3
3
+ metadata.gz: a039097df66894fac8c6611d93ac56293888ace1
4
+ data.tar.gz: b177d6b3d261a0c7f54dbd51b03b73265ceaaa4a
5
5
  SHA512:
6
- metadata.gz: a656bb8873f3a8d476ab0760bb63d1e804392bf65e0aa0ce06ebbd9a4351e081ea81a4129d958b237ed5e32aae645f1a097c155856b0b97d03e8fa585d3bb3a9
7
- data.tar.gz: 673025cc11a94db65ffd22e86a99e6967c7797e1b3072a95e676e02e4657949f72fac988efe33ece8c4b9163ba65379207060bf93c0882f66cc5de1c62a11cef
6
+ metadata.gz: 0091081a875551c012e21d69afdd0fba443c52a01c22a4e171b6752ddfdaa59f43241af0157460fc24f7d4d7b7b44ea01fe81b1e4ad39536159f709da613c607
7
+ data.tar.gz: 416efbaf986c32e256d733d171dd1796e02429984190cf930706ca351145c999e6cb8503c0be38ce01b0850ea7e47435cdde5f82424c2a1d76685bd989f2f37e
data/HISTORY.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Next Version
4
4
 
5
+ ## 2.0.15
6
+ * Add support for supports_fraud_review gateway characteristic [markabe]
7
+ * Add support for the store API call [duff]
8
+ * Add support for company name property on credit card [duff]
9
+ * Deliver payment method uses talking to gateway timeout [duff]
10
+ * Fix issue creating production receiver [duff]
11
+
5
12
  ## 2.0.14
6
13
  * Add support for gateway_specific_fields [duff]
7
14
 
data/lib/spreedly.rb CHANGED
@@ -28,6 +28,7 @@ require 'spreedly/transactions/redact_payment_method'
28
28
  require 'spreedly/transactions/redact_gateway'
29
29
  require 'spreedly/transactions/recache_sensitive_data'
30
30
  require 'spreedly/transactions/deliver_payment_method'
31
+ require 'spreedly/transactions/store'
31
32
  require 'spreedly/gateway'
32
33
  require 'spreedly/receiver'
33
34
  require 'spreedly/gateway_class'
@@ -96,6 +96,11 @@ module Spreedly
96
96
  Gateway.new_list_from(xml_doc)
97
97
  end
98
98
 
99
+ def store_on_gateway(gateway_token, payment_method_token)
100
+ body = store_body(payment_method_token)
101
+ api_post(store_url(gateway_token), body)
102
+ end
103
+
99
104
  def gateway_options
100
105
  xml_doc = ssl_options(gateway_options_url)
101
106
  GatewayClass.new_list_from(xml_doc)
@@ -129,8 +134,7 @@ module Spreedly
129
134
 
130
135
  def deliver_to_receiver(receiver_token, payment_method_token, receiver_options)
131
136
  body = deliver_to_receiver_body(payment_method_token, receiver_options)
132
- xml_doc = ssl_post(deliver_to_receiver_url(receiver_token), body, headers)
133
- DeliverPaymentMethod.new_from(xml_doc)
137
+ api_post(deliver_to_receiver_url(receiver_token), body)
134
138
  end
135
139
 
136
140
  private
@@ -202,11 +206,17 @@ module Spreedly
202
206
  def add_receiver_body(receiver_type, host_names, credentials)
203
207
  build_xml_request('receiver') do |doc|
204
208
  doc.receiver_type receiver_type
205
- doc.hostnames host_names
209
+ doc.hostnames(host_names) if host_names
206
210
  add_credentials_to_doc(doc, credentials) if credentials && !credentials.empty?
207
211
  end
208
212
  end
209
213
 
214
+ def store_body(payment_method_token)
215
+ build_xml_request('transaction') do |doc|
216
+ doc.payment_method_token(payment_method_token)
217
+ end
218
+ end
219
+
210
220
  def add_credentials_to_doc(doc, credentials)
211
221
  doc.credentials do
212
222
  credentials.each do |credential|
@@ -223,7 +233,7 @@ module Spreedly
223
233
  doc.credit_card do
224
234
  add_to_doc(doc, options, :number, :verification_value, :month, :first_name, :last_name,
225
235
  :year, :address1, :address2, :city, :state, :zip, :country, :phone_number,
226
- :eligible_for_card_updater)
236
+ :company, :eligible_for_card_updater)
227
237
  end
228
238
  end
229
239
  end
@@ -8,7 +8,8 @@ module Spreedly
8
8
  :supports_void, :supports_verify, :supports_reference_purchase,
9
9
  :supports_purchase_via_preauthorization, :supports_offsite_purchase,
10
10
  :supports_offsite_authorize, :supports_3dsecure_purchase, :supports_3dsecure_authorize,
11
- :supports_store, :supports_remove, :supports_general_credit, type: :boolean
11
+ :supports_store, :supports_remove, :supports_general_credit,
12
+ :supports_fraud_review, type: :boolean
12
13
 
13
14
  attr_reader :supported_countries, :payment_methods, :auth_modes, :regions
14
15
 
@@ -3,7 +3,7 @@ module Spreedly
3
3
  class CreditCard < PaymentMethod
4
4
  field :first_name, :last_name, :full_name, :month, :year
5
5
  field :number, :last_four_digits, :first_six_digits, :card_type, :verification_value
6
- field :address1, :address2, :city, :state, :zip, :country, :phone_number
6
+ field :address1, :address2, :city, :state, :zip, :country, :phone_number, :company
7
7
  field :eligible_for_card_updater, type: :boolean
8
8
  end
9
9
 
@@ -37,7 +37,7 @@ module Spreedly
37
37
  class Response
38
38
  include Fields
39
39
 
40
- field :success, :pending, :cancelled, type: :boolean
40
+ field :success, :pending, :cancelled, :fraud_review, type: :boolean
41
41
  field :created_at, :updated_at, type: :date_time
42
42
  field :message, :avs_code, :avs_message, :cvv_code, :cvv_message, :error_code, :error_detail
43
43
 
@@ -0,0 +1,20 @@
1
+ module Spreedly
2
+
3
+ class Store < Transaction
4
+
5
+ attr_reader :payment_method, :basis_payment_method, :response
6
+
7
+ def initialize(xml_doc)
8
+ super
9
+ payment_method_xml_doc = xml_doc.at_xpath('.//payment_method')
10
+ @payment_method = payment_method_xml_doc ? PaymentMethod.new_from(xml_doc.at_xpath('.//payment_method')) : nil
11
+
12
+ @basis_payment_method = PaymentMethod.new_from(xml_doc.at_xpath('.//basis_payment_method'))
13
+
14
+ response_xml_doc = xml_doc.at_xpath('.//response')
15
+ @response = response_xml_doc ? Response.new(response_xml_doc) : nil
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -32,6 +32,8 @@ module Spreedly
32
32
  return RecacheSensitiveData.new(xml_doc)
33
33
  when 'DeliverPaymentMethod'
34
34
  return DeliverPaymentMethod.new(xml_doc)
35
+ when 'Store'
36
+ return Store.new(xml_doc)
35
37
  else
36
38
  Transaction.new(xml_doc)
37
39
  end
data/lib/spreedly/urls.rb CHANGED
@@ -54,6 +54,10 @@ module Spreedly
54
54
  "#{base_url}/v1/gateways/#{gateway_token}/redact.xml"
55
55
  end
56
56
 
57
+ def store_url(gateway_token)
58
+ "#{base_url}/v1/gateways/#{gateway_token}/store.xml"
59
+ end
60
+
57
61
  def list_transactions_url(since_token, payment_method_token)
58
62
  since_param = "?since_token=#{since_token}" if since_token
59
63
  return "#{base_url}/v1/transactions.xml#{since_param}" unless payment_method_token
@@ -1,3 +1,3 @@
1
1
  module Spreedly
2
- VERSION = "2.0.14"
2
+ VERSION = "2.0.15"
3
3
  end
data/spreedly.gemspec CHANGED
@@ -25,5 +25,6 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency 'mocha'
26
26
  s.add_development_dependency 'log_buddy'
27
27
  s.add_development_dependency 'awesome_print'
28
+ s.add_development_dependency 'test-unit'
28
29
  end
29
30
 
@@ -25,16 +25,15 @@ class RemoteAddReceiverTest < Test::Unit::TestCase
25
25
  end
26
26
 
27
27
  def test_add_test_receiver
28
- receiver = @environment.add_receiver(:test, 'http://api.example.com/post')
28
+ receiver = @environment.add_receiver(:test, 'http://testserver.com')
29
29
  assert_equal "test", receiver.receiver_type
30
- assert_equal 'http://api.example.com/post', receiver.hostnames
30
+ assert_equal 'http://testserver.com', receiver.hostnames
31
31
  end
32
32
 
33
- # Coming soon
34
- # def test_need_active_account
35
- # assert_raise_with_message(Spreedly::PaymentRequiredError, "Your account has not been activated for real transactions. Please update your subscription settings.") do
36
- # @environment.add_receiver(:braintree)
37
- # end
38
- # end
33
+ def test_need_active_account
34
+ assert_raise_with_message(Spreedly::PaymentRequiredError, "Your account has not been activated for real transactions. Please update your subscription settings.") do
35
+ @environment.add_receiver(:braintree)
36
+ end
37
+ end
39
38
 
40
39
  end
@@ -10,7 +10,7 @@ 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 %w(credit_card third_party_token), braintree.payment_methods
13
+ assert_equal %w(credit_card third_party_token apple_pay), braintree.payment_methods
14
14
  assert_equal %w(asia_pacific europe north_america), braintree.regions
15
15
  assert_equal %w(orange blue), braintree.auth_modes.map { |e| e.auth_mode_type }
16
16
  assert_equal %w(login password), braintree.auth_modes.first.credentials.map { |e| e.name }
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ class RemoteStoreTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @environment = Spreedly::Environment.new(remote_test_environment_key, remote_test_access_secret)
7
+ end
8
+
9
+ def test_invalid_login
10
+ assert_invalid_login do |environment|
11
+ environment.store_on_gateway('gtoken', 'ptoken')
12
+ end
13
+ end
14
+
15
+ def test_payment_method_not_found
16
+ assert_raise_with_message(Spreedly::TransactionCreationError, "There is no payment method corresponding to the specified payment method token.") do
17
+ @environment.store_on_gateway('gateway_token', 'unknown_payment_method')
18
+ end
19
+ end
20
+
21
+ def test_gateway_not_found
22
+ card_token = create_card_on(@environment).token
23
+ assert_raise_with_message(Spreedly::NotFoundError, "Unable to find the specified gateway.") do
24
+ @environment.store_on_gateway('unknown_gateway', card_token)
25
+ end
26
+ end
27
+
28
+ def test_successful_store
29
+ gateway_token = @environment.add_gateway(:test).token
30
+ card_token = create_card_on(@environment).token
31
+
32
+ transaction = @environment.store_on_gateway(gateway_token, card_token)
33
+ assert transaction.succeeded?
34
+ assert_equal card_token, transaction.basis_payment_method.token
35
+ assert transaction.payment_method.third_party_token
36
+ end
37
+
38
+ def test_failed_store
39
+ gateway_token = @environment.add_gateway(:test).token
40
+ card_token = create_card_on(@environment, number: "4217651111111119").token
41
+
42
+ transaction = @environment.store_on_gateway(gateway_token, card_token)
43
+ assert !transaction.succeeded?
44
+ assert_equal "Unable to store card", transaction.message
45
+ end
46
+
47
+ end
@@ -66,7 +66,8 @@ class GatewayOptionsTest < Test::Unit::TestCase
66
66
  :supports_offsite_authorize,
67
67
  :supports_3dsecure_purchase,
68
68
  :supports_3dsecure_authorize,
69
- :supports_store
69
+ :supports_store,
70
+ :supports_fraud_review
70
71
  ].each do |c|
71
72
  assert gateway_class.send("#{c}?")
72
73
  end
@@ -37,6 +37,7 @@ class PurchaseTest < Test::Unit::TestCase
37
37
  assert_equal '31', t.response.cvv_code
38
38
  assert_equal 'Rutabaga', t.response.cvv_message
39
39
  assert !t.response.pending
40
+ assert !t.response.fraud_review
40
41
  assert_equal '899', t.response.error_code
41
42
  assert_equal 'The eagle lives!', t.response.error_detail
42
43
  assert !t.response.cancelled
@@ -31,6 +31,7 @@ module AddCreditCardStubs
31
31
  <zip>33221</zip>
32
32
  <country>UK</country>
33
33
  <phone_number>43</phone_number>
34
+ <company>Acme</company>
34
35
  <full_name>Eland Venture</full_name>
35
36
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
36
37
  <payment_method_type>credit_card</payment_method_type>
@@ -21,6 +21,7 @@ module AddGatewayStubs
21
21
  <supports_3dsecure_authorize type="boolean">true</supports_3dsecure_authorize>
22
22
  <supports_store type="boolean">true</supports_store>
23
23
  <supports_remove type="boolean">true</supports_remove>
24
+ <supports_fraud_review type="boolean">true</supports_fraud_review>
24
25
  </characteristics>
25
26
  <state>retained</state>
26
27
  <payment_methods>
@@ -39,6 +39,7 @@ module AuthorizationStubs
39
39
  <cvv_code nil="true"/>
40
40
  <cvv_message nil="true"/>
41
41
  <pending type="boolean">false</pending>
42
+ <fraud_review type="boolean">false</fraud_review>
42
43
  <error_code></error_code>
43
44
  <error_detail nil="true"/>
44
45
  <cancelled type="boolean">false</cancelled>
@@ -66,6 +67,7 @@ module AuthorizationStubs
66
67
  <zip nil="true"/>
67
68
  <country nil="true"/>
68
69
  <phone_number nil="true"/>
70
+ <company>Acme</company>
69
71
  <full_name>John Forthrast</full_name>
70
72
  <payment_method_type>credit_card</payment_method_type>
71
73
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -110,6 +112,7 @@ module AuthorizationStubs
110
112
  <cvv_code nil="true"/>
111
113
  <cvv_message nil="true"/>
112
114
  <pending type="boolean">false</pending>
115
+ <fraud_review type="boolean">false</fraud_review>
113
116
  <error_code></error_code>
114
117
  <error_detail>The eagle may have perished.</error_detail>
115
118
  <cancelled type="boolean">false</cancelled>
@@ -137,6 +140,7 @@ module AuthorizationStubs
137
140
  <zip nil="true"/>
138
141
  <country nil="true"/>
139
142
  <phone_number nil="true"/>
143
+ <company>Acme</company>
140
144
  <full_name>Perrin Aybara</full_name>
141
145
  <payment_method_type>credit_card</payment_method_type>
142
146
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -30,6 +30,7 @@ module CaptureStubs
30
30
  <cvv_code nil="true"/>
31
31
  <cvv_message nil="true"/>
32
32
  <pending type="boolean">false</pending>
33
+ <fraud_review type="boolean">false</fraud_review>
33
34
  <error_code></error_code>
34
35
  <error_detail nil="true"/>
35
36
  <cancelled type="boolean">false</cancelled>
@@ -73,6 +74,7 @@ module CaptureStubs
73
74
  <cvv_code nil="true"/>
74
75
  <cvv_message nil="true"/>
75
76
  <pending type="boolean">false</pending>
77
+ <fraud_review type="boolean">false</fraud_review>
76
78
  <error_code></error_code>
77
79
  <error_detail>The eagle has hit the window.</error_detail>
78
80
  <cancelled type="boolean">false</cancelled>
@@ -69,6 +69,7 @@ module DeliverPaymentMethodStubs
69
69
  <zip nil="true"/>
70
70
  <country nil="true"/>
71
71
  <phone_number nil="true"/>
72
+ <company>Acme</company>
72
73
  <eligible_for_card_updater>true</eligible_for_card_updater>
73
74
  <verification_value></verification_value>
74
75
  <number>XXXX-XXXX-XXXX-1111</number>
@@ -23,6 +23,7 @@ module FindGatewayStubs
23
23
  <supports_3dsecure_authorize type="boolean">false</supports_3dsecure_authorize>
24
24
  <supports_store type="boolean">false</supports_store>
25
25
  <supports_remove type="boolean">false</supports_remove>
26
+ <supports_fraud_review type="boolean">false</supports_fraud_review>
26
27
  </characteristics>
27
28
  <credentials>
28
29
  <credential>
@@ -25,6 +25,7 @@ module FindPaymentMethodStubs
25
25
  <zip>02124</zip>
26
26
  <country>USA</country>
27
27
  <phone_number>201.344.7712</phone_number>
28
+ <company>Acme</company>
28
29
  <full_name>Alcatraz Smedry</full_name>
29
30
  <payment_method_type>credit_card</payment_method_type>
30
31
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -61,6 +62,7 @@ module FindPaymentMethodStubs
61
62
  <zip nil="true"/>
62
63
  <country nil="true"/>
63
64
  <phone_number nil="true"/>
65
+ <company>Acme</company>
64
66
  <full_name></full_name>
65
67
  <payment_method_type>credit_card</payment_method_type>
66
68
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -32,6 +32,7 @@ module FindTransactionStubs
32
32
  <zip nil="true"/>
33
33
  <country nil="true"/>
34
34
  <phone_number nil="true"/>
35
+ <company>Acme</company>
35
36
  <full_name>Perrin Aybara</full_name>
36
37
  <payment_method_type>credit_card</payment_method_type>
37
38
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -87,6 +88,7 @@ module FindTransactionStubs
87
88
  <zip>10657</zip>
88
89
  <country>United States</country>
89
90
  <phone_number nil="true"/>
91
+ <company>Acme</company>
90
92
  <full_name>Jonathan Phaedrus</full_name>
91
93
  <payment_method_type>credit_card</payment_method_type>
92
94
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -78,6 +78,7 @@ module GatewayOptionsStubs
78
78
  <supports_3dsecure_authorize type="boolean">true</supports_3dsecure_authorize>
79
79
  <supports_store type="boolean">true</supports_store>
80
80
  <supports_remove type="boolean">false</supports_remove>
81
+ <supports_fraud_review type="boolean">true</supports_fraud_review>
81
82
  </characteristics>
82
83
  <payment_methods>
83
84
  <payment_method>credit_card</payment_method>
@@ -128,6 +129,7 @@ module GatewayOptionsStubs
128
129
  <supports_3dsecure_authorize type="boolean">false</supports_3dsecure_authorize>
129
130
  <supports_store type="boolean">false</supports_store>
130
131
  <supports_remove type="boolean">false</supports_remove>
132
+ <supports_fraud_review type="boolean">false</supports_fraud_review>
131
133
  </characteristics>
132
134
  <payment_methods>
133
135
  <payment_method>credit_card</payment_method>
@@ -22,6 +22,7 @@ module ListGatewaysStubs
22
22
  <supports_3dsecure_authorize type="boolean">true</supports_3dsecure_authorize>
23
23
  <supports_store type="boolean">true</supports_store>
24
24
  <supports_remove type="boolean">true</supports_remove>
25
+ <supports_fraud_review type="boolean">true</supports_fraud_review>
25
26
  </characteristics>
26
27
  <credentials>
27
28
  </credentials>
@@ -24,6 +24,7 @@ module ListPaymentMethodsStubs
24
24
  <zip nil="true"/>
25
25
  <country nil="true"/>
26
26
  <phone_number nil="true"/>
27
+ <company>Acme</company>
27
28
  <full_name>Perrin Aybara</full_name>
28
29
  <payment_method_type>credit_card</payment_method_type>
29
30
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -53,6 +54,7 @@ module ListPaymentMethodsStubs
53
54
  <zip nil="true"/>
54
55
  <country nil="true"/>
55
56
  <phone_number nil="true"/>
57
+ <company>Acme</company>
56
58
  <full_name>Mat Cauthon</full_name>
57
59
  <payment_method_type>credit_card</payment_method_type>
58
60
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -31,6 +31,7 @@ module ListTransactionsStubs
31
31
  <cvv_code nil="true"/>
32
32
  <cvv_message nil="true"/>
33
33
  <pending type="boolean">false</pending>
34
+ <fraud_review type="boolean">false</fraud_review>
34
35
  <error_code></error_code>
35
36
  <error_detail nil="true"/>
36
37
  <cancelled type="boolean">false</cancelled>
@@ -58,6 +59,7 @@ module ListTransactionsStubs
58
59
  <zip nil="true"/>
59
60
  <country nil="true"/>
60
61
  <phone_number nil="true"/>
62
+ <company>Acme</company>
61
63
  <full_name>Perrin Aybara</full_name>
62
64
  <payment_method_type>credit_card</payment_method_type>
63
65
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -98,6 +100,7 @@ module ListTransactionsStubs
98
100
  <cvv_code nil="true"/>
99
101
  <cvv_message nil="true"/>
100
102
  <pending type="boolean">false</pending>
103
+ <fraud_review type="boolean">false</fraud_review>
101
104
  <error_code></error_code>
102
105
  <error_detail nil="true"/>
103
106
  <cancelled type="boolean">false</cancelled>
@@ -30,6 +30,7 @@ module PurchaseStubs
30
30
  <cvv_code>31</cvv_code>
31
31
  <cvv_message nil="true">Rutabaga</cvv_message>
32
32
  <pending type="boolean">false</pending>
33
+ <fraud_review type="boolean">false</fraud_review>
33
34
  <error_code>899</error_code>
34
35
  <error_detail nil="true">The eagle lives!</error_detail>
35
36
  <cancelled type="boolean">false</cancelled>
@@ -57,6 +58,7 @@ module PurchaseStubs
57
58
  <zip nil="true"/>
58
59
  <country nil="true"/>
59
60
  <phone_number nil="true"/>
61
+ <company>Acme</company>
60
62
  <full_name>Perrin Aybara</full_name>
61
63
  <payment_method_type>credit_card</payment_method_type>
62
64
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -101,6 +103,7 @@ module PurchaseStubs
101
103
  <cvv_code nil="true"/>
102
104
  <cvv_message nil="true"/>
103
105
  <pending type="boolean">false</pending>
106
+ <fraud_review type="boolean">false</fraud_review>
104
107
  <error_code></error_code>
105
108
  <error_detail nil="true">The eagle is dead Jim.</error_detail>
106
109
  <cancelled type="boolean">false</cancelled>
@@ -128,6 +131,7 @@ module PurchaseStubs
128
131
  <zip nil="true"/>
129
132
  <country nil="true"/>
130
133
  <phone_number nil="true"/>
134
+ <company>Acme</company>
131
135
  <full_name>Perrin Aybara</full_name>
132
136
  <payment_method_type>credit_card</payment_method_type>
133
137
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -36,6 +36,7 @@ module RedactPaymentMethodStubs
36
36
  <zip nil="true"/>
37
37
  <country nil="true"/>
38
38
  <phone_number nil="true"/>
39
+ <company>Acme</company>
39
40
  <full_name>Perrin Aybara</full_name>
40
41
  <payment_method_type>credit_card</payment_method_type>
41
42
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -30,6 +30,7 @@ module RefundStubs
30
30
  <cvv_code nil="true"/>
31
31
  <cvv_message nil="true"/>
32
32
  <pending type="boolean">false</pending>
33
+ <fraud_review type="boolean">false</fraud_review>
33
34
  <error_code></error_code>
34
35
  <error_detail nil="true"/>
35
36
  <cancelled type="boolean">false</cancelled>
@@ -73,6 +74,7 @@ module RefundStubs
73
74
  <cvv_code nil="true"/>
74
75
  <cvv_message nil="true"/>
75
76
  <pending type="boolean">false</pending>
77
+ <fraud_review type="boolean">false</fraud_review>
76
78
  <error_code></error_code>
77
79
  <error_detail>The eagle is actually a dead duck.</error_detail>
78
80
  <cancelled type="boolean">false</cancelled>
@@ -31,6 +31,7 @@ module RetainPaymentMethodStubs
31
31
  <zip nil="true"/>
32
32
  <country nil="true"/>
33
33
  <phone_number nil="true"/>
34
+ <company>Acme</company>
34
35
  <full_name>Perrin Aybara</full_name>
35
36
  <payment_method_type>credit_card</payment_method_type>
36
37
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -74,6 +75,7 @@ module RetainPaymentMethodStubs
74
75
  <zip nil="true"/>
75
76
  <country nil="true"/>
76
77
  <phone_number nil="true"/>
78
+ <company>Acme</company>
77
79
  <full_name>Perrin Aybara</full_name>
78
80
  <payment_method_type>credit_card</payment_method_type>
79
81
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -0,0 +1,158 @@
1
+ module StoreStubs
2
+
3
+ def successful_store_response
4
+ StubResponse.succeeded <<-XML
5
+ <transaction>
6
+ <created_at type="dateTime">2015-03-20T17:32:04Z</created_at>
7
+ <updated_at type="dateTime">2015-03-20T17:32:04Z</updated_at>
8
+ <succeeded type="boolean">true</succeeded>
9
+ <token>1gOXWjBEiF83cylf5t4WLe4uULI</token>
10
+ <state>succeeded</state>
11
+ <gateway_specific_fields nil="true"/>
12
+ <gateway_specific_response_fields nil="true"/>
13
+ <transaction_type>Store</transaction_type>
14
+ <third_party_token nil="true"/>
15
+ <gateway_transaction_id nil="true"/>
16
+ <message key="messages.transaction_succeeded">Succeeded!</message>
17
+ <payment_method>
18
+ <token>McNbLlg7Ytmyyuh45PCsyfHas1r</token>
19
+ <created_at type="dateTime">2015-03-20T17:32:04Z</created_at>
20
+ <updated_at type="dateTime">2015-03-20T17:32:04Z</updated_at>
21
+ <gateway_type>test</gateway_type>
22
+ <storage_state>retained</storage_state>
23
+ <third_party_token>test_vault:5555555555554444</third_party_token>
24
+ <payment_method_type>third_party_token</payment_method_type>
25
+ <errors>
26
+ </errors>
27
+ </payment_method>
28
+ <basis_payment_method>
29
+ <token>GQzlYKsJho12S2VswhsY8Q9qCmM</token>
30
+ <created_at type="dateTime">2015-03-20T17:32:03Z</created_at>
31
+ <updated_at type="dateTime">2015-03-20T17:32:04Z</updated_at>
32
+ <email>perrin@wot.com</email>
33
+ <data nil="true"/>
34
+ <storage_state>retained</storage_state>
35
+ <test type="boolean">true</test>
36
+ <last_four_digits>4444</last_four_digits>
37
+ <first_six_digits>555555</first_six_digits>
38
+ <card_type>master</card_type>
39
+ <first_name>Perrin</first_name>
40
+ <last_name>Aybara</last_name>
41
+ <month type="integer">1</month>
42
+ <year type="integer">2019</year>
43
+ <address1 nil="true"/>
44
+ <address2 nil="true"/>
45
+ <city nil="true"/>
46
+ <state nil="true"/>
47
+ <zip nil="true"/>
48
+ <country nil="true"/>
49
+ <phone_number nil="true"/>
50
+ <company>Acme</company>
51
+ <full_name>Perrin Aybara</full_name>
52
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
53
+ <shipping_address1 nil="true"/>
54
+ <shipping_address2 nil="true"/>
55
+ <shipping_city nil="true"/>
56
+ <shipping_state nil="true"/>
57
+ <shipping_zip nil="true"/>
58
+ <shipping_country nil="true"/>
59
+ <shipping_phone_number nil="true"/>
60
+ <payment_method_type>credit_card</payment_method_type>
61
+ <errors>
62
+ </errors>
63
+ <verification_value/>
64
+ <number>XXXX-XXXX-XXXX-4444</number>
65
+ </basis_payment_method>
66
+ <response>
67
+ <success type="boolean">true</success>
68
+ <message>Successful store</message>
69
+ <avs_code nil="true"/>
70
+ <avs_message nil="true"/>
71
+ <cvv_code nil="true"/>
72
+ <cvv_message nil="true"/>
73
+ <pending type="boolean">false</pending>
74
+ <result_unknown type="boolean">false</result_unknown>
75
+ <error_code/>
76
+ <error_detail nil="true"/>
77
+ <cancelled type="boolean">false</cancelled>
78
+ <fraud_review nil="true"/>
79
+ <created_at type="dateTime">2015-03-20T17:32:04Z</created_at>
80
+ <updated_at type="dateTime">2015-03-20T17:32:04Z</updated_at>
81
+ </response>
82
+ </transaction>
83
+ XML
84
+ end
85
+
86
+ def failed_store_response
87
+ StubResponse.failed <<-XML
88
+ <transaction>
89
+ <created_at type="dateTime">2015-03-20T17:35:20Z</created_at>
90
+ <updated_at type="dateTime">2015-03-20T17:35:20Z</updated_at>
91
+ <succeeded type="boolean">false</succeeded>
92
+ <token>88PvId4mseKsO09KlkcoilsbfMW</token>
93
+ <state>gateway_processing_failed</state>
94
+ <gateway_specific_fields nil="true"/>
95
+ <gateway_specific_response_fields nil="true"/>
96
+ <transaction_type>Store</transaction_type>
97
+ <third_party_token nil="true"/>
98
+ <gateway_transaction_id nil="true"/>
99
+ <message>Unable to store card</message>
100
+ <basis_payment_method>
101
+ <token>E0iLmJB1eHtJJXf7rpmk2UimCVi</token>
102
+ <created_at type="dateTime">2015-03-20T17:35:19Z</created_at>
103
+ <updated_at type="dateTime">2015-03-20T17:35:19Z</updated_at>
104
+ <email>perrin@wot.com</email>
105
+ <data nil="true"/>
106
+ <storage_state>retained</storage_state>
107
+ <test type="boolean">true</test>
108
+ <last_four_digits>1119</last_four_digits>
109
+ <first_six_digits>421765</first_six_digits>
110
+ <card_type>visa</card_type>
111
+ <first_name>Perrin</first_name>
112
+ <last_name>Aybara</last_name>
113
+ <month type="integer">1</month>
114
+ <year type="integer">2019</year>
115
+ <address1 nil="true"/>
116
+ <address2 nil="true"/>
117
+ <city nil="true"/>
118
+ <state nil="true"/>
119
+ <zip nil="true"/>
120
+ <country nil="true"/>
121
+ <phone_number nil="true"/>
122
+ <company>Acme</company>
123
+ <full_name>Perrin Aybara</full_name>
124
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
125
+ <shipping_address1 nil="true"/>
126
+ <shipping_address2 nil="true"/>
127
+ <shipping_city nil="true"/>
128
+ <shipping_state nil="true"/>
129
+ <shipping_zip nil="true"/>
130
+ <shipping_country nil="true"/>
131
+ <shipping_phone_number nil="true"/>
132
+ <payment_method_type>credit_card</payment_method_type>
133
+ <errors>
134
+ </errors>
135
+ <verification_value/>
136
+ <number>XXXX-XXXX-XXXX-1119</number>
137
+ </basis_payment_method>
138
+ <response>
139
+ <success type="boolean">false</success>
140
+ <message>Unable to store card</message>
141
+ <avs_code nil="true"/>
142
+ <avs_message nil="true"/>
143
+ <cvv_code nil="true"/>
144
+ <cvv_message nil="true"/>
145
+ <pending type="boolean">false</pending>
146
+ <result_unknown type="boolean">false</result_unknown>
147
+ <error_code/>
148
+ <error_detail nil="true"/>
149
+ <cancelled type="boolean">false</cancelled>
150
+ <fraud_review nil="true"/>
151
+ <created_at type="dateTime">2015-03-20T17:35:20Z</created_at>
152
+ <updated_at type="dateTime">2015-03-20T17:35:20Z</updated_at>
153
+ </response>
154
+ </transaction>
155
+ XML
156
+ end
157
+
158
+ end
@@ -23,6 +23,7 @@ module UpdateCreditCardStubs
23
23
  <zip nil="true"/>
24
24
  <country nil="true"/>
25
25
  <phone_number nil="true"/>
26
+ <company>Acme</company>
26
27
  <full_name>Mat Cauthon</full_name>
27
28
  <payment_method_type>credit_card</payment_method_type>
28
29
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
@@ -31,6 +31,7 @@ module VerificationStubs
31
31
  <cvv_code nil="true"/>
32
32
  <cvv_message nil="true"/>
33
33
  <pending type="boolean">false</pending>
34
+ <fraud_review type="boolean">false</fraud_review>
34
35
  <error_code/>
35
36
  <error_detail nil="true"/>
36
37
  <cancelled type="boolean">false</cancelled>
@@ -59,6 +60,7 @@ module VerificationStubs
59
60
  <zip nil="true"/>
60
61
  <country nil="true"/>
61
62
  <phone_number nil="true"/>
63
+ <company>Acme</company>
62
64
  <full_name>Perrin Aybara</full_name>
63
65
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
64
66
  <payment_method_type>credit_card</payment_method_type>
@@ -100,6 +102,7 @@ module VerificationStubs
100
102
  <cvv_code nil="true"/>
101
103
  <cvv_message nil="true"/>
102
104
  <pending type="boolean">false</pending>
105
+ <fraud_review type="boolean">false</fraud_review>
103
106
  <error_code/>
104
107
  <error_detail>What up with that?</error_detail>
105
108
  <cancelled type="boolean">false</cancelled>
@@ -128,6 +131,7 @@ module VerificationStubs
128
131
  <zip nil="true"/>
129
132
  <country nil="true"/>
130
133
  <phone_number nil="true"/>
134
+ <company>Acme</company>
131
135
  <full_name>Perrin Aybara</full_name>
132
136
  <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
133
137
  <payment_method_type>credit_card</payment_method_type>
@@ -29,6 +29,7 @@ module VoidStubs
29
29
  <cvv_code nil="true"/>
30
30
  <cvv_message nil="true"/>
31
31
  <pending type="boolean">false</pending>
32
+ <fraud_review type="boolean">false</fraud_review>
32
33
  <error_code></error_code>
33
34
  <error_detail nil="true"/>
34
35
  <cancelled type="boolean">false</cancelled>
@@ -68,6 +69,7 @@ module VoidStubs
68
69
  <cvv_code nil="true"/>
69
70
  <cvv_message nil="true"/>
70
71
  <pending type="boolean">false</pending>
72
+ <fraud_review type="boolean">false</fraud_review>
71
73
  <error_code>10609</error_code>
72
74
  <error_detail nil="true"/>
73
75
  <cancelled type="boolean">false</cancelled>
@@ -0,0 +1,60 @@
1
+ require 'test_helper'
2
+ require 'unit/response_stubs/store_stubs'
3
+
4
+ class StoreTest < Test::Unit::TestCase
5
+
6
+ include StoreStubs
7
+
8
+ def setup
9
+ @environment = Spreedly::Environment.new("key", "secret")
10
+ end
11
+
12
+ def test_successful_store
13
+ t = store_using(successful_store_response)
14
+
15
+ assert_kind_of(Spreedly::Store, t)
16
+ assert_equal '1gOXWjBEiF83cylf5t4WLe4uULI', t.token
17
+ assert_equal Time.parse("2015-03-20 17:32:04 UTC"), t.created_at
18
+ assert_equal Time.parse("2015-03-20 17:32:04 UTC"), t.updated_at
19
+ assert t.succeeded?
20
+ assert_equal 'succeeded', t.state
21
+ assert_equal 'McNbLlg7Ytmyyuh45PCsyfHas1r', t.payment_method.token
22
+ assert_equal "test_vault:5555555555554444", t.payment_method.third_party_token
23
+ assert_equal 'GQzlYKsJho12S2VswhsY8Q9qCmM', t.basis_payment_method.token
24
+
25
+ assert t.response.success
26
+ assert_equal 'Successful store', t.response.message
27
+ assert !t.response.pending
28
+ assert !t.response.fraud_review
29
+ assert !t.response.cancelled
30
+ end
31
+
32
+ def test_failed_store
33
+ t = store_using(failed_store_response)
34
+
35
+ assert_kind_of(Spreedly::Store, t)
36
+ assert_equal '88PvId4mseKsO09KlkcoilsbfMW', t.token
37
+ assert !t.succeeded?
38
+ assert_equal 'gateway_processing_failed', t.state
39
+
40
+ assert_equal 'E0iLmJB1eHtJJXf7rpmk2UimCVi', t.basis_payment_method.token
41
+ assert_equal 'Unable to store card', t.message
42
+ end
43
+
44
+ def test_request_body_params
45
+ body = get_request_body(successful_store_response) do
46
+ @environment.store_on_gateway("TheGatewayToken", "TheCardToken")
47
+ end
48
+
49
+ transaction = body.xpath('./transaction')
50
+ assert_xpaths_in transaction, [ './payment_method_token', 'TheCardToken' ]
51
+ end
52
+
53
+
54
+ private
55
+ def store_using(response)
56
+ @environment.stubs(:raw_ssl_request).returns(response)
57
+ @environment.store_on_gateway("IgnoredGatewayTokenSinceResponseIsStubbed", "IgnoredPaymentMethodTokenSinceResponseIsStubbed")
58
+ end
59
+
60
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreedly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spreedly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: test-unit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: The Spreedly gem provides a convenient Ruby wrapper for the Spreedly
98
112
  API.
99
113
  email:
@@ -139,6 +153,7 @@ files:
139
153
  - lib/spreedly/transactions/redact_payment_method.rb
140
154
  - lib/spreedly/transactions/refund.rb
141
155
  - lib/spreedly/transactions/retain_payment_method.rb
156
+ - lib/spreedly/transactions/store.rb
142
157
  - lib/spreedly/transactions/transaction.rb
143
158
  - lib/spreedly/transactions/verification.rb
144
159
  - lib/spreedly/transactions/void.rb
@@ -170,6 +185,7 @@ files:
170
185
  - test/remote/remote_redact_payment_method_test.rb
171
186
  - test/remote/remote_refund_test.rb
172
187
  - test/remote/remote_retain_test.rb
188
+ - test/remote/remote_store_test.rb
173
189
  - test/remote/remote_update_credit_card_test.rb
174
190
  - test/remote/remote_verify_test.rb
175
191
  - test/remote/remote_void_test.rb
@@ -212,10 +228,12 @@ files:
212
228
  - test/unit/response_stubs/redact_payment_method_stubs.rb
213
229
  - test/unit/response_stubs/refund_stubs.rb
214
230
  - test/unit/response_stubs/retain_payment_method_stubs.rb
231
+ - test/unit/response_stubs/store_stubs.rb
215
232
  - test/unit/response_stubs/update_credit_card_stubs.rb
216
233
  - test/unit/response_stubs/verification_stubs.rb
217
234
  - test/unit/response_stubs/void_stubs.rb
218
235
  - test/unit/retain_payment_method_test.rb
236
+ - test/unit/store_test.rb
219
237
  - test/unit/timeout_test.rb
220
238
  - test/unit/update_credit_card_test.rb
221
239
  - test/unit/verify_test.rb
@@ -240,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
258
  version: '0'
241
259
  requirements: []
242
260
  rubyforge_project:
243
- rubygems_version: 2.2.2
261
+ rubygems_version: 2.4.5
244
262
  signing_key:
245
263
  specification_version: 4
246
264
  summary: Provides a Ruby wrapper for the Spreedly API.
@@ -270,6 +288,7 @@ test_files:
270
288
  - test/remote/remote_redact_payment_method_test.rb
271
289
  - test/remote/remote_refund_test.rb
272
290
  - test/remote/remote_retain_test.rb
291
+ - test/remote/remote_store_test.rb
273
292
  - test/remote/remote_update_credit_card_test.rb
274
293
  - test/remote/remote_verify_test.rb
275
294
  - test/remote/remote_void_test.rb
@@ -312,10 +331,12 @@ test_files:
312
331
  - test/unit/response_stubs/redact_payment_method_stubs.rb
313
332
  - test/unit/response_stubs/refund_stubs.rb
314
333
  - test/unit/response_stubs/retain_payment_method_stubs.rb
334
+ - test/unit/response_stubs/store_stubs.rb
315
335
  - test/unit/response_stubs/update_credit_card_stubs.rb
316
336
  - test/unit/response_stubs/verification_stubs.rb
317
337
  - test/unit/response_stubs/void_stubs.rb
318
338
  - test/unit/retain_payment_method_test.rb
339
+ - test/unit/store_test.rb
319
340
  - test/unit/timeout_test.rb
320
341
  - test/unit/update_credit_card_test.rb
321
342
  - test/unit/verify_test.rb