spreedly 2.0.18 → 2.0.24

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.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -1
  3. data/CHANGELOG.md +174 -0
  4. data/README.md +12 -3
  5. data/Rakefile +2 -14
  6. data/lib/spreedly/environment.rb +31 -5
  7. data/lib/spreedly/gateway_class.rb +3 -1
  8. data/lib/spreedly/payment_methods/payment_method.rb +1 -1
  9. data/lib/spreedly/receiver.rb +1 -1
  10. data/lib/spreedly/ssl_requester.rb +1 -4
  11. data/lib/spreedly/transactions/auth_purchase.rb +3 -5
  12. data/lib/spreedly/transactions/authorization.rb +1 -5
  13. data/lib/spreedly/transactions/gateway_transaction.rb +6 -31
  14. data/lib/spreedly/transactions/purchase.rb +0 -3
  15. data/lib/spreedly/transactions/response.rb +13 -0
  16. data/lib/spreedly/transactions/shipping_address.rb +11 -0
  17. data/lib/spreedly/transactions/transaction.rb +0 -4
  18. data/lib/spreedly/urls.rb +25 -8
  19. data/lib/spreedly/version.rb +1 -1
  20. data/lib/spreedly.rb +2 -0
  21. data/spreedly.gemspec +18 -18
  22. data/test/credentials/credentials.yml.example +5 -0
  23. data/test/credentials/test_credentials.rb +1 -1
  24. data/test/helpers/creation_helper.rb +11 -8
  25. data/test/remote/remote_add_credit_card_test.rb +2 -2
  26. data/test/remote/remote_add_receiver_test.rb +2 -2
  27. data/test/remote/remote_authorize_test.rb +17 -2
  28. data/test/remote/remote_complete_test.rb +27 -0
  29. data/test/remote/remote_deliver_payment_method_test.rb +3 -3
  30. data/test/remote/remote_gateway_options_test.rb +1 -1
  31. data/test/remote/remote_purchase_test.rb +42 -0
  32. data/test/remote/remote_recache_payment_method_test.rb +30 -0
  33. data/test/remote/remote_redact_receiver_test.rb +16 -0
  34. data/test/remote/remote_update_credit_card_test.rb +1 -1
  35. data/test/test_helper.rb +1 -0
  36. data/test/unit/add_credit_card_test.rb +1 -2
  37. data/test/unit/authorize_test.rb +9 -2
  38. data/test/unit/capture_test.rb +2 -0
  39. data/test/unit/find_payment_method_test.rb +1 -0
  40. data/test/unit/gateway_options_test.rb +18 -12
  41. data/test/unit/list_payment_methods_test.rb +1 -0
  42. data/test/unit/list_transactions_test.rb +12 -0
  43. data/test/unit/purchase_test.rb +59 -2
  44. data/test/unit/recache_payment_method_test.rb +34 -0
  45. data/test/unit/refund_test.rb +1 -0
  46. data/test/unit/response_stubs/authorization_stubs.rb +6 -2
  47. data/test/unit/response_stubs/capture_stubs.rb +5 -1
  48. data/test/unit/response_stubs/purchase_stubs.rb +106 -0
  49. data/test/unit/response_stubs/recache_payment_method_stubs.rb +53 -0
  50. data/test/unit/verify_test.rb +5 -2
  51. data/test/unit/void_test.rb +1 -0
  52. metadata +44 -16
  53. data/HISTORY.md +0 -153
  54. data/test/credentials/credentials.yml +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fee7ae1d3bf0eaf6126ead42e28a16367920632f
4
- data.tar.gz: b38482be678195d537c456b845fa6f1c33dcf7c7
2
+ SHA256:
3
+ metadata.gz: 43cf51954eea13a2f1305e712c4ea4c4870f4de8b1066160b8023ca45b8e2aa0
4
+ data.tar.gz: 0dd8522435f12b094dbdb8f07dfb45143ac265aaac416457f95242a038e1e5b6
5
5
  SHA512:
