solidus_stripe 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +6 -2
- data/Gemfile +7 -0
- data/LICENSE +2 -2
- data/README.md +4 -5
- data/Rakefile +1 -1
- data/app/controllers/solidus_stripe/intents_controller.rb +1 -7
- data/app/decorators/models/spree/refund_decorator.rb +9 -0
- data/app/models/solidus_stripe/address_from_params_service.rb +4 -1
- data/app/models/solidus_stripe/create_intents_payment_service.rb +17 -5
- data/app/models/spree/payment_method/stripe_credit_card.rb +15 -0
- data/bin/r +13 -0
- data/bin/rake +7 -0
- data/bin/sandbox +84 -0
- data/bin/sandbox_rails +18 -0
- data/bin/setup +1 -1
- data/config/routes.rb +2 -0
- data/lib/generators/solidus_stripe/install/install_generator.rb +7 -3
- data/lib/solidus_stripe/engine.rb +1 -1
- data/lib/solidus_stripe/factories.rb +4 -0
- data/lib/solidus_stripe/version.rb +1 -1
- data/lib/views/frontend/spree/checkout/payment/v3/_form_elements.html.erb +0 -1
- data/solidus_stripe.gemspec +34 -37
- data/spec/features/stripe_checkout_spec.rb +22 -4
- data/spec/models/solidus_stripe/address_from_params_service_spec.rb +19 -5
- data/spec/models/solidus_stripe/create_intents_payment_service_spec.rb +16 -0
- data/spec/models/spree/payment_method/stripe_credit_card_spec.rb +44 -1
- data/spec/spec_helper.rb +4 -1
- metadata +16 -12
- data/LICENSE.md +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c27f15c92bf2fcee8f467f66e8c1c261baf7d0909f86e7df87e8ce9547cc2951
|
4
|
+
data.tar.gz: b6ae23186cd51fc4b7938081d26df066a1b45903a3fcbb29db39d83106e520e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 799216217f0bf2353e94c598dc9e49187c44004f9c25dc254d13a3e5805751e8fddabaf45f83c3cc422ed561b12d0e7260cf4367d71dd614086c4d9f2d2521c6
|
7
|
+
data.tar.gz: 322e5c0299a3afc1555057cd10685a1f5c6ad3f446dd592326084be7959e93c009cb092f8d9fe688682527653d7078ec58c49506ba593f4b4b688d8fa81a549e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,23 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v4.0.0](https://github.com/solidusio/solidus_stripe/tree/v4.0.0) (2020-04-29)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v3.0.0...
|
5
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v3.0.0...v4.0.0)
|
6
6
|
|
7
7
|
**Fixed bugs:**
|
8
8
|
|
9
9
|
- Duplicates charges with Payment Intents [\#44](https://github.com/solidusio/solidus_stripe/issues/44)
|
10
|
+
- Fix for 3D-Secure payments on cart page checkout [\#49](https://github.com/solidusio/solidus_stripe/pull/49) ([spaghetticode](https://github.com/spaghetticode))
|
10
11
|
- Send form data also when paying with payment request button [\#47](https://github.com/solidusio/solidus_stripe/pull/47) ([spaghetticode](https://github.com/spaghetticode))
|
11
12
|
- Create a single charge when using Stripe Payment Intents [\#45](https://github.com/solidusio/solidus_stripe/pull/45) ([spaghetticode](https://github.com/spaghetticode))
|
12
13
|
|
13
14
|
**Closed issues:**
|
14
15
|
|
16
|
+
- Custom stripe element field options \(e.g for showing a credit card icon\) [\#41](https://github.com/solidusio/solidus_stripe/issues/41)
|
15
17
|
- Stripe Elements submit button stuck in disabled state. [\#39](https://github.com/solidusio/solidus_stripe/issues/39)
|
16
18
|
- Visa credit card type is blank [\#36](https://github.com/solidusio/solidus_stripe/issues/36)
|
17
19
|
- Pay with Apple Pay from cart page [\#23](https://github.com/solidusio/solidus_stripe/issues/23)
|
20
|
+
- Clearer documentation on how to implement [\#15](https://github.com/solidusio/solidus_stripe/issues/15)
|
18
21
|
|
19
22
|
**Merged pull requests:**
|
20
23
|
|
24
|
+
- Relax solidus\_support dependency [\#48](https://github.com/solidusio/solidus_stripe/pull/48) ([kennyadsl](https://github.com/kennyadsl))
|
21
25
|
- Replace deprecated route `/stripe/confirm\_payment` [\#46](https://github.com/solidusio/solidus_stripe/pull/46) ([spaghetticode](https://github.com/spaghetticode))
|
22
26
|
- Custom Stripe Elements field options [\#42](https://github.com/solidusio/solidus_stripe/pull/42) ([stuffmatic](https://github.com/stuffmatic))
|
23
27
|
- Improve the way Stripe Elements validation errors are displayed [\#40](https://github.com/solidusio/solidus_stripe/pull/40) ([stuffmatic](https://github.com/stuffmatic))
|
data/Gemfile
CHANGED
@@ -30,3 +30,10 @@ group :development, :test do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
gemspec
|
33
|
+
|
34
|
+
# Use a local Gemfile to include development dependencies that might not be
|
35
|
+
# relevant for the project or for other contributors, e.g. pry-byebug.
|
36
|
+
#
|
37
|
+
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
38
|
+
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
39
|
+
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2014 Spree Commerce Inc. and other contributors.
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification,
|
@@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
|
|
9
9
|
* Redistributions in binary form must reproduce the above copyright notice,
|
10
10
|
this list of conditions and the following disclaimer in the documentation
|
11
11
|
and/or other materials provided with the distribution.
|
12
|
-
* Neither the name
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
13
|
endorse or promote products derived from this software without specific
|
14
14
|
prior written permission.
|
15
15
|
|
data/README.md
CHANGED
@@ -138,14 +138,11 @@ Stripe account to receive payments via Apple Pay.
|
|
138
138
|
It's possible to pay with Apple Pay and Google Pay directly from the cart
|
139
139
|
page. The functionality is self-contained in the view partial
|
140
140
|
`_stripe_payment_request_button.html.erb`. In order to use it, you need
|
141
|
-
to
|
141
|
+
to render that partial in the `orders#edit` frontend page, and pass it the
|
142
142
|
payment method configured for Stripe via the local variable
|
143
|
-
`cart_checkout_payment_method
|
143
|
+
`cart_checkout_payment_method`:
|
144
144
|
|
145
145
|
```ruby
|
146
|
-
# app/overrides/spree/orders/edit/add_payment_request_button.html.erb.deface
|
147
|
-
|
148
|
-
<!-- insert_after '[data-hook="cart_container"]' -->
|
149
146
|
<%= render 'stripe_payment_request_button', cart_checkout_payment_method: Spree::PaymentMethod::StripeCreditCard.first %>
|
150
147
|
```
|
151
148
|
|
@@ -313,3 +310,5 @@ gem bump --version minor --remote upstream
|
|
313
310
|
gem tag --remote upstream
|
314
311
|
gem release
|
315
312
|
```
|
313
|
+
|
314
|
+
Copyright (c) 2020 Spree Commerce Inc., released under the New BSD License
|
data/Rakefile
CHANGED
@@ -5,13 +5,7 @@ module SolidusStripe
|
|
5
5
|
include Spree::Core::ControllerHelpers::Order
|
6
6
|
|
7
7
|
def create_intent
|
8
|
-
|
9
|
-
@intent = create_payment_intent
|
10
|
-
rescue Stripe::CardError => e
|
11
|
-
render json: { error: e.message }, status: 500
|
12
|
-
return
|
13
|
-
end
|
14
|
-
|
8
|
+
@intent = create_payment_intent
|
15
9
|
generate_payment_response
|
16
10
|
end
|
17
11
|
|
@@ -43,7 +43,10 @@ module SolidusStripe
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def state
|
46
|
-
@state ||=
|
46
|
+
@state ||= begin
|
47
|
+
region = address_params[:region]
|
48
|
+
country.states.find_by(abbr: region) || country.states.find_by(name: region)
|
49
|
+
end
|
47
50
|
end
|
48
51
|
|
49
52
|
def default_attributes
|
@@ -61,7 +61,7 @@ module SolidusStripe
|
|
61
61
|
cc_type: intent_card['brand'],
|
62
62
|
last_digits: intent_card['last4'],
|
63
63
|
gateway_payment_profile_id: intent_customer_profile,
|
64
|
-
name: address_full_name,
|
64
|
+
name: card_holder_name || address_full_name,
|
65
65
|
address_attributes: address_attributes
|
66
66
|
}
|
67
67
|
}]
|
@@ -69,26 +69,38 @@ module SolidusStripe
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def intent_card
|
72
|
-
|
72
|
+
intent_data['payment_method_details']['card']
|
73
73
|
end
|
74
74
|
|
75
75
|
def intent_customer_profile
|
76
76
|
intent.params['payment_method']
|
77
77
|
end
|
78
78
|
|
79
|
+
def card_holder_name
|
80
|
+
(html_payment_source_data['name'] || intent_data['billing_details']['name']).presence
|
81
|
+
end
|
82
|
+
|
83
|
+
def intent_data
|
84
|
+
intent.params['charges']['data'][0]
|
85
|
+
end
|
86
|
+
|
79
87
|
def form_data
|
80
88
|
params[:form_data]
|
81
89
|
end
|
82
90
|
|
83
|
-
def
|
91
|
+
def html_payment_source_data
|
84
92
|
if form_data.is_a?(String)
|
85
93
|
data = Rack::Utils.parse_nested_query(form_data)
|
86
|
-
data['payment_source'][stripe.id.to_s]
|
94
|
+
data['payment_source'][stripe.id.to_s]
|
87
95
|
else
|
88
|
-
|
96
|
+
{}
|
89
97
|
end
|
90
98
|
end
|
91
99
|
|
100
|
+
def address_attributes
|
101
|
+
html_payment_source_data['address_attributes'] || SolidusStripe::AddressFromParamsService.new(form_data).call.attributes
|
102
|
+
end
|
103
|
+
|
92
104
|
def address_full_name
|
93
105
|
current_order.bill_address&.full_name || form_data[:recipient]
|
94
106
|
end
|
@@ -81,6 +81,21 @@ module Spree
|
|
81
81
|
gateway.void(response_code, {})
|
82
82
|
end
|
83
83
|
|
84
|
+
def payment_intents_refund_reason
|
85
|
+
Spree::RefundReason.where(name: Spree::Payment::Cancellation::DEFAULT_REASON).first_or_create
|
86
|
+
end
|
87
|
+
|
88
|
+
def try_void(payment)
|
89
|
+
if v3_intents? && payment.completed?
|
90
|
+
payment.refunds.create!(
|
91
|
+
amount: payment.credit_allowed,
|
92
|
+
reason: payment_intents_refund_reason
|
93
|
+
).response
|
94
|
+
else
|
95
|
+
payment.void_transaction!
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
84
99
|
def cancel(response_code)
|
85
100
|
gateway.void(response_code, {})
|
86
101
|
end
|
data/bin/r
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path('../lib/solidus_stripe/engine', __dir__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
11
|
+
|
12
|
+
require 'rails/all'
|
13
|
+
require 'rails/engine/commands'
|
data/bin/rake
ADDED
data/bin/sandbox
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
case "$DB" in
|
6
|
+
postgres|postgresql)
|
7
|
+
RAILSDB="postgresql"
|
8
|
+
;;
|
9
|
+
mysql)
|
10
|
+
RAILSDB="mysql"
|
11
|
+
;;
|
12
|
+
sqlite|'')
|
13
|
+
RAILSDB="sqlite3"
|
14
|
+
;;
|
15
|
+
*)
|
16
|
+
echo "Invalid DB specified: $DB"
|
17
|
+
exit 1
|
18
|
+
;;
|
19
|
+
esac
|
20
|
+
|
21
|
+
if [ ! -z $SOLIDUS_BRANCH ]
|
22
|
+
then
|
23
|
+
BRANCH=$SOLIDUS_BRANCH
|
24
|
+
else
|
25
|
+
BRANCH="master"
|
26
|
+
fi
|
27
|
+
|
28
|
+
extension_name="solidus_stripe"
|
29
|
+
|
30
|
+
# Stay away from the bundler env of the containing extension.
|
31
|
+
function unbundled {
|
32
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
|
33
|
+
}
|
34
|
+
|
35
|
+
rm -rf ./sandbox
|
36
|
+
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
|
37
|
+
--skip-bundle \
|
38
|
+
--skip-git \
|
39
|
+
--skip-keeps \
|
40
|
+
--skip-rc \
|
41
|
+
--skip-spring \
|
42
|
+
--skip-test \
|
43
|
+
--skip-javascript
|
44
|
+
|
45
|
+
if [ ! -d "sandbox" ]; then
|
46
|
+
echo 'sandbox rails application failed'
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
|
50
|
+
cd ./sandbox
|
51
|
+
cat <<RUBY >> Gemfile
|
52
|
+
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
|
53
|
+
gem 'solidus_auth_devise', '>= 2.1.0'
|
54
|
+
gem 'rails-i18n'
|
55
|
+
gem 'solidus_i18n'
|
56
|
+
|
57
|
+
gem '$extension_name', path: '..'
|
58
|
+
|
59
|
+
group :test, :development do
|
60
|
+
platforms :mri do
|
61
|
+
gem 'pry-byebug'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
RUBY
|
65
|
+
|
66
|
+
unbundled bundle install --gemfile Gemfile
|
67
|
+
|
68
|
+
unbundled bundle exec rake db:drop db:create
|
69
|
+
|
70
|
+
unbundled bundle exec rails generate spree:install \
|
71
|
+
--auto-accept \
|
72
|
+
--user_class=Spree::User \
|
73
|
+
--enforce_available_locales=true \
|
74
|
+
--with-authentication=false \
|
75
|
+
$@
|
76
|
+
|
77
|
+
unbundled bundle exec rails generate solidus:auth:install
|
78
|
+
|
79
|
+
echo
|
80
|
+
echo "🚀 Sandbox app successfully created for $extension_name!"
|
81
|
+
echo "🚀 Using $RAILSDB and Solidus $BRANCH"
|
82
|
+
echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
|
83
|
+
echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
|
84
|
+
echo "🚀 This app is intended for test purposes."
|
data/bin/sandbox_rails
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
app_root = 'sandbox'
|
6
|
+
|
7
|
+
unless File.exist? "#{app_root}/bin/rails"
|
8
|
+
warn 'Creating the sandbox app...'
|
9
|
+
Dir.chdir "#{__dir__}/.." do
|
10
|
+
system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
|
11
|
+
warn 'Automatic creation of the sandbox app failed'
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.chdir app_root
|
18
|
+
exec 'bin/rails', *ARGV
|
data/bin/setup
CHANGED
data/config/routes.rb
CHANGED
@@ -13,12 +13,16 @@ module SolidusStripe
|
|
13
13
|
run 'bundle exec rake railties:install:migrations FROM=solidus_stripe'
|
14
14
|
end
|
15
15
|
|
16
|
+
def add_migrations
|
17
|
+
run 'bin/rails railties:install:migrations FROM=solidus_stripe'
|
18
|
+
end
|
19
|
+
|
16
20
|
def run_migrations
|
17
|
-
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
21
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Metrics/LineLength
|
18
22
|
if run_migrations
|
19
|
-
run '
|
23
|
+
run 'bin/rails db:migrate'
|
20
24
|
else
|
21
|
-
puts 'Skipping
|
25
|
+
puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
<div id="payment-request-button" data-stripe-config="<%= payment_method.stripe_config(current_order).to_json %>" data-v3-api="<%= stripe_v3_api %>"></div>
|
2
2
|
|
3
|
-
<%= image_tag 'credit_cards/credit_card.gif', id: 'credit-card-image' %>
|
4
3
|
<% param_prefix = "payment_source[#{payment_method.id}]" %>
|
5
4
|
|
6
5
|
<div class="field field-required">
|
data/solidus_stripe.gemspec
CHANGED
@@ -1,40 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
s.add_dependency "activemerchant", ">= 1.100" # includes "Stripe Payment Intents: Fix fallback for Store"
|
38
|
-
|
39
|
-
s.add_development_dependency 'solidus_dev_support'
|
3
|
+
require_relative 'lib/solidus_stripe/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'solidus_stripe'
|
7
|
+
spec.version = SolidusStripe::VERSION
|
8
|
+
spec.authors = ['Solidus Team']
|
9
|
+
spec.email = 'contact@solidus.io'
|
10
|
+
|
11
|
+
spec.summary = 'Stripe Payment Method for Solidus'
|
12
|
+
spec.description = 'Stripe Payment Method for Solidus'
|
13
|
+
spec.homepage = 'https://github.com/solidusio/solidus_stripe#readme'
|
14
|
+
spec.license = 'BSD-3'
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_stripe'
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_stripe/blob/master/CHANGELOG.md'
|
19
|
+
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.4')
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
25
|
+
|
26
|
+
spec.files = files.grep_v(%r{^(test|spec|features)/})
|
27
|
+
spec.test_files = files.grep(%r{^(test|spec|features)/})
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency 'solidus_core', ['>= 2.3', '< 3']
|
33
|
+
spec.add_dependency 'solidus_support', '~> 0.5'
|
34
|
+
spec.add_dependency 'activemerchant', '>= 1.100'
|
35
|
+
|
36
|
+
spec.add_development_dependency 'solidus_dev_support'
|
40
37
|
end
|
@@ -217,7 +217,7 @@ RSpec.describe "Stripe checkout", type: :feature do
|
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
|
-
context 'when using Stripe V3 API
|
220
|
+
context 'when using Stripe V3 API library with Elements', :js do
|
221
221
|
let(:preferred_v3_elements) { true }
|
222
222
|
let(:preferred_v3_intents) { false }
|
223
223
|
|
@@ -293,7 +293,7 @@ RSpec.describe "Stripe checkout", type: :feature do
|
|
293
293
|
it_behaves_like "Stripe Elements invalid payments"
|
294
294
|
end
|
295
295
|
|
296
|
-
context "when using Stripe V3 API
|
296
|
+
context "when using Stripe V3 API library with Intents", :js do
|
297
297
|
let(:preferred_v3_elements) { false }
|
298
298
|
let(:preferred_v3_intents) { true }
|
299
299
|
|
@@ -400,8 +400,9 @@ RSpec.describe "Stripe checkout", type: :feature do
|
|
400
400
|
click_button "Place Order"
|
401
401
|
expect(page).to have_content("Your order has been processed successfully")
|
402
402
|
|
403
|
-
# Capture in backend
|
404
403
|
Spree::Order.complete.each do |order|
|
404
|
+
# Capture in backend
|
405
|
+
|
405
406
|
visit spree.admin_path
|
406
407
|
|
407
408
|
expect(page).to have_selector("#listing_orders tbody tr", count: 2)
|
@@ -413,6 +414,21 @@ RSpec.describe "Stripe checkout", type: :feature do
|
|
413
414
|
|
414
415
|
expect(page).to have_content "Payment Updated"
|
415
416
|
expect(find("table#payments")).to have_content "Completed"
|
417
|
+
|
418
|
+
# Order cancel, after capture
|
419
|
+
click_link "Cart"
|
420
|
+
|
421
|
+
within "#sidebar" do
|
422
|
+
expect(page).to have_content "Completed"
|
423
|
+
end
|
424
|
+
|
425
|
+
find('input[value="Cancel"]').click
|
426
|
+
|
427
|
+
expect(page).to have_content "Order canceled"
|
428
|
+
|
429
|
+
within "#sidebar" do
|
430
|
+
expect(page).to have_content "Canceled"
|
431
|
+
end
|
416
432
|
end
|
417
433
|
end
|
418
434
|
end
|
@@ -489,7 +505,9 @@ RSpec.describe "Stripe checkout", type: :feature do
|
|
489
505
|
def within_3d_secure_modal
|
490
506
|
within_frame "__privateStripeFrame11" do
|
491
507
|
within_frame "__stripeJSChallengeFrame" do
|
492
|
-
|
508
|
+
within_frame "acsFrame" do
|
509
|
+
yield
|
510
|
+
end
|
493
511
|
end
|
494
512
|
end
|
495
513
|
end
|
@@ -14,7 +14,8 @@ RSpec.describe SolidusStripe::AddressFromParamsService do
|
|
14
14
|
recipient: 'Clark Kent',
|
15
15
|
city: 'Metropolis',
|
16
16
|
postalCode: '12345',
|
17
|
-
addressLine: [ '12, Lincoln Rd']
|
17
|
+
addressLine: [ '12, Lincoln Rd'],
|
18
|
+
phone: '555-555-0199'
|
18
19
|
}
|
19
20
|
end
|
20
21
|
|
@@ -39,7 +40,8 @@ RSpec.describe SolidusStripe::AddressFromParamsService do
|
|
39
40
|
firstname: 'Clark',
|
40
41
|
lastname: 'Kent',
|
41
42
|
address1: params[:addressLine].first,
|
42
|
-
address2: nil
|
43
|
+
address2: nil,
|
44
|
+
phone: '555-555-0199'
|
43
45
|
)
|
44
46
|
end
|
45
47
|
|
@@ -50,11 +52,23 @@ RSpec.describe SolidusStripe::AddressFromParamsService do
|
|
50
52
|
|
51
53
|
context "when no user's address is compatible with the params" do
|
52
54
|
before do
|
53
|
-
user.addresses << create(:address)
|
55
|
+
user.addresses << create(:address, state: state)
|
54
56
|
end
|
55
57
|
|
56
|
-
it "returns a non-persisted address
|
57
|
-
|
58
|
+
it "returns a non-persisted valid address" do
|
59
|
+
aggregate_failures do
|
60
|
+
expect(subject).to be_new_record
|
61
|
+
expect(subject).to be_valid
|
62
|
+
expect(subject.state).to eq state
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when the region is the state name" do
|
67
|
+
before { params[:region] = state.name }
|
68
|
+
|
69
|
+
it "still can set the address state attribute" do
|
70
|
+
expect(subject.state).to eq state
|
71
|
+
end
|
58
72
|
end
|
59
73
|
end
|
60
74
|
end
|
@@ -41,6 +41,9 @@ RSpec.describe SolidusStripe::CreateIntentsPaymentService do
|
|
41
41
|
"id" => intent_id,
|
42
42
|
"charges" => {
|
43
43
|
"data" => [{
|
44
|
+
"billing_details" => {
|
45
|
+
"name" => "John Doe"
|
46
|
+
},
|
44
47
|
"payment_method_details" => {
|
45
48
|
"card" => {
|
46
49
|
"brand" => "visa",
|
@@ -70,6 +73,19 @@ RSpec.describe SolidusStripe::CreateIntentsPaymentService do
|
|
70
73
|
expect(order.payments.last.reload).to be_pending
|
71
74
|
end
|
72
75
|
|
76
|
+
it "creates a credit card with the correct information" do
|
77
|
+
expect { subject }.to change { Spree::CreditCard.count }
|
78
|
+
card = Spree::CreditCard.last
|
79
|
+
|
80
|
+
aggregate_failures do
|
81
|
+
expect(card.name).to eq "John Doe"
|
82
|
+
expect(card.cc_type).to eq "visa"
|
83
|
+
expect(card.month).to eq "1"
|
84
|
+
expect(card.year).to eq "2022"
|
85
|
+
expect(card.last_digits).to eq "4242"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
73
89
|
context "when for any reason the payment could not be created" do
|
74
90
|
before { params[:form_data].delete(:city) }
|
75
91
|
|
@@ -22,7 +22,8 @@ describe Spree::PaymentMethod::StripeCreditCard do
|
|
22
22
|
let(:payment) {
|
23
23
|
double('Spree::Payment',
|
24
24
|
source: source,
|
25
|
-
order: order
|
25
|
+
order: order,
|
26
|
+
amount: order.total
|
26
27
|
)
|
27
28
|
}
|
28
29
|
|
@@ -241,4 +242,46 @@ describe Spree::PaymentMethod::StripeCreditCard do
|
|
241
242
|
expect(gateway).to receive(:capture).with(9855, '12345', anything).and_return(success_response)
|
242
243
|
end
|
243
244
|
end
|
245
|
+
|
246
|
+
describe '#try_void' do
|
247
|
+
let(:payment) { create :payment, amount: order.total }
|
248
|
+
|
249
|
+
shared_examples 'voids the payment transaction' do
|
250
|
+
it 'voids the payment transaction' do
|
251
|
+
expect(payment).to receive(:void_transaction!)
|
252
|
+
|
253
|
+
subject.try_void(payment)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context 'when using Payment Intents' do
|
258
|
+
before { subject.preferred_v3_intents = true }
|
259
|
+
|
260
|
+
context 'when the payment is completed' do
|
261
|
+
before do
|
262
|
+
allow(payment).to receive(:completed?) { true }
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'creates a refund' do
|
266
|
+
expect { subject.try_void(payment) }.to change { Spree::Refund.count }.by(1)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
context 'when the payment is not completed' do
|
271
|
+
it_behaves_like 'voids the payment transaction'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'when not using Payment Intents' do
|
276
|
+
before { subject.preferred_v3_intents = false }
|
277
|
+
|
278
|
+
context 'when the payment is completed' do
|
279
|
+
it_behaves_like 'voids the payment transaction'
|
280
|
+
end
|
281
|
+
|
282
|
+
context 'when the payment is not completed' do
|
283
|
+
it_behaves_like 'voids the payment transaction'
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
244
287
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,10 @@ require 'solidus_dev_support/rspec/feature_helper'
|
|
13
13
|
|
14
14
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
15
15
|
# in spec/support/ and its subdirectories.
|
16
|
-
Dir[File.join(File.dirname(__FILE__),
|
16
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
17
|
+
|
18
|
+
# Requires factories defined in lib/solidus_stripe/factories.rb
|
19
|
+
require 'solidus_stripe/factories'
|
17
20
|
|
18
21
|
RSpec.configure do |config|
|
19
22
|
config.infer_spec_type_from_file_location!
|
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.
|
4
|
+
version: 4.1.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: 2020-
|
11
|
+
date: 2020-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -88,7 +88,6 @@ files:
|
|
88
88
|
- CHANGELOG.md
|
89
89
|
- Gemfile
|
90
90
|
- LICENSE
|
91
|
-
- LICENSE.md
|
92
91
|
- README.md
|
93
92
|
- Rakefile
|
94
93
|
- app/assets/javascripts/spree/frontend/solidus_stripe.js
|
@@ -103,13 +102,18 @@ files:
|
|
103
102
|
- app/controllers/spree/stripe_controller.rb
|
104
103
|
- app/decorators/models/spree/order_update_attributes_decorator.rb
|
105
104
|
- app/decorators/models/spree/payment_decorator.rb
|
105
|
+
- app/decorators/models/spree/refund_decorator.rb
|
106
106
|
- app/models/solidus_stripe/address_from_params_service.rb
|
107
107
|
- app/models/solidus_stripe/create_intents_payment_service.rb
|
108
108
|
- app/models/solidus_stripe/prepare_order_for_payment_service.rb
|
109
109
|
- app/models/solidus_stripe/shipping_rates_service.rb
|
110
110
|
- app/models/spree/payment_method/stripe_credit_card.rb
|
111
111
|
- bin/console
|
112
|
+
- bin/r
|
112
113
|
- bin/rails
|
114
|
+
- bin/rake
|
115
|
+
- bin/sandbox
|
116
|
+
- bin/sandbox_rails
|
113
117
|
- bin/setup
|
114
118
|
- config/routes.rb
|
115
119
|
- db/migrate/20181010123508_update_stripe_payment_method_type_to_credit_card.rb
|
@@ -118,6 +122,7 @@ files:
|
|
118
122
|
- lib/generators/solidus_stripe/install/install_generator.rb
|
119
123
|
- lib/solidus_stripe.rb
|
120
124
|
- lib/solidus_stripe/engine.rb
|
125
|
+
- lib/solidus_stripe/factories.rb
|
121
126
|
- lib/solidus_stripe/version.rb
|
122
127
|
- lib/tasks/solidus_stripe/db/seed.rake
|
123
128
|
- lib/views/api/spree/api/payments/source_views/_stripe.json.jbuilder
|
@@ -141,30 +146,29 @@ files:
|
|
141
146
|
- spec/models/spree/payment_method/stripe_credit_card_spec.rb
|
142
147
|
- spec/spec_helper.rb
|
143
148
|
- spec/support/solidus_address_helper.rb
|
144
|
-
homepage: https://
|
149
|
+
homepage: https://github.com/solidusio/solidus_stripe#readme
|
145
150
|
licenses:
|
146
151
|
- BSD-3
|
147
152
|
metadata:
|
148
|
-
homepage_uri: https://
|
149
|
-
source_code_uri: https://
|
153
|
+
homepage_uri: https://github.com/solidusio/solidus_stripe#readme
|
154
|
+
source_code_uri: https://github.com/solidusio/solidus_stripe
|
155
|
+
changelog_uri: https://github.com/solidusio/solidus_stripe/blob/master/CHANGELOG.md
|
150
156
|
post_install_message:
|
151
157
|
rdoc_options: []
|
152
158
|
require_paths:
|
153
159
|
- lib
|
154
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
161
|
requirements:
|
156
|
-
- - "
|
162
|
+
- - "~>"
|
157
163
|
- !ruby/object:Gem::Version
|
158
|
-
version: '2.
|
164
|
+
version: '2.4'
|
159
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
166
|
requirements:
|
161
167
|
- - ">="
|
162
168
|
- !ruby/object:Gem::Version
|
163
169
|
version: '0'
|
164
|
-
requirements:
|
165
|
-
|
166
|
-
rubyforge_project:
|
167
|
-
rubygems_version: 2.7.10
|
170
|
+
requirements: []
|
171
|
+
rubygems_version: 3.0.3
|
168
172
|
signing_key:
|
169
173
|
specification_version: 4
|
170
174
|
summary: Stripe Payment Method for Solidus
|
data/LICENSE.md
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Spree Commerce Inc. and other contributors.
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without modification,
|
5
|
-
are permitted provided that the following conditions are met:
|
6
|
-
|
7
|
-
* Redistributions of source code must retain the above copyright notice,
|
8
|
-
this list of conditions and the following disclaimer.
|
9
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
-
this list of conditions and the following disclaimer in the documentation
|
11
|
-
and/or other materials provided with the distribution.
|
12
|
-
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
-
endorse or promote products derived from this software without specific
|
14
|
-
prior written permission.
|
15
|
-
|
16
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
-
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|