solidus_stripe 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b92e606bb4ada8e49087a97ffeff9be982f8cc0110cd7c8c0721d73220adeb3c
4
- data.tar.gz: 6c0b61f704f0faab2e16ef827879e86efde9bf7123eadc7a968c7810452956bc
3
+ metadata.gz: ae346073816f937b18888261522168542afadcd9d00ab6350045707b8b11a380
4
+ data.tar.gz: 0fd2b4a1f79a3b50eb4c272fac0baeff4aa0a222ba98bf6d12c0d9d1910d1cc1
5
5
  SHA512:
6
- metadata.gz: 0daa283258eb4c1fb7dc0c41444e0e0ebaf8a439a91f7597d1ec4d941c9fd7badc0d043aec6a98e9b2c3e1bef131e4222d9bcc931c508546fee67b7d679a48ad
7
- data.tar.gz: f10627a842fff35f6ef69e7cfcf8643ec4e7fb961cab9f9f2aba28217068afd62babe3d6048396d781794457c3f0fa2bdbad278f2a8865a13b0a41ee4397dd94
6
+ metadata.gz: 7b744e67e2a22c606ce93d666750a810c09dd85d0d038a119445e7bd40faad6edda4ec68a741325e42cc97a334f3c10c5d742b61aeaf9e01911ad21e40412fed
7
+ data.tar.gz: ece237b20f84ad66a2688585de53bdaed4adf17317dd86c35d0788290a0221de22961283cf912b27da118400369d0634d45a768d2400f99a111458b38eb8c958
data/.circleci/config.yml CHANGED
@@ -1,20 +1,39 @@
1
1
  version: 2.1
2
2
 
3
3
  orbs:
4
+ # Required for feature specs.
5
+ browser-tools: circleci/browser-tools@1.1
6
+
4
7
  # Always take the latest version of the orb, this allows us to
5
8
  # run specs against Solidus supported versions only without the need
6
9
  # to change this configuration every time a Solidus version is released
7
10
  # or goes EOL.
8
11
  solidusio_extensions: solidusio/extensions@volatile
9
12
 
13
+ executors:
14
+ sqlite:
15
+ description: Run specs with an SQLite
16
+ docker:
17
+ - image: cimg/ruby:2.7-browsers
18
+ environment:
19
+ RAILS_ENV: test
20
+ DB: sqlite
21
+
10
22
  jobs:
11
23
  run-specs-with-postgres:
12
24
  executor: solidusio_extensions/postgres
13
25
  steps:
26
+ - browser-tools/install-chrome
14
27
  - solidusio_extensions/run-tests
15
28
  run-specs-with-mysql:
16
29
  executor: solidusio_extensions/mysql
17
30
  steps:
31
+ - browser-tools/install-chrome
32
+ - solidusio_extensions/run-tests
33
+ run-specs-with-sqlite:
34
+ executor: sqlite
35
+ steps:
36
+ - browser-tools/install-chrome
18
37
  - solidusio_extensions/run-tests
19
38
  lint-code:
20
39
  executor: solidusio_extensions/sqlite-memory
@@ -26,6 +45,8 @@ workflows:
26
45
  jobs:
27
46
  - run-specs-with-postgres
28
47
  - run-specs-with-mysql
48
+ - run-specs-with-sqlite
49
+ - lint-code
29
50
 
30
51
  "Weekly run specs against master":
31
52
  triggers:
data/.github/stale.yml CHANGED
@@ -1,17 +1 @@
1
- # Number of days of inactivity before an issue becomes stale
2
- daysUntilStale: 60
3
- # Number of days of inactivity before a stale issue is closed
4
- daysUntilClose: false
5
- # Issues with these labels will never be considered stale
6
- exemptLabels:
7
- - pinned
8
- - security
9
- # Label to use when marking an issue as stale
10
- staleLabel: stale
11
- # Comment to post when marking an issue as stale. Set to `false` to disable
12
- markComment: >
13
- This issue has been automatically marked as stale because it has not had
14
- recent activity. It might be closed if no further activity occurs. Thank you
15
- for your contributions.
16
- # Comment to post when closing a stale issue. Set to `false` to disable
17
- closeComment: false
1
+ _extends: .github
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  require:
2
4
  - solidus_dev_support/rubocop