6
- metadata.gz: e8637191e25984c4fa21fb0afe9ef517fbfc68c4bd714f9ffb000ace8348d9d91980aded43f8ae30311990791055ac769ff3c1217bc53e0606fd59b9ddc5a626
7
- data.tar.gz: ca75c0e0a89f28e5f19c87bea810e0939ae58e6d7d1e921ea0a7ee8e99bcd8dd1596f858032c2f740458c086cbf5035e90930742f738e8d56c2d51b3112728db
6
+ metadata.gz: 1d36b133483e50f955c4e392a2f43a6ae6efa0edae54f2b7f1266b7a4587b47fc4a8e1725b6de49e90b4e2cc3a390e78b4c10e919eb8b2d675df73c3b8232c2a
7
+ data.tar.gz: 77f2b68c2f8b94250836a3a8a2dadaf47e2950717c5a0ef192d39150ba0844b5b874799773c3f4eb46c1b53209374cb62e6264093eb752f19374120381501067
data/.gitignore CHANGED
@@ -5,5 +5,6 @@ pkg
5
5
  .bundle
6
6
  tmp
7
7
  vendor/ruby
8
- test/credentials/personal_credentials.yml
8
+ test/credentials/*.yml
9
9
  .ruby-version
10
+ .idea
data/CHANGELOG.md ADDED
@@ -0,0 +1,174 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [2.0.24]
6
+ ### Added
7
+ - @jeremywrowe - Add 3D Secure 2 complete transaction
8
+
9
+ ## [2.0.23] - 2019-08-16
10
+ ### Added
11
+ - @bayprogrammer - Add 3D Secure 2 third-party auth abilities to gateway class
12
+
13
+ ## [2.0.22] - 2019-08-14
14
+ ### Added
15
+ - @jeremywrowe - Support for three_ds_version, three_ds_context, and channel on
16
+ authorization / purchase
17
+
18
+ ## [2.0.21] - 2019-07-19
19
+ ### Added
20
+ - @jeremywrowe - Support for Stored Credentials on authorization / purchase
21
+ - @jeremywrowe - 3D Secure 2 abilities to gateway class
22
+
23
+ ## [2.0.20] - 2019-06-27
24
+ ### Changed
25
+ - @patrickarnett - Modify `list_transactions` and `list_transactions_url` to take `count`, `order`, and `state` arguments in an optional hash.
26
+
27
+ ## [2.0.19] - 2019-06-07
28
+ ### Added
29
+ - Lori Holden - Receiver redaction
30
+ - Lancelot Carlson - Recached payment method support
31
+ - @pawel-krysiak and @jeremywrowe - Support 3D-Secure transactions
32
+
33
+ ### Changed
34
+ - @therufs - Expose `display_api_url` on gateway
35
+ - @ZeusPerez - Expose `continue_caching` on transactions
36
+ - @adamcohen - Expose `transaction_type` on transaction
37
+ - @adamcohen - Expose `gateway_specific_response_fields` on transaction
38
+ - @adamcohen - Expose `payment_method_type` on transaction
39
+
40
+ ## [2.0.16]
41
+ - Support disburse [rwdaigle]
42
+ - Support full_name property [maccca]
43
+ - Add support for purchase shipping address override [davidsantoso]
44
+ - Allow email override in transactions [duff]
45
+ - Add options for store_on_gateway [fedesoria]
46
+ - Support fingerprint [duff]
47
+
48
+ ## 2.0.15
49
+ - Add support for supports_fraud_review gateway characteristic [markabe]
50
+ - Add support for the store API call [duff]
51
+ - Add support for company name property on credit card [duff]
52
+ - Deliver payment method uses talking to gateway timeout [duff]
53
+ - Fix issue creating production receiver [duff]
54
+
55
+ ## 2.0.14
56
+ - Add support for gateway_specific_fields [duff]
57
+
58
+ ## 2.0.13
59
+ - Check attributes for non-nil before sending [markabe]
60
+ - Add supports_verify option to Gateway [duff]
61
+ - Add support for verify_on_gateway API call [duff]
62
+ - Add support for RecacheSensitiveData transaction [duff]
63
+ - Remove cacert.pem and rely on system certs [duff]
64
+ - Adds add_receiver method to environment [Thomas Hoen]
65
+ - Adds deliver_receiver functionality [Thomas Hoen]
66
+ - Add support for first_six_digits [duff]
67
+ - Add support for supports_general_credit characteristic [markabe]
68
+
69
+ ## 2.0.12
70
+ - Add support for new credit card field: eligible_for_card_updater [markabe]
71
+
72
+ ## 2.0.11
73
+ - Add support for ThirdPartyTokens [duff]
74
+
75
+ ## 2.0.10
76
+ - Add support for gateway_transaction_id [hoenth]
77
+
78
+ ## 2.0.9
79
+ - Improve support for base_url around ssl [duff]
80
+
81
+ ## 2.0.8
82
+ - Add support for gateway regions [duff]
83
+
84
+ ## 2.0.7
85
+ - Add support for company_name to gateway options [duff]
86
+ - Implemented gateway characteristics [ilyutov]
87
+ - Allow access to gateway options w/o credentials [duff]
88
+
89
+ ## 2.0.6
90
+ - Add auth_mode support to gateway options call [sosedoff]
91
+ - Pass through verification_value when creating a card directly [duff]
92
+
93
+ ## 2.0.5
94
+ - Add ability to retrieve a transcript [hoenth]
95
+
96
+ ## 2.0.3
97
+ - Readme improvements
98
+ - Smarter about timeouts - now only have long timeout for calls
99
+ that actually talk to a payment gateway. The other calls can
100
+ have shorter timeouts.
101
+
102
+ ## 2.0.2
103
+ - Add support for gateway options call.
104
+
105
+ ## 2.0.1
106
+ - List the transactions for a payment method
107
+ - Allow adding other gateways
108
+ - Listing Payment Methods (retained on an account)
109
+ - Updating a Payment Method
110
+ - Listing Your Gateways
111
+ - Finding a Gateway
112
+ - Fix Ruby 1.9.2 private method issue
113
+ - Add ability to find a bank account payment method
114
+ - Add ability to redact a gateway
115
+
116
+ ## 2.0.0
117
+ - This gem is now intended for the Spreedly API. For the Spreedly
118
+ Subscriptions API, you can use the spreedly_subscriptions gem
119
+ which has everything that 1.4.0 had.
120
+
121
+ ## 1.4.0
122
+ - Add accessor for invoices
123
+ - Add accessor for last successful invoice
124
+
125
+ ## 1.3.6
126
+ - Modernize packaging
127
+ - Improve handling of bad credentials
128
+
129
+ ## 1.3.5
130
+ - Move to Spreedly repo.
131
+
132
+ ## 1.3.4
133
+ - Add result body to comp validation failure. [ntalbott]
134
+
135
+ ## 1.3.3
136
+ - Add support for return_url in Spreedly.edit_subscriber_url [jjthrash]
137
+ - Add support for return_url in Spreedly.subscribe_url [jjthrash]
138
+
139
+ ## 1.3.2
140
+ - Added methods on subscriber: update, allow_free_trial,
141
+ add_fee [mateuszzawisza]
142
+ - Fixing tests: generate spreedly url and edit url working with all
143
+ site names [mateuszzawisza]
144
+ - Add support for pre-population of the subscribe page via the subscribe
145
+ url. [davemcp]
146
+
147
+ ## 1.3.1
148
+ - Handle new error reporting when creating a subscriber.
149
+ - Use a more sane way of setting attributes in the mock, and make plans have a
150
+ plan type [seancribbs].
151
+ - Allow optional arguments to be passed when creating subscribers [jaknowlden].
152
+
153
+ ## 1.3.0 / 2009-06-04
154
+ - Properly handle invalid Subscriber lookup [karnowski].
155
+ - Added support for stopping auto renew [scottmotte, dsimard].
156
+
157
+ ## 1.2.2 / 2009-05-11
158
+ - Fixed an error in the README [karnowski].
159
+
160
+ ## 1.2.1 / 2009-04-30
161
+ - A few documentation tweaks.
162
+
163
+ ## 1.2.0 / 2009-04-30
164
+ - Added mock support for Subscriber#activate_free_trial [scottmotte].
165
+ - Added tests for Subscriber#activate_free_trial.
166
+
167
+ ## 1.1.0 / 2009-04-24
168
+ - Compatibility with the latest hoe and HTTParty [seancribbs].
169
+ - Added Subscriber.delete! [scottmotte].
170
+ - Added Subscriber#activate_free_trial [scottmotte].
171
+
172
+ ## 1.0.0 / 2009-03-17
173
+ - Initial release.
174
+
data/README.md CHANGED
@@ -181,6 +181,12 @@ env.purchase_on_gateway(gateway_token, payment_method_token, amount,
181
181
  )
182
182
  ```
183
183
 
184
+ #### Complete a transaction (3DS 2)
185
+
186
+ ```ruby
187
+ env.complete_transaction(transaction_token)
188
+ ```
189
+
184
190
  #### Retain on success
185
191
  Retain a payment method automatically if the purchase, verify, or authorize transaction succeeded. Saves you a separate call to retain:
186
192
 
@@ -273,7 +279,7 @@ Here's how you can do it:
273
279
 
274
280
  ``` ruby
275
281
  options = {
276
- email: 'perrin@wot.com', number: '5555555555554444', month: 1, year: 2019, last_name: 'Aybara', first_name: 'Perrin', data: "occupation: Blacksmith"
282
+ email: 'perrin@wot.com', number: '5555555555554444', month: 1, year: 2023, last_name: 'Aybara', first_name: 'Perrin', data: "occupation: Blacksmith"
277
283
  }
278
284
  transaction = env.add_credit_card(options)
279
285
 
@@ -286,7 +292,7 @@ You can also retain the card immediately like so:
286
292
 
287
293
  ``` ruby
288
294
  options = {
289
- email: 'perrin@wot.com', number: '5555555555554444', month: 1, year: 2019, last_name: 'Aybara', first_name: 'Perrin', data: "occupation: Blacksmith", retained: true
295
+ email: 'perrin@wot.com', number: '5555555555554444', month: 1, year: 2023, last_name: 'Aybara', first_name: 'Perrin', data: "occupation: Blacksmith", retained: true
290
296
  }
291
297
  transaction = env.add_credit_card(options)
292
298
 
@@ -322,7 +328,6 @@ You can get the full list of supported receivers like so:
322
328
  env.receiver_options
323
329
  ```
324
330
 
325
-
326
331
  ## Error Handling
327
332
 
328
333
  When you make a call to the API, there are times when things don't go as expected. For the most part, when a call is made, a Transaction is created behind the scenes at Spreedly. In general,
@@ -409,3 +414,7 @@ There are two rake tasks to help run the tests:
409
414
  rake test:remote # Run remote tests that actually hit the Spreedly site
410
415
  rake test:units # Run unit tests
411
416
  ```
417
+
418
+ To run remote tests you'll need to copy `test/credentials/credentials.yml.example` to `test/credentials/credentials.yml` and update the values of `environment_key` and `access_secret`.
419
+
420
+ When you're happy with your change, don't forget to add your contributions to CHANGELOG.md. We follow the changelog format found [here](https://keepachangelog.com/en/1.0.0/).
data/Rakefile CHANGED
@@ -2,20 +2,10 @@ require "bundler/gem_tasks"
2
2
 
3
3
  require 'rake/testtask'
4
4
 
5
- # Rake::TestTask.new do |t|
6
- # t.libs << 'test'
7
- # end
8
-
9
- # desc "Run tests"
10
- # task :default => :test
11
-
12
-
13
-
14
- desc "Run the unit test suite"
15
- task :default => 'test:units'
5
+ desc 'Run the unit test suite'
6
+ task default: 'test:units'
16
7
 
17
8
  namespace :test do
18
-
19
9
  Rake::TestTask.new(:units) do |t|
20
10
  t.pattern = 'test/unit/**/*_test.rb'
21
11
  t.libs << 'test'
@@ -27,6 +17,4 @@ namespace :test do
27
17
  t.libs << 'test'
28
18
  t.verbose = true
29
19
  end
30
-
31
20
  end
32
-
@@ -30,7 +30,8 @@ module Spreedly
30
30
  end
31
31
 
32
32
  def find_transcript(transaction_token)
33
- ssl_raw_get(find_transcript_url(transaction_token), headers)
33
+ transcript_url = find_transcript_url(transaction_token)
34
+ ssl_raw_get(transcript_url, headers)
34
35
  end
35
36
 
36
37
  def find_gateway(token)
@@ -48,6 +49,10 @@ module Spreedly
48
49
  api_post(authorize_url(gateway_token), body)
49
50
  end
50
51
 
52
+ def complete_transaction(transaction_token)
53
+ api_post(complete_transaction_url(transaction_token), '')
54
+ end
55
+
51
56
  def verify_on_gateway(gateway_token, payment_method_token, options = {})
52
57
  body = verify_body(payment_method_token, options)
53
58
  api_post(verify_url(gateway_token), body)
@@ -76,13 +81,24 @@ module Spreedly
76
81
  Transaction.new_from(xml_doc)
77
82
  end
78
83
 
84
+ def recache_payment_method(payment_method_token, options = {})
85
+ body = recache_payment_method_body(options)
86
+ xml_doc = ssl_put(recache_payment_method_url(payment_method_token), body, headers)
87
+ RecacheSensitiveData.new_from(xml_doc)
88
+ end
89
+
79
90
  def redact_gateway(gateway_token, options = {})