3
5
 
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,298 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-08-30 14:09:43 UTC using RuboCop version 1.35.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/OrderedDependencies:
14
+ Exclude:
15
+ - 'solidus_stripe.gemspec'
16
+
17
+ # Offense count: 3
18
+ # This cop supports safe autocorrection (--autocorrect).
19
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
20
+ # SupportedStyles: with_first_argument, with_fixed_indentation
21
+ Layout/ArgumentAlignment:
22
+ Exclude:
23
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
24
+
25
+ # Offense count: 2
26
+ # This cop supports safe autocorrection (--autocorrect).
27
+ Layout/ClosingParenthesisIndentation:
28
+ Exclude:
29
+ - 'spec/requests/payment_requests_spec.rb'
30
+
31
+ # Offense count: 2
32
+ # This cop supports safe autocorrection (--autocorrect).
33
+ Layout/ElseAlignment:
34
+ Exclude:
35
+ - 'app/models/solidus_stripe/address_from_params_service.rb'
36
+ - 'spec/models/solidus_stripe/address_from_params_service_spec.rb'
37
+
38
+ # Offense count: 2
39
+ # This cop supports safe autocorrection (--autocorrect).
40
+ # Configuration parameters: EnforcedStyleAlignWith, Severity.
41
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
42
+ Layout/EndAlignment:
43
+ Exclude:
44
+ - 'app/models/solidus_stripe/address_from_params_service.rb'
45
+ - 'spec/models/solidus_stripe/address_from_params_service_spec.rb'
46
+
47
+ # Offense count: 2
48
+ # This cop supports safe autocorrection (--autocorrect).
49
+ # Configuration parameters: Width, AllowedPatterns, IgnoredPatterns.
50
+ Layout/IndentationWidth:
51
+ Exclude:
52
+ - 'app/models/solidus_stripe/address_from_params_service.rb'
53
+ - 'spec/models/solidus_stripe/address_from_params_service_spec.rb'
54
+
55
+ # Offense count: 2
56
+ # This cop supports safe autocorrection (--autocorrect).
57
+ # Configuration parameters: EnforcedStyle.
58
+ # SupportedStyles: symmetrical, new_line, same_line
59
+ Layout/MultilineMethodCallBraceLayout:
60
+ Exclude:
61
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
62
+
63
+ # Offense count: 1
64
+ # This cop supports safe autocorrection (--autocorrect).
65
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
66
+ # SupportedStyles: aligned, indented, indented_relative_to_receiver
67
+ Layout/MultilineMethodCallIndentation:
68
+ Exclude:
69
+ - 'spec/models/solidus_stripe/prepare_order_for_payment_service_spec.rb'
70
+
71
+ # Offense count: 1
72
+ # This cop supports safe autocorrection (--autocorrect).
73
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
74
+ # SupportedStyles: space, no_space, compact
75
+ # SupportedStylesForEmptyBrackets: space, no_space
76
+ Layout/SpaceInsideArrayLiteralBrackets:
77
+ Exclude:
78
+ - 'spec/models/solidus_stripe/address_from_params_service_spec.rb'
79
+
80
+ # Offense count: 5
81
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
82
+ Lint/AmbiguousBlockAssociation:
83
+ Exclude:
84
+ - 'spec/models/solidus_stripe/create_intents_payment_service_spec.rb'
85
+ - 'spec/models/solidus_stripe/prepare_order_for_payment_service_spec.rb'
86
+ - 'spec/requests/payment_requests_spec.rb'
87
+
88
+ # Offense count: 2
89
+ # This cop supports safe autocorrection (--autocorrect).
90
+ Lint/RedundantCopDisableDirective:
91
+ Exclude:
92
+ - 'bin/sandbox_rails'
93
+ - 'lib/generators/solidus_stripe/install/install_generator.rb'
94
+
95
+ # Offense count: 10
96
+ RSpec/AnyInstance:
97
+ Exclude:
98
+ - 'spec/models/solidus_stripe/create_intents_payment_service_spec.rb'
99
+ - 'spec/requests/payment_requests_spec.rb'
100
+
101
+ # Offense count: 6
102
+ # Configuration parameters: Prefixes.
103
+ # Prefixes: when, with, without
104
+ RSpec/ContextWording:
105
+ Exclude:
106
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
107
+
108
+ # Offense count: 8
109
+ # This cop supports unsafe autocorrection (--autocorrect-all).
110
+ # Configuration parameters: EnforcedStyle.
111
+ # SupportedStyles: method_call, block
112
+ RSpec/ExpectChange:
113
+ Exclude:
114
+ - 'spec/models/solidus_stripe/create_intents_payment_service_spec.rb'
115
+ - 'spec/models/solidus_stripe/prepare_order_for_payment_service_spec.rb'
116
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
117
+
118
+ # Offense count: 6
119
+ RSpec/ExpectInHook:
120
+ Exclude:
121
+ - 'spec/features/stripe_checkout_spec.rb'
122
+
123
+ # Offense count: 1
124
+ # This cop supports safe autocorrection (--autocorrect).
125
+ RSpec/LeadingSubject:
126
+ Exclude:
127
+ - 'spec/models/solidus_stripe/address_from_params_service_spec.rb'
128
+
129
+ # Offense count: 2
130
+ RSpec/LetSetup:
131
+ Exclude:
132
+ - 'spec/models/solidus_stripe/prepare_order_for_payment_service_spec.rb'
133
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
134
+
135
+ # Offense count: 9
136
+ # Configuration parameters: .
137
+ # SupportedStyles: have_received, receive
138
+ RSpec/MessageSpies:
139
+ EnforcedStyle: receive
140
+
141
+ # Offense count: 13
142
+ RSpec/MultipleExpectations:
143
+ Max: 15
144
+
145
+ # Offense count: 40
146
+ # Configuration parameters: AllowSubject.
147
+ RSpec/MultipleMemoizedHelpers:
148
+ Max: 11
149
+
150
+ # Offense count: 47
151
+ # Configuration parameters: IgnoreSharedExamples.
152
+ RSpec/NamedSubject:
153
+ Exclude:
154
+ - 'spec/models/solidus_stripe/address_from_params_service_spec.rb'
155
+ - 'spec/models/solidus_stripe/create_intents_payment_service_spec.rb'
156
+ - 'spec/models/solidus_stripe/prepare_order_for_payment_service_spec.rb'
157
+ - 'spec/models/solidus_stripe/shipping_rates_service_spec.rb'
158
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
159
+
160
+ # Offense count: 13
161
+ RSpec/NestedGroups:
162
+ Max: 5
163
+
164
+ # Offense count: 2
165
+ RSpec/RepeatedExampleGroupBody:
166
+ Exclude:
167
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
168
+
169
+ # Offense count: 3
170
+ # This cop supports safe autocorrection (--autocorrect).
171
+ # Configuration parameters: EnforcedStyle.
172
+ # SupportedStyles: and_return, block
173
+ RSpec/ReturnFromStub:
174
+ Exclude:
175
+ - 'spec/models/solidus_stripe/create_intents_payment_service_spec.rb'
176
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
177
+
178
+ # Offense count: 4
179
+ RSpec/StubbedMock:
180
+ Exclude:
181
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
182
+
183
+ # Offense count: 3
184
+ RSpec/SubjectStub:
185
+ Exclude:
186
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
187
+
188
+ # Offense count: 12
189
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
190
+ RSpec/VerifiedDoubles:
191
+ Exclude:
192
+ - 'spec/models/solidus_stripe/create_intents_payment_service_spec.rb'
193
+ - 'spec/models/solidus_stripe/prepare_order_for_payment_service_spec.rb'
194
+ - 'spec/models/spree/payment_method/stripe_credit_card_spec.rb'
195
+
196
+ # Offense count: 1
197
+ # This cop supports safe autocorrection (--autocorrect).
198
+ # Configuration parameters: EnforceForPrefixed.
199
+ Rails/Delegate:
200
+ Exclude:
201
+ - 'app/models/spree/payment_method/stripe_credit_card.rb'
202
+
203
+ # Offense count: 1
204
+ # This cop supports unsafe autocorrection (--autocorrect-all).
205
+ # Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers.
206
+ # Whitelist: find_by_sql
207
+ # AllowedMethods: find_by_sql
208
+ # AllowedReceivers: Gem::Specification
209
+ Rails/DynamicFindBy:
210
+ Exclude:
211
+ - 'app/models/solidus_stripe/address_from_params_service.rb'
212
+
213
+ # Offense count: 1
214
+ # This cop supports safe autocorrection (--autocorrect).
215
+ # Configuration parameters: Include, IgnoredMethods.
216
+ # Include: app/models/**/*.rb
217
+ # IgnoredMethods: order, limit, select, lock
218
+ Rails/FindEach:
219
+ Exclude:
220
+ - 'app/models/solidus_stripe/create_intents_payment_service.rb'
221
+
222
+ # Offense count: 5
223
+ # This cop supports unsafe autocorrection (--autocorrect-all).
224
+ # Configuration parameters: Include.
225
+ # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
226
+ Rails/Output:
227
+ Exclude:
228
+ - 'db/seeds.rb'
229
+
230
+ # Offense count: 3
231
+ # Configuration parameters: ForbiddenMethods, AllowedMethods.
232
+ # ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
233
+ Rails/SkipsModelValidations:
234
+ Exclude:
235
+ - 'db/migrate/20181010123508_update_stripe_payment_method_type_to_credit_card.rb'
236
+ - 'spec/models/solidus_stripe/shipping_rates_service_spec.rb'
237
+
238
+ # Offense count: 1
239
+ # This cop supports safe autocorrection (--autocorrect).
240
+ # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
241
+ # SupportedStyles: assign_to_condition, assign_inside_condition
242
+ Style/ConditionalAssignment:
243
+ Exclude:
244
+ - 'app/models/spree/payment_method/stripe_credit_card.rb'
245
+
246
+ # Offense count: 1
247
+ # This cop supports safe autocorrection (--autocorrect).
248
+ Style/ExplicitBlockArgument:
249
+ Exclude:
250
+ - 'spec/features/stripe_checkout_spec.rb'
251
+
252
+ # Offense count: 2
253
+ # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
254
+ Style/GuardClause:
255
+ Exclude:
256
+ - 'app/decorators/models/spree/order_update_attributes_decorator.rb'
257
+ - 'app/models/solidus_stripe/create_intents_payment_service.rb'
258
+
259
+ # Offense count: 1
260
+ # This cop supports safe autocorrection (--autocorrect).
261
+ Style/MultilineIfModifier:
262
+ Exclude:
263
+ - 'app/models/spree/payment_method/stripe_credit_card.rb'
264
+
265
+ # Offense count: 1
266
+ # This cop supports unsafe autocorrection (--autocorrect-all).
267
+ # Configuration parameters: EnforcedStyle.
268
+ # SupportedStyles: literals, strict
269
+ Style/MutableConstant:
270
+ Exclude:
271
+ - 'app/models/spree/payment_method/stripe_credit_card.rb'
272
+
273
+ # Offense count: 2
274
+ # This cop supports safe autocorrection (--autocorrect).
275
+ # Configuration parameters: AllowedMethods.
276
+ # AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with
277
+ Style/NestedParenthesizedCalls:
278
+ Exclude:
279
+ - 'lib/solidus_stripe/testing_support/card_input_helper.rb'
280
+
281
+ # Offense count: 1
282
+ # This cop supports safe autocorrection (--autocorrect).
283
+ Style/RedundantBegin:
284
+ Exclude:
285
+ - 'app/models/solidus_stripe/address_from_params_service.rb'
286
+
287
+ # Offense count: 1
288
+ # This cop supports unsafe autocorrection (--autocorrect-all).
289
+ Style/RedundantInterpolation:
290
+ Exclude:
291
+ - 'lib/solidus_stripe/testing_support/card_input_helper.rb'
292
+
293
+ # Offense count: 19
294
+ # This cop supports safe autocorrection (--autocorrect).
295
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
296
+ # URISchemes: http, https
297
+ Layout/LineLength:
298
+ Max: 163
data/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.4.0](https://github.com/solidusio/solidus_stripe/tree/v4.4.0) (2022-12-19)
4
+
5
+ [Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v4.3.0...v4.4.0)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Test issue, please disregard [\#145](https://github.com/solidusio/solidus_stripe/issues/145)
10
+ - Fix incorrect charge amount for currencies without fractions [\#138](https://github.com/solidusio/solidus_stripe/issues/138)
11
+ - ActionView::MissingTemplate in Spree::Checkout\#edit [\#127](https://github.com/solidusio/solidus_stripe/issues/127)
12
+
13
+ **Closed issues:**
14
+
15
+ - RFC: Overhauling solidus\_stripe [\#135](https://github.com/solidusio/solidus_stripe/issues/135)
16
+ - Initializer fails with uninitialized constant Spree::PaymentMethod [\#133](https://github.com/solidusio/solidus_stripe/issues/133)
17
+ - How to pass zip code when add a Credit Card [\#132](https://github.com/solidusio/solidus_stripe/issues/132)
18
+ - Undefined method `cvv\_path' [\#130](https://github.com/solidusio/solidus_stripe/issues/130)
19
+ - Javascript don't working after solidus\_stripe installation [\#126](https://github.com/solidusio/solidus_stripe/issues/126)
20
+ - Facing dependency issue after upgrade solidus 3 [\#114](https://github.com/solidusio/solidus_stripe/issues/114)
21
+ - New release for solidus 3 [\#113](https://github.com/solidusio/solidus_stripe/issues/113)
22
+ - How to specify API version [\#93](https://github.com/solidusio/solidus_stripe/issues/93)
23
+ - Consistency between README and Wiki [\#67](https://github.com/solidusio/solidus_stripe/issues/67)
24
+
25
+ **Merged pull requests:**
26
+
27
+ - Fix adding a new customer card in admin [\#144](https://github.com/solidusio/solidus_stripe/pull/144) ([elia](https://github.com/elia))
28
+ - Fix incorrect charge amount for currencies without fractions [\#139](https://github.com/solidusio/solidus_stripe/pull/139) ([cmbaldwin](https://github.com/cmbaldwin))
29
+ - Fix setup instructions for Rails 7 [\#136](https://github.com/solidusio/solidus_stripe/pull/136) ([diegomichel](https://github.com/diegomichel))
30
+ - Update stale bot to extend org-level config [\#134](https://github.com/solidusio/solidus_stripe/pull/134) ([gsmendoza](https://github.com/gsmendoza))
31
+ - Revert "Add back custom view paths that were mistakenly removed" [\#129](https://github.com/solidusio/solidus_stripe/pull/129) ([elia](https://github.com/elia))
32
+ - Add back custom view paths that were mistakenly removed [\#128](https://github.com/solidusio/solidus_stripe/pull/128) ([elia](https://github.com/elia))
33
+ - Fix the CI after the Solidus v3.2 release [\#125](https://github.com/solidusio/solidus_stripe/pull/125) ([elia](https://github.com/elia))
34
+ - Update to use forked solidus\_frontend when needed [\#124](https://github.com/solidusio/solidus_stripe/pull/124) ([waiting-for-dev](https://github.com/waiting-for-dev))
35
+ - Fix CI and tests on Rails 7 [\#123](https://github.com/solidusio/solidus_stripe/pull/123) ([waiting-for-dev](https://github.com/waiting-for-dev))
36
+
3
37
  ## [v4.3.0](https://github.com/solidusio/solidus_stripe/tree/v4.3.0) (2021-10-19)
4
38
 
5
39
  [Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v4.2.0...v4.3.0)
data/Gemfile CHANGED
@@ -6,6 +6,11 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
6
6
  branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
7
  gem 'solidus', github: 'solidusio/solidus', branch: branch
8
8
 
9
+ # The solidus_frontend gem has been pulled out since v3.2
10
+ if (branch == 'master') || (branch >= 'v3.2')
11
+ gem 'solidus_frontend', github: 'solidusio/solidus_frontend', branch: branch
12
+ end
13
+
9
14
  # Needed to help Bundler figure out how to resolve dependencies,
10
15
  # otherwise it takes forever to resolve them.
11
16
  # See https://github.com/bundler/bundler/issues/6677
@@ -14,7 +19,7 @@ gem 'rails', '>0.a'
14
19
  # Provides basic authentication functionality for testing parts of your engine
15
20
  gem 'solidus_auth_devise'
16
21
 
17
- case ENV['DB']
22
+ case ENV.fetch('DB', nil)
18
23
  when 'mysql'
19
24
  gem 'mysql2'
20
25
  when 'postgresql'
data/README.md CHANGED
@@ -5,10 +5,8 @@
5
5
 
6
6
  Stripe Payment Method for Solidus. It works as a wrapper for the ActiveMerchant Stripe gateway.
7
7
 
8
- ---
8
+ ## Installation
9
9
 
10
- Installation
11
- ------------
12
10
 
13
11
  Run from the command line:
14
12
 
@@ -38,11 +36,8 @@ variables you can create the following static configuration:
38
36
 
39
37
  ```ruby
40
38
  # config/initializers/spree.rb
41
-
42
- Spree.config do |config|
43
- # ...
44
-
45
- config.static_model_preferences.add(
39
+ Rails.application.config.to_prepare do
40
+ Spree::Config.static_model_preferences.add(
46
41
  Spree::PaymentMethod::StripeCreditCard,
47
42
  'stripe_env_credentials',
48
43
  secret_key: ENV['STRIPE_SECRET_KEY'],
@@ -277,10 +272,17 @@ bundle exec rubocop
277
272
  ```
278
273
 
279
274
  When testing your application's integration with this extension you may use its factories.
280
- Simply add this require statement to your spec_helper:
275
+ Simply add this require statement to your `spec/spec_helper.rb`:
276
+
277
+ ```ruby
278
+ require 'solidus_stripe/testing_support/factories'
279
+ ```
280
+
281
+ Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
282
+ factories along with this extension's factories using this statement:
281
283
 
282
284
  ```ruby
283
- require '<%= file_name %>/factories'
285
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusStripe::Engine)
284
286
  ```
285
287
 
286
288
  ### Running the sandbox
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Don't build a dummy app with solidus_bolt enabled
4
+ ENV['SKIP_SOLIDUS_BOLT'] = 'true'
5
+
3
6
  require 'solidus_dev_support/rake_tasks'
4
7
  SolidusDevSupport::RakeTasks.install
5
8
 
@@ -19,7 +19,7 @@ module SolidusStripe
19
19
  if create_payment_service.call
20
20
  render json: { success: true }
21
21
  else
22
- render json: { error: "Could not create payment" }, status: 500
22
+ render json: { error: "Could not create payment" }, status: :internal_server_error
23
23
  end
24
24
  end
25
25
 
@@ -45,7 +45,7 @@ module SolidusStripe
45
45
  stripe_payment_intent_id: response['id']
46
46
  }
47
47
  else
48
- render json: { error: response['error']['message'] }, status: 500
48
+ render json: { error: response['error']['message'] }, status: :internal_server_error
49
49
  end
50
50
  end
51
51
 
@@ -14,7 +14,7 @@ module SolidusStripe
14
14
  if rates.any?
15
15
  render json: { success: true, shipping_rates: rates }
16
16
  else
17
- render json: { success: false, error: 'No shipping method available for that address' }, status: 500
17
+ render json: { success: false, error: 'No shipping method available for that address' }, status: :internal_server_error
18
18
  end
19
19
  end
20
20
 
@@ -32,10 +32,10 @@ module SolidusStripe
32
32
  if current_order.payment?
33
33
  render json: { success: true }
34
34
  else
35
- render json: { success: false, error: 'Order not ready for payment. Try manual checkout.' }, status: 500
35
+ render json: { success: false, error: 'Order not ready for payment. Try manual checkout.' }, status: :internal_server_error
36
36
  end
37
37
  else
38
- render json: { success: false, error: address.errors.full_messages.to_sentence }, status: 500
38
+ render json: { success: false, error: address.errors.full_messages.to_sentence }, status: :internal_server_error
39
39
  end
40
40
  end
41
41
 
@@ -61,20 +61,29 @@ module Spree
61
61
  true
62
62
  end
63
63
 
64
+ def non_fractional_money(money, currency)
65
+ amount = money.is_a?(Integer) ? money : money.cents
66
+ Spree::Money.new((amount * 100), { currency: currency })
67
+ end
68
+
69
+ def localize(money, currency)
70
+ ActiveMerchant::Billing::Gateway.currencies_without_fractions.include?(currency) ? non_fractional_money(money, currency) : money
71
+ end
72
+
64
73
  def purchase(money, creditcard, transaction_options)
65
- gateway.purchase(*options_for_purchase_or_auth(money, creditcard, transaction_options))
74
+ gateway.purchase(*options_for_purchase_or_auth(localize(money, transaction_options[:currency]), creditcard, transaction_options))
66
75
  end
67
76
 
68
77
  def authorize(money, creditcard, transaction_options)
69
- gateway.authorize(*options_for_purchase_or_auth(money, creditcard, transaction_options))
78
+ gateway.authorize(*options_for_purchase_or_auth(localize(money, transaction_options[:currency]), creditcard, transaction_options))
70
79
  end
71
80
 
72
81
  def capture(money, response_code, transaction_options)
73
- gateway.capture(money, response_code, transaction_options)
82
+ gateway.capture(localize(money, transaction_options[:currency]), response_code, transaction_options)
74
83
  end
75
84
 
76
- def credit(money, _creditcard, response_code, _transaction_options)
77
- gateway.refund(money, response_code, {})
85
+ def credit(money, _creditcard, response_code, transaction_options)
86
+ gateway.refund(localize(money, transaction_options[:currency]), response_code, {})
78
87
  end
79
88
 
80
89
  def void(response_code, _creditcard, _transaction_options)
@@ -112,7 +121,7 @@ module Spree
112
121
  }.merge! address_for(payment)
113
122
 
114
123
  source = update_source!(payment.source)
115
- if source.number.blank? && source.gateway_payment_profile_id.present?
124
+ if reuse_existing_source?(source)
116
125
  if v3_intents?
117
126
  creditcard = ActiveMerchant::Billing::StripeGateway::StripePaymentToken.new('id' => source.gateway_payment_profile_id)
118
127
  else
@@ -124,7 +133,7 @@ module Spree
124
133
 
125
134
  response = gateway.store(creditcard, options)
126
135
  if response.success?
127
- if v3_intents?
136
+ if v3_intents? && reuse_existing_source?(source)
128
137
  payment.source.update!(
129
138
  cc_type: payment.source.cc_type,
130
139
  gateway_customer_profile_id: response.params['customer'],
@@ -212,6 +221,10 @@ module Spree
212
221
 
213
222
  refund
214
223
  end
224
+
225
+ def reuse_existing_source?(source)
226
+ source.number.blank? && source.gateway_payment_profile_id.present?
227
+ end
215
228
  end
216
229
  end
217
230
  end
data/bin/sandbox CHANGED
@@ -67,7 +67,7 @@ unbundled bundle install --gemfile Gemfile
67
67
 
68
68
  unbundled bundle exec rake db:drop db:create
69
69
 
70
- unbundled bundle exec rails generate spree:install \
70
+ unbundled bundle exec rails generate solidus:install \
71
71
  --auto-accept \
72
72
  --user_class=Spree::User \
73
73
  --enforce_available_locales=true \
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SolidusStripe
4
4
  class Configuration
5
- # Define here the settings for this extensions, e.g.:
5
+ # Define here the settings for this extension, e.g.:
6
6
  #
7
7
  # attr_accessor :my_setting
8
8
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusStripe
4
- VERSION = '4.3.0'
4
+ VERSION = '4.4.0'
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_stripe'
18
18
  spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_stripe/blob/master/CHANGELOG.md'
19
19
 
20
- spec.required_ruby_version = '>= 2.4.0'
20
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'solidus_core', ['>= 2.3', '< 4']
33
33
  spec.add_dependency 'solidus_support', '~> 0.8'
34
34
  spec.add_dependency 'activemerchant', '>= 1.105'
35
+ spec.add_dependency 'rexml'
35
36
 
36
- spec.add_development_dependency 'solidus_dev_support', '~> 2.3'
37
+ spec.add_development_dependency 'solidus_dev_support', '~> 2.5'
37
38
  end
@@ -266,7 +266,7 @@ RSpec.describe "Stripe checkout", type: :feature do
266
266
  end
267
267
 
268
268
  page.accept_alert do
269
- find('input[value="Cancel"]').click
269
+ click_on "Cancel"
270
270
  end
271
271
 
272
272
  expect(page).to have_content "Order canceled"
@@ -315,14 +315,14 @@ RSpec.describe "Stripe checkout", type: :feature do
315
315
  click_button 'Complete authentication'
316
316
  end
317
317
 
318
- expect(page).to have_content "Your card was declined."
318
+ expect(page).to have_content "Your card has been declined."
319
319
  end
320
320
  end
321
321
 
322
322
  context "when reusing a card" do
323
323
  stub_authorization!
324
324
 
325
- it "succesfully creates a second payment that can be captured in the backend" do
325
+ it "successfully creates a second payment that can be captured in the backend" do
326
326
  authenticate_3d_secure_card(card_3d_secure)
327
327
 
328
328
  expect(page).to have_current_path("/checkout/confirm")
@@ -388,7 +388,7 @@ RSpec.describe "Stripe checkout", type: :feature do
388
388
  end
389
389
 
390
390
  page.accept_alert do
391
- find('input[value="Cancel"]').click
391
+ click_on "Cancel"
392
392
  end
393
393
 
394
394
  expect(page).to have_content "Order canceled"
@@ -26,12 +26,12 @@ RSpec.describe SolidusStripe::CreateIntentsPaymentService do
26
26
  stripe_payment_intent_id: intent_id,
27
27
  form_data: {
28
28
  addressLine: ["31 Cotton Rd"],
29
- city: "San Diego",
30
- country: "US",
29
+ city: order.bill_address.city,
30
+ country: order.bill_address.country.iso,
31
+ region: order.bill_address.state.abbr,
31
32
  phone: "+188836412312",
32
33
  postalCode: "12345",
33
34
  recipient: "James Edwards",
34
- region: "CA"
35
35
  }
36
36
  }
37
37
  end
@@ -171,6 +171,16 @@ describe Spree::PaymentMethod::StripeCreditCard do
171
171
  end
172
172
  end
173
173
 
174
+ context 'purchasing with fractionless currency' do
175
+ after do
176
+ subject.purchase(1999, 'credit card', { currency: 'JPY' })
177
+ end
178
+
179
+ it 'send the payment to the gateway' do
180
+ expect(gateway).to receive(:purchase).with('money', 'cc', 'opts')
181
+ end
182
+ end
183
+
174
184
  context 'authorizing' do
175
185
  after do
176
186
  subject.authorize(19.99, 'credit card', {})
@@ -181,6 +191,16 @@ describe Spree::PaymentMethod::StripeCreditCard do
181
191
  end
182
192
  end
183
193
 
194
+ context 'authorizing with fractionless currency' do
195
+ after do
196
+ subject.authorize(1999, 'credit card', { currency: 'JPY' })
197
+ end
198
+
199
+ it 'send the authorization to the gateway' do
200
+ expect(gateway).to receive(:authorize).with('money', 'cc', 'opts')
201
+ end
202
+ end
203
+
184
204
  context 'capturing' do
185
205
  after do
186
206
  subject.capture(1234, 'response_code', {})
@@ -195,6 +215,20 @@ describe Spree::PaymentMethod::StripeCreditCard do
195
215
  end
196
216
  end
197
217
 
218
+ context 'capturing with fractionless currency' do
219
+ after do
220
+ subject.capture(1234, 'response_code', { currency: 'JPY' })
221
+ end
222
+
223
+ it 'amount not converted to cents' do
224
+ expect(gateway).to receive(:capture).with(Spree::Money.new(123_400, { currency: 'JPY' }), anything, anything)
225
+ end
226
+
227
+ it 'use the response code as the authorization' do
228
+ expect(gateway).to receive(:capture).with(anything, 'response_code', anything)
229
+ end
230
+ end
231
+
198
232
  context 'capture with payment class' do
199
233
  let(:payment_method) do
200
234
  payment_method = described_class.new(active: true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-19 00:00:00.000000000 Z
11
+ date: 2022-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -58,20 +58,34 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.105'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rexml
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: solidus_dev_support
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: '2.3'
81
+ version: '2.5'
68
82
  type: :development
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: '2.3'
88
+ version: '2.5'
75
89
  description: Stripe Payment Method for Solidus
76
90
  email: contact@solidus.io
77
91
  executables: []
@@ -85,6 +99,7 @@ files:
85
99
  - ".gitignore"
86
100
  - ".rspec"
87
101
  - ".rubocop.yml"
102
+ - ".rubocop_todo.yml"
88
103
  - ".travis.yml"
89
104
  - CHANGELOG.md
90
105
  - Gemfile
@@ -168,14 +183,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
183
  requirements:
169
184
  - - ">="
170
185
  - !ruby/object:Gem::Version
171
- version: 2.4.0
186
+ version: '2.5'
172
187
  required_rubygems_version: !ruby/object:Gem::Requirement
173
188
  requirements:
174
189
  - - ">="
175
190
  - !ruby/object:Gem::Version
176
191
  version: '0'
177
192
  requirements: []
178
- rubygems_version: 3.2.20
193
+ rubygems_version: 3.3.26
179
194
  signing_key:
180
195
  specification_version: 4
181
196
  summary: Stripe Payment Method for Solidus