80
91
  xml_doc = ssl_put(redact_gateway_url(gateway_token), '', headers)
81
92
  Transaction.new_from(xml_doc)
82
93
  end
83
94
 
84
- def list_transactions(since_token = nil, payment_method_token = nil)
85
- xml_doc = ssl_get(list_transactions_url(since_token, payment_method_token), headers)
95
+ def redact_receiver(receiver_token, options = {})
96
+ xml_doc = ssl_put(redact_receiver_url(receiver_token), '', headers)
97
+ Transaction.new_from(xml_doc)
98
+ end
99
+
100
+ def list_transactions(since_token = nil, payment_method_token = nil, options = {})
101
+ xml_doc = ssl_get(list_transactions_url(since_token, payment_method_token, options), headers)
86
102
  Transaction.new_list_from(xml_doc)
87
103
  end
88
104
 
@@ -160,6 +176,8 @@ module Spreedly
160
176
  doc.currency_code(options[:currency_code] || currency_code)
161
177
  doc.payment_method_token(payment_method_token)
162
178
  add_to_doc(doc, options, :retain_on_success)
179
+ add_to_doc(doc, options, :stored_credential_initiator)
180
+ add_to_doc(doc, options, :stored_credential_reason_type)
163
181
  add_extra_options_for_basic_ops(doc, options)
164
182
  end
165
183
  end
@@ -205,6 +223,14 @@ module Spreedly
205
223
  end
206
224
  end
207
225
 
226
+ def recache_payment_method_body(options)
227
+ build_xml_request('payment_method') do |doc|
228
+ doc.credit_card do
229
+ add_to_doc(doc, options, :verification_value)
230
+ end
231
+ end
232
+ end
233
+
208
234
  def add_gateway_body(gateway_type, credentials)
209
235
  build_xml_request('gateway') do |doc|
210
236
  doc.gateway_type gateway_type
@@ -279,7 +305,8 @@ module Spreedly
279
305
  add_gateway_specific_fields(doc, options)
280
306
  add_shipping_address_override(doc, options)
281
307
  add_to_doc(doc, options, :order_id, :description, :ip, :email, :merchant_name_descriptor,
282
- :merchant_location_descriptor, :redirect_url, :callback_url)
308
+ :merchant_location_descriptor, :redirect_url, :callback_url,
309
+ :continue_caching, :attempt_3dsecure, :browser_info, :three_ds_version, :channel)
283
310
  end
284
311
 
285
312
  def add_gateway_specific_fields(doc, options)
@@ -315,6 +342,5 @@ module Spreedly
315
342
  xml_doc = ssl_post(url, body, headers, talking_to_gateway)
316
343
  Transaction.new_from(xml_doc)
317
344
  end
318
-
319
345
  end
320
346
  end
@@ -3,11 +3,13 @@ module Spreedly
3
3
  class GatewayClass
4
4
  include Fields
5
5
 
6
- field :gateway_type, :name, :homepage, :company_name
6
+ field :gateway_type, :name, :homepage, :company_name, :display_api_url
7
7
  field :supports_purchase, :supports_authorize, :supports_capture, :supports_credit,
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_3dsecure_2_purchase, :supports_3dsecure_2_authorize,
12
+ :supports_3dsecure_2_mpi_purchase, :supports_3dsecure_2_mpi_authorize,
11
13
  :supports_store, :supports_remove, :supports_general_credit,
12
14
  :supports_fraud_review, type: :boolean
13
15
 
@@ -6,7 +6,7 @@ module Spreedly
6
6
 
7
7
  include ErrorsParser
8
8
 
9
- field :email, :storage_state, :data
9
+ field :email, :storage_state, :data, :payment_method_type
10
10
  attr_reader :errors
11
11
 
12
12
  def initialize(xml_doc)
@@ -3,7 +3,7 @@ module Spreedly
3
3
 
4
4
  class Receiver < Model
5
5
 
6
- field :receiver_type, :hostnames
6
+ field :receiver_type, :hostnames, :state, :company_name
7
7
  attr_reader :credentials
8
8
 
9
9
  def initialize(xml_doc)
@@ -1,7 +1,5 @@
1
1
  module Spreedly
2
-
3
2
  module SslRequester
4
-
5
3
  def ssl_get(endpoint, headers)
6
4
  ssl_request(:get, endpoint, nil, headers)
7
5
  end
@@ -23,6 +21,7 @@ module Spreedly
23
21
  end
24
22
 
25
23
  private
24
+
26
25
  def ssl_request(method, endpoint, body, headers, options = {})
27
26
  opts = { talking_to_gateway: false, return_raw: false }.merge(options)
28
27
  how_long = opts[:talking_to_gateway] ? 66 : 10
@@ -73,7 +72,5 @@ module Spreedly
73
72
  puts raw_response.inspect
74
73
  puts "\nraw_response.code: #{raw_response.code}\nraw_response.body:\n#{raw_response.body}"
75
74
  end
76
-
77
75
  end
78
-
79
76
  end
@@ -1,8 +1,8 @@
1
1
  module Spreedly
2
-
3
2
  class AuthPurchase < GatewayTransaction
4
-
5
- field :currency_code
3
+ field :currency_code, :checkout_url, :checkout_form, :redirect_url, :callback_url
4
+ field :required_action, :challenge_form, :challenge_url, :device_fingerprint_form
5
+ field :stored_credential_initiator, :stored_credential_reason_type, :three_ds_context
6
6
  field :amount, type: :integer
7
7
 
8
8
  attr_reader :payment_method
@@ -11,7 +11,5 @@ module Spreedly
11
11
  super
12
12
  @payment_method = PaymentMethod.new_from(xml_doc.at_xpath('.//payment_method'))
13
13
  end
14
-
15
14
  end
16
-
17
15
  end
@@ -1,7 +1,3 @@
1
1
  module Spreedly
2
-
3
- class Authorization < AuthPurchase
4
-
5
- end
6
-
2
+ Authorization = Class.new(AuthPurchase)
7
3
  end
@@ -1,12 +1,10 @@
1
1
  module Spreedly
2
-
3
2
  class GatewayTransaction < Transaction
4
-
5
- field :order_id, :ip, :description, :gateway_token, :gateway_transaction_id, :email
3
+ field :order_id, :ip, :description, :gateway_token, :gateway_transaction_id, :email, :transaction_type
6
4
  field :merchant_name_descriptor, :merchant_location_descriptor
7
5
  field :on_test_gateway, type: :boolean
8
6
 
9
- attr_reader :response, :gateway_specific_fields, :shipping_address
7
+ attr_reader :response, :gateway_specific_fields, :gateway_specific_response_fields, :shipping_address
10
8
 
11
9
  def initialize(xml_doc)
12
10
  super
@@ -14,13 +12,14 @@ module Spreedly
14
12
  shipping_address_xml_doc = xml_doc.at_xpath('.//shipping_address')
15
13
  @response = response_xml_doc ? Response.new(response_xml_doc) : nil
16
14
  @shipping_address = shipping_address_xml_doc ? ShippingAddress.new(shipping_address_xml_doc) : nil
17
- @gateway_specific_fields = parse_gateway_specific_fields(xml_doc)
15
+ @gateway_specific_fields = parse_gateway_fields(xml_doc, './/gateway_specific_fields')
16
+ @gateway_specific_response_fields = parse_gateway_fields(xml_doc, './/gateway_specific_response_fields')
18
17
  end
19
18
 
20
- def parse_gateway_specific_fields(xml_doc)
19
+ def parse_gateway_fields(xml_doc, path)
21
20
  result = {}
22
21
 
23
- xml_doc.at_xpath('.//gateway_specific_fields').xpath('*').each do |node|
22
+ xml_doc.at_xpath(path).xpath('*').each do |node|
24
23
  node_name = node.name.to_sym
25
24
  if (node.elements.empty?)
26
25
  result[node_name] = node.text
@@ -35,28 +34,4 @@ module Spreedly
35
34
  result
36
35
  end
37
36
  end
38
-
39
- class Response
40
- include Fields
41
-
42
- field :success, :pending, :cancelled, :fraud_review, type: :boolean
43
- field :created_at, :updated_at, type: :date_time
44
- field :message, :avs_code, :avs_message, :cvv_code, :cvv_message, :error_code, :error_detail
45
-
46
- def initialize(xml_doc)
47
- initialize_fields(xml_doc)
48
- end
49
-
50
- end
51
-
52
- class ShippingAddress
53
- include Fields
54
-
55
- field :name, :address1, :address2, :city, :state, :zip, :country, :phone_number
56
-
57
- def initialize(xml_doc)
58
- initialize_fields(xml_doc)
59
- end
60
-
61
- end
62
37
  end
@@ -1,7 +1,4 @@
1
1
  module Spreedly
2
-
3
2
  class Purchase < AuthPurchase
4
-
5
3
  end
6
-
7
4
  end
@@ -0,0 +1,13 @@
1
+ module Spreedly
2
+ class Response
3
+ include Fields
4
+
5
+ field :success, :pending, :cancelled, :fraud_review, type: :boolean
6
+ field :created_at, :updated_at, type: :date_time
7
+ field :message, :avs_code, :avs_message, :cvv_code, :cvv_message, :error_code, :error_detail
8
+
9
+ def initialize(xml_doc)
10
+ initialize_fields(xml_doc)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Spreedly
2
+ class ShippingAddress
3
+ include Fields
4
+
5
+ field :name, :address1, :address2, :city, :state, :zip, :country, :phone_number
6
+
7
+ def initialize(xml_doc)
8
+ initialize_fields(xml_doc)
9
+ end
10
+ end
11
+ end
@@ -1,8 +1,6 @@
1
1
 
2
2
  module Spreedly
3
-
4
3
  class Transaction < Model
5
-
6
4
  field :state, :message
7
5
  field :succeeded, type: :boolean
8
6
 
@@ -47,7 +45,5 @@ module Spreedly
47
45
  self.new_from(each)
48
46
  end
49
47
  end
50
-
51
48
  end
52
-
53
49
  end
data/lib/spreedly/urls.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  module Spreedly
2
-
3
2
  module Urls
4
-
5
3
  def find_payment_method_url(token)
6
4
  "#{base_url}/v1/payment_methods/#{token}.xml"
7
5
  end
@@ -14,6 +12,10 @@ module Spreedly
14
12
  "#{base_url}/v1/transactions/#{transaction_token}/transcript"
15
13
  end
16
14
 
15
+ def complete_transaction_url(token)
16
+ "#{base_url}/v1/transactions/#{token}/complete.xml"
17
+ end
18
+
17
19
  def find_gateway_url(token)
18
20
  "#{base_url}/v1/gateways/#{token}.xml"
19
21
  end
@@ -50,6 +52,10 @@ module Spreedly
50
52
  "#{base_url}/v1/payment_methods/#{payment_method_token}/redact.xml"
51
53
  end
52
54
 
55
+ def recache_payment_method_url(payment_method_token)
56
+ "#{base_url}/v1/payment_methods/#{payment_method_token}/recache.xml"
57
+ end
58
+
53
59
  def redact_gateway_url(gateway_token)
54
60
  "#{base_url}/v1/gateways/#{gateway_token}/redact.xml"
55
61
  end
@@ -58,11 +64,20 @@ module Spreedly
58
64
  "#{base_url}/v1/gateways/#{gateway_token}/store.xml"
59
65
  end
60
66
 
61
- def list_transactions_url(since_token, payment_method_token)
62
- since_param = "?since_token=#{since_token}" if since_token
63
- return "#{base_url}/v1/transactions.xml#{since_param}" unless payment_method_token
67
+ def list_transactions_url(since_token, payment_method_token, options = {})
68
+ options.each do |key, val|
69
+ options[key.to_sym] = val
70
+ end
71
+
72
+ params = []
73
+ params << "since_token=#{since_token}" if since_token
74
+ params << "count=#{options[:count]}" if options[:count]
75
+ params << "order=#{options[:order]}" if options[:order]
76
+ params << "state=#{options[:state]}" if options[:state]
77
+ param_string = "?#{params.join('&')}" if params.any?
78
+ return "#{base_url}/v1/transactions.xml#{param_string}" unless payment_method_token
64
79
 
65
- "#{base_url}/v1/payment_methods/#{payment_method_token}/transactions.xml#{since_param}"
80
+ "#{base_url}/v1/payment_methods/#{payment_method_token}/transactions.xml#{param_string}"
66
81
  end
67
82
 
68
83
  def list_payment_methods_url(since_token)
@@ -91,6 +106,10 @@ module Spreedly
91
106
  "#{base_url}/v1/receivers.xml"
92
107
  end
93
108
 
109
+ def redact_receiver_url(token)
110
+ "#{base_url}/v1/receivers/#{token}/redact.xml"
111
+ end
112
+
94
113
  def add_payment_method_url
95
114
  "#{base_url}/v1/payment_methods.xml"
96
115
  end
@@ -102,7 +121,5 @@ module Spreedly
102
121
  def deliver_to_receiver_url(receiver_token)
103
122
  "#{base_url}/v1/receivers/#{receiver_token}/deliver.xml"
104
123
  end
105
-
106
124
  end
107
-
108
125
  end
@@ -1,3 +1,3 @@
1
1
  module Spreedly
2
- VERSION = "2.0.18"
2
+ VERSION = "2.0.24"
3
3
  end
data/lib/spreedly.rb CHANGED
@@ -13,6 +13,8 @@ require 'spreedly/payment_methods/paypal'
13
13
  require 'spreedly/payment_methods/sprel'
14
14
  require 'spreedly/payment_methods/bank_account'
15
15
  require 'spreedly/payment_methods/third_party_token'
16
+ require 'spreedly/transactions/shipping_address'
17
+ require 'spreedly/transactions/response'
16
18
  require 'spreedly/transactions/transaction'
17
19
  require 'spreedly/transactions/gateway_transaction'
18
20
  require 'spreedly/transactions/add_payment_method'