solidus_stripe 3.2.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +5 -0
- data/.gem_release.yml +1 -1
- data/.github/stale.yml +4 -4
- data/.github_changelog_generator +2 -0
- data/.gitignore +4 -2
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +121 -3
- data/Gemfile +10 -9
- data/LICENSE +2 -1
- data/README.md +77 -54
- data/Rakefile +1 -1
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-cart-page-checkout.js +43 -9
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-intents.js +2 -2
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-request-button-shared.js +58 -21
- data/app/controllers/solidus_stripe/intents_controller.rb +23 -18
- data/app/controllers/solidus_stripe/payment_request_controller.rb +11 -1
- data/app/decorators/models/spree/refund_decorator.rb +9 -0
- data/app/models/solidus_stripe/address_from_params_service.rb +25 -10
- data/app/models/solidus_stripe/create_intents_payment_service.rb +114 -0
- data/app/models/spree/payment_method/stripe_credit_card.rb +38 -1
- data/bin/r +13 -0
- data/bin/rails +4 -12
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +86 -0
- data/bin/sandbox_rails +18 -0
- data/bin/setup +1 -1
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +4 -1
- data/lib/generators/solidus_stripe/install/install_generator.rb +4 -4
- data/lib/solidus_stripe/configuration.rb +21 -0
- data/lib/solidus_stripe/engine.rb +5 -16
- data/lib/solidus_stripe/testing_support/card_input_helper.rb +34 -0
- data/lib/solidus_stripe/testing_support/factories.rb +4 -0
- data/lib/solidus_stripe/version.rb +1 -1
- data/lib/solidus_stripe.rb +5 -5
- data/lib/views/frontend/spree/checkout/payment/v2/_javascript.html.erb +1 -1
- data/lib/views/frontend/spree/checkout/payment/v3/_form_elements.html.erb +2 -2
- data/solidus_stripe.gemspec +34 -37
- data/spec/features/stripe_checkout_spec.rb +118 -147
- data/spec/models/solidus_stripe/address_from_params_service_spec.rb +35 -10
- data/spec/models/solidus_stripe/create_intents_payment_service_spec.rb +127 -0
- data/spec/models/spree/payment_method/stripe_credit_card_spec.rb +73 -1
- data/spec/requests/payment_requests_spec.rb +152 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/support/solidus_address_helper.rb +2 -2
- metadata +39 -24
- data/LICENSE.md +0 -26
- data/app/models/solidus_stripe/create_intents_order_service.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b92e606bb4ada8e49087a97ffeff9be982f8cc0110cd7c8c0721d73220adeb3c
|
4
|
+
data.tar.gz: 6c0b61f704f0faab2e16ef827879e86efde9bf7123eadc7a968c7810452956bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0daa283258eb4c1fb7dc0c41444e0e0ebaf8a439a91f7597d1ec4d941c9fd7badc0d043aec6a98e9b2c3e1bef131e4222d9bcc931c508546fee67b7d679a48ad
|
7
|
+
data.tar.gz: f10627a842fff35f6ef69e7cfcf8643ec4e7fb961cab9f9f2aba28217068afd62babe3d6048396d781794457c3f0fa2bdbad278f2a8865a13b0a41ee4397dd94
|
data/.circleci/config.yml
CHANGED
@@ -16,12 +16,17 @@ jobs:
|
|
16
16
|
executor: solidusio_extensions/mysql
|
17
17
|
steps:
|
18
18
|
- solidusio_extensions/run-tests
|
19
|
+
lint-code:
|
20
|
+
executor: solidusio_extensions/sqlite-memory
|
21
|
+
steps:
|
22
|
+
- solidusio_extensions/lint-code
|
19
23
|
|
20
24
|
workflows:
|
21
25
|
"Run specs on supported Solidus versions":
|
22
26
|
jobs:
|
23
27
|
- run-specs-with-postgres
|
24
28
|
- run-specs-with-mysql
|
29
|
+
|
25
30
|
"Weekly run specs against master":
|
26
31
|
triggers:
|
27
32
|
- schedule:
|
data/.gem_release.yml
CHANGED
data/.github/stale.yml
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# Number of days of inactivity before an issue becomes stale
|
2
2
|
daysUntilStale: 60
|
3
3
|
# Number of days of inactivity before a stale issue is closed
|
4
|
-
daysUntilClose:
|
4
|
+
daysUntilClose: false
|
5
5
|
# Issues with these labels will never be considered stale
|
6
6
|
exemptLabels:
|
7
7
|
- pinned
|
8
8
|
- security
|
9
9
|
# Label to use when marking an issue as stale
|
10
|
-
staleLabel:
|
10
|
+
staleLabel: stale
|
11
11
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
12
|
markComment: >
|
13
13
|
This issue has been automatically marked as stale because it has not had
|
14
|
-
recent activity. It
|
14
|
+
recent activity. It might be closed if no further activity occurs. Thank you
|
15
15
|
for your contributions.
|
16
16
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
-
closeComment: false
|
17
|
+
closeComment: false
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,126 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v4.3.0](https://github.com/solidusio/solidus_stripe/tree/v4.3.0) (2021-10-19)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/
|
5
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v4.2.0...v4.3.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Remove Solidus 2.x deprecation to allow 3.0 usage [\#99](https://github.com/solidusio/solidus_stripe/pull/99) ([kennyadsl](https://github.com/kennyadsl))
|
10
|
+
- Update gem with the latest dev\_support [\#97](https://github.com/solidusio/solidus_stripe/pull/97) ([kennyadsl](https://github.com/kennyadsl))
|
11
|
+
|
12
|
+
**Fixed bugs:**
|
13
|
+
|
14
|
+
- Fix 3DS iframe selection [\#86](https://github.com/solidusio/solidus_stripe/pull/86) ([spaghetticode](https://github.com/spaghetticode))
|
15
|
+
|
16
|
+
**Closed issues:**
|
17
|
+
|
18
|
+
- Could not create payment [\#111](https://github.com/solidusio/solidus_stripe/issues/111)
|
19
|
+
- statement\_descriptor\_suffix [\#107](https://github.com/solidusio/solidus_stripe/issues/107)
|
20
|
+
- Shipping cost payment refund rejected from Stripe API because of negative charge value [\#101](https://github.com/solidusio/solidus_stripe/issues/101)
|
21
|
+
- Remove Solidus 2.x deprecations [\#98](https://github.com/solidusio/solidus_stripe/issues/98)
|
22
|
+
- about LICENSE [\#59](https://github.com/solidusio/solidus_stripe/issues/59)
|
23
|
+
|
24
|
+
**Merged pull requests:**
|
25
|
+
|
26
|
+
- Add statement\_descriptor\_suffix support to options\_for\_purchase\_or\_auth [\#106](https://github.com/solidusio/solidus_stripe/pull/106) ([torukMnk](https://github.com/torukMnk))
|
27
|
+
- Update install instructions [\#105](https://github.com/solidusio/solidus_stripe/pull/105) ([kennyadsl](https://github.com/kennyadsl))
|
28
|
+
- Allow Solidus 3 [\#104](https://github.com/solidusio/solidus_stripe/pull/104) ([kennyadsl](https://github.com/kennyadsl))
|
29
|
+
- Bump minimum solidus\_support version requirement [\#102](https://github.com/solidusio/solidus_stripe/pull/102) ([filippoliverani](https://github.com/filippoliverani))
|
30
|
+
- Relax Ruby required version to support Ruby 3.0+ [\#96](https://github.com/solidusio/solidus_stripe/pull/96) ([filippoliverani](https://github.com/filippoliverani))
|
31
|
+
- Update refund\_decorator.rb prepend namespacing [\#91](https://github.com/solidusio/solidus_stripe/pull/91) ([brchristian](https://github.com/brchristian))
|
32
|
+
- Retrieve phone number paying with digital wallets [\#90](https://github.com/solidusio/solidus_stripe/pull/90) ([kennyadsl](https://github.com/kennyadsl))
|
33
|
+
- Fix Intents API link in README [\#87](https://github.com/solidusio/solidus_stripe/pull/87) ([kennyadsl](https://github.com/kennyadsl))
|
34
|
+
- Add missing 'var' [\#85](https://github.com/solidusio/solidus_stripe/pull/85) ([willread](https://github.com/willread))
|
35
|
+
- Fixes Rails 6.1 load warnings [\#84](https://github.com/solidusio/solidus_stripe/pull/84) ([marcrohloff](https://github.com/marcrohloff))
|
36
|
+
- Dedupe common code in stripe\_checkout\_spec.rb [\#80](https://github.com/solidusio/solidus_stripe/pull/80) ([brchristian](https://github.com/brchristian))
|
37
|
+
- Refactor spec with fill\_in\_card helper [\#78](https://github.com/solidusio/solidus_stripe/pull/78) ([brchristian](https://github.com/brchristian))
|
38
|
+
- Fix non-breaking space character in comment [\#76](https://github.com/solidusio/solidus_stripe/pull/76) ([brchristian](https://github.com/brchristian))
|
39
|
+
- Fix Copyright in README [\#73](https://github.com/solidusio/solidus_stripe/pull/73) ([kennyadsl](https://github.com/kennyadsl))
|
40
|
+
- Remove server and test\_mode from README [\#66](https://github.com/solidusio/solidus_stripe/pull/66) ([adammathys](https://github.com/adammathys))
|
41
|
+
|
42
|
+
## [v4.2.0](https://github.com/solidusio/solidus_stripe/tree/v4.2.0) (2020-07-20)
|
43
|
+
|
44
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v4.1.0...v4.2.0)
|
45
|
+
|
46
|
+
**Fixed bugs:**
|
47
|
+
|
48
|
+
- Fix StripeCreditCard\#try\_void with Elements/V2 API [\#75](https://github.com/solidusio/solidus_stripe/pull/75) ([spaghetticode](https://github.com/spaghetticode))
|
49
|
+
|
50
|
+
**Closed issues:**
|
51
|
+
|
52
|
+
- A token may not be passed in as a PaymentMethod. Instead, create a PaymentMethod or convert your token to a PaymentMethod by setting the `card[token]` parameter to [\#71](https://github.com/solidusio/solidus_stripe/issues/71)
|
53
|
+
|
54
|
+
**Merged pull requests:**
|
55
|
+
|
56
|
+
- Fix 3DS modal amount verification [\#72](https://github.com/solidusio/solidus_stripe/pull/72) ([spaghetticode](https://github.com/spaghetticode))
|
57
|
+
|
58
|
+
## [v4.1.0](https://github.com/solidusio/solidus_stripe/tree/v4.1.0) (2020-07-01)
|
59
|
+
|
60
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v3.2.1...v4.1.0)
|
61
|
+
|
62
|
+
**Fixed bugs:**
|
63
|
+
|
64
|
+
- Card name ignored when adding new card to an order during checkout [\#68](https://github.com/solidusio/solidus_stripe/issues/68)
|
65
|
+
- Try to find address state also by name [\#65](https://github.com/solidusio/solidus_stripe/pull/65) ([spaghetticode](https://github.com/spaghetticode))
|
66
|
+
- Fix order cancel with Payment Intents captured payment [\#57](https://github.com/solidusio/solidus_stripe/pull/57) ([spaghetticode](https://github.com/spaghetticode))
|
67
|
+
|
68
|
+
**Merged pull requests:**
|
69
|
+
|
70
|
+
- Save correct cardholder name in Spree::CreditCard [\#69](https://github.com/solidusio/solidus_stripe/pull/69) ([spaghetticode](https://github.com/spaghetticode))
|
71
|
+
- Update Readme [\#63](https://github.com/solidusio/solidus_stripe/pull/63) ([aleph1ow](https://github.com/aleph1ow))
|
72
|
+
- Remove credit cards image [\#62](https://github.com/solidusio/solidus_stripe/pull/62) ([aleph1ow](https://github.com/aleph1ow))
|
73
|
+
- Remove Stripe::CardError leftover [\#58](https://github.com/solidusio/solidus_stripe/pull/58) ([spaghetticode](https://github.com/spaghetticode))
|
74
|
+
- Update gemspec URLs [\#54](https://github.com/solidusio/solidus_stripe/pull/54) ([elia](https://github.com/elia))
|
75
|
+
- fix typo [\#51](https://github.com/solidusio/solidus_stripe/pull/51) ([ccarruitero](https://github.com/ccarruitero))
|
76
|
+
|
77
|
+
## [v3.2.1](https://github.com/solidusio/solidus_stripe/tree/v3.2.1) (2020-06-29)
|
78
|
+
|
79
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v4.0.0...v3.2.1)
|
80
|
+
|
81
|
+
**Fixed bugs:**
|
82
|
+
|
83
|
+
- \[ADMIN\] Order cancel doen't work with Payment Intents captured payments [\#56](https://github.com/solidusio/solidus_stripe/issues/56)
|
84
|
+
|
85
|
+
**Closed issues:**
|
86
|
+
|
87
|
+
- Could not find generator 'solidus\_stripe:install' [\#60](https://github.com/solidusio/solidus_stripe/issues/60)
|
88
|
+
- Payment Intent creation exception handling with class not present in the gem [\#55](https://github.com/solidusio/solidus_stripe/issues/55)
|
89
|
+
- Using static credentials [\#52](https://github.com/solidusio/solidus_stripe/issues/52)
|
90
|
+
- Auto capture behavior in v4.0.0 [\#50](https://github.com/solidusio/solidus_stripe/issues/50)
|
91
|
+
|
92
|
+
## [v4.0.0](https://github.com/solidusio/solidus_stripe/tree/v4.0.0) (2020-04-29)
|
93
|
+
|
94
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v3.2.0...v4.0.0)
|
95
|
+
|
96
|
+
**Fixed bugs:**
|
97
|
+
|
98
|
+
- Fix for 3D-Secure payments on cart page checkout [\#49](https://github.com/solidusio/solidus_stripe/pull/49) ([spaghetticode](https://github.com/spaghetticode))
|
99
|
+
|
100
|
+
**Closed issues:**
|
101
|
+
|
102
|
+
- Custom stripe element field options \(e.g for showing a credit card icon\) [\#41](https://github.com/solidusio/solidus_stripe/issues/41)
|
103
|
+
- Clearer documentation on how to implement [\#15](https://github.com/solidusio/solidus_stripe/issues/15)
|
104
|
+
|
105
|
+
**Merged pull requests:**
|
106
|
+
|
107
|
+
- Relax solidus\_support dependency [\#48](https://github.com/solidusio/solidus_stripe/pull/48) ([kennyadsl](https://github.com/kennyadsl))
|
108
|
+
|
109
|
+
## [v3.2.0](https://github.com/solidusio/solidus_stripe/tree/v3.2.0) (2020-04-10)
|
110
|
+
|
111
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v3.1.0...v3.2.0)
|
112
|
+
|
113
|
+
**Fixed bugs:**
|
114
|
+
|
115
|
+
- Send form data also when paying with payment request button [\#47](https://github.com/solidusio/solidus_stripe/pull/47) ([spaghetticode](https://github.com/spaghetticode))
|
116
|
+
|
117
|
+
**Merged pull requests:**
|
118
|
+
|
119
|
+
- Replace deprecated route `/stripe/confirm_payment` [\#46](https://github.com/solidusio/solidus_stripe/pull/46) ([spaghetticode](https://github.com/spaghetticode))
|
120
|
+
|
121
|
+
## [v3.1.0](https://github.com/solidusio/solidus_stripe/tree/v3.1.0) (2020-04-10)
|
122
|
+
|
123
|
+
[Full Changelog](https://github.com/solidusio/solidus_stripe/compare/v3.0.0...v3.1.0)
|
6
124
|
|
7
125
|
**Fixed bugs:**
|
8
126
|
|
@@ -70,7 +188,7 @@
|
|
70
188
|
**Merged pull requests:**
|
71
189
|
|
72
190
|
- Remove ERB from Elements and Intents JS code [\#28](https://github.com/solidusio/solidus_stripe/pull/28) ([spaghetticode](https://github.com/spaghetticode))
|
73
|
-
- Remove `
|
191
|
+
- Remove `update_attributes!` deprecation [\#24](https://github.com/solidusio/solidus_stripe/pull/24) ([spaghetticode](https://github.com/spaghetticode))
|
74
192
|
- Add solidus\_dev\_support gem [\#21](https://github.com/solidusio/solidus_stripe/pull/21) ([spaghetticode](https://github.com/spaghetticode))
|
75
193
|
- Fix reusing cards with Stripe v3 [\#17](https://github.com/solidusio/solidus_stripe/pull/17) ([kennyadsl](https://github.com/kennyadsl))
|
76
194
|
- Extension maintenance [\#14](https://github.com/solidusio/solidus_stripe/pull/14) ([kennyadsl](https://github.com/kennyadsl))
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
5
|
|
6
6
|
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
7
|
-
gem
|
7
|
+
gem 'solidus', github: 'solidusio/solidus', branch: branch
|
8
8
|
|
9
9
|
# Needed to help Bundler figure out how to resolve dependencies,
|
10
10
|
# otherwise it takes forever to resolve them.
|
@@ -12,7 +12,7 @@ gem "solidus", github: "solidusio/solidus", branch: branch
|
|
12
12
|
gem 'rails', '>0.a'
|
13
13
|
|
14
14
|
# Provides basic authentication functionality for testing parts of your engine
|
15
|
-
gem
|
15
|
+
gem 'solidus_auth_devise'
|
16
16
|
|
17
17
|
case ENV['DB']
|
18
18
|
when 'mysql'
|
@@ -23,10 +23,11 @@ else
|
|
23
23
|
gem 'sqlite3'
|
24
24
|
end
|
25
25
|
|
26
|
-
group :development, :test do
|
27
|
-
gem "pry-rails"
|
28
|
-
gem "ffaker"
|
29
|
-
gem "rails-controller-testing"
|
30
|
-
end
|
31
|
-
|
32
26
|
gemspec
|
27
|
+
|
28
|
+
# Use a local Gemfile to include development dependencies that might not be
|
29
|
+
# relevant for the project or for other contributors, e.g. pry-byebug.
|
30
|
+
#
|
31
|
+
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
32
|
+
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
33
|
+
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Solidus Stripe
|
2
|
-
===============
|
1
|
+
# Solidus Stripe
|
3
2
|
|
4
|
-
[![CircleCI](https://circleci.com/gh/solidusio/solidus_stripe.svg?style=
|
3
|
+
[![CircleCI](https://circleci.com/gh/solidusio/solidus_stripe.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_stripe)
|
4
|
+
[![codecov](https://codecov.io/gh/solidusio/solidus_stripe/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_stripe)
|
5
5
|
|
6
6
|
Stripe Payment Method for Solidus. It works as a wrapper for the ActiveMerchant Stripe gateway.
|
7
7
|
|
@@ -10,18 +10,11 @@ Stripe Payment Method for Solidus. It works as a wrapper for the ActiveMerchant
|
|
10
10
|
Installation
|
11
11
|
------------
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
gem 'solidus_stripe', '~> 3.0'
|
17
|
-
```
|
18
|
-
|
19
|
-
Then run from the command line:
|
13
|
+
Run from the command line:
|
20
14
|
|
21
15
|
```shell
|
22
|
-
bundle
|
16
|
+
bundle add solidus_stripe
|
23
17
|
bundle exec rails g solidus_stripe:install
|
24
|
-
bundle exec rails db:migrate
|
25
18
|
```
|
26
19
|
|
27
20
|
Usage
|
@@ -56,9 +49,7 @@ Spree.config do |config|
|
|
56
49
|
publishable_key: ENV['STRIPE_PUBLISHABLE_KEY'],
|
57
50
|
stripe_country: 'US',
|
58
51
|
v3_elements: false,
|
59
|
-
v3_intents: false
|
60
|
-
server: Rails.env.production? ? 'production' : 'test',
|
61
|
-
test_mode: !Rails.env.production?
|
52
|
+
v3_intents: false
|
62
53
|
)
|
63
54
|
end
|
64
55
|
```
|
@@ -82,7 +73,7 @@ account. Conversely, if you need to disable the button you can simply remove
|
|
82
73
|
the `stripe_country` preference.
|
83
74
|
|
84
75
|
Please refer to Stripe official
|
85
|
-
[documentation](https://stripe.com/docs/
|
76
|
+
[documentation](https://stripe.com/docs/payments/payment-intents)
|
86
77
|
for further instructions on how to make this work properly.
|
87
78
|
|
88
79
|
The following configuration will use both Payment Intents and the
|
@@ -100,13 +91,30 @@ Spree.config do |config|
|
|
100
91
|
publishable_key: ENV['STRIPE_PUBLISHABLE_KEY'],
|
101
92
|
stripe_country: 'US',
|
102
93
|
v3_elements: false,
|
103
|
-
v3_intents: true
|
104
|
-
server: Rails.env.production? ? 'production' : 'test',
|
105
|
-
test_mode: !Rails.env.production?
|
94
|
+
v3_intents: true
|
106
95
|
)
|
107
96
|
end
|
108
97
|
```
|
109
98
|
|
99
|
+
When using the Payment Intents API, be aware that the charge flow will be a bit
|
100
|
+
different than when using the old V2 API or Elements. It's advisable that all
|
101
|
+
Payment Intents charges are captured only by using the Solidus backend, as it is
|
102
|
+
the final source of truth in regards of Solidus orders payments.
|
103
|
+
|
104
|
+
A Payment Intent is created as soon as the customer enters their credit card
|
105
|
+
data. A tentative charge will be created on Stripe, easily recognizable by its
|
106
|
+
description: `Solidus Order ID: R987654321 (pending)`. As soon as the credit
|
107
|
+
card is confirmed (ie. when the customer passes the 3DSecure authorization, when
|
108
|
+
required) then the charge description gets updated to include the Solidus payment
|
109
|
+
number: `Solidus Order ID: R987654321-Z4VYUDB3`.
|
110
|
+
|
111
|
+
These charges are created `uncaptured` and will need to be captured in Solidus
|
112
|
+
backend later, after the customer confirms the order. If the customer never
|
113
|
+
completes the checkout, that charge must remain uncaptured. If the customer
|
114
|
+
decides to change their payment method after creating a Payment Request, then
|
115
|
+
that Payment Request charge will be canceled.
|
116
|
+
|
117
|
+
|
110
118
|
Apple Pay and Google Pay
|
111
119
|
-----------------------
|
112
120
|
|
@@ -119,14 +127,11 @@ Stripe account to receive payments via Apple Pay.
|
|
119
127
|
It's possible to pay with Apple Pay and Google Pay directly from the cart
|
120
128
|
page. The functionality is self-contained in the view partial
|
121
129
|
`_stripe_payment_request_button.html.erb`. In order to use it, you need
|
122
|
-
to
|
130
|
+
to render that partial in the `orders#edit` frontend page, and pass it the
|
123
131
|
payment method configured for Stripe via the local variable
|
124
|
-
`cart_checkout_payment_method
|
132
|
+
`cart_checkout_payment_method`:
|
125
133
|
|
126
134
|
```ruby
|
127
|
-
# app/overrides/spree/orders/edit/add_payment_request_button.html.erb.deface
|
128
|
-
|
129
|
-
<!-- insert_after '[data-hook="cart_container"]' -->
|
130
135
|
<%= render 'stripe_payment_request_button', cart_checkout_payment_method: Spree::PaymentMethod::StripeCreditCard.first %>
|
131
136
|
```
|
132
137
|
|
@@ -210,13 +215,13 @@ You can also style your element containers directly by using CSS rules like this
|
|
210
215
|
|
211
216
|
### Customizing individual input fields
|
212
217
|
|
213
|
-
If you want to customize individual input fields, you can override these methods
|
218
|
+
If you want to customize individual input fields, you can override these methods
|
214
219
|
|
215
220
|
* `SolidusStripe.Elements.prototype.cardNumberElementOptions`
|
216
221
|
* `SolidusStripe.Elements.prototype.cardExpiryElementOptions`
|
217
222
|
* `SolidusStripe.Elements.prototype.cardCvcElementOptions`
|
218
223
|
|
219
|
-
and return a valid [options object](https://stripe.com/docs/js/elements_object/create_element?type=cardNumber) for the corresponding field type. For example, this code sets a custom placeholder and enables the credit card icon for the card number field
|
224
|
+
and return a valid [options object](https://stripe.com/docs/js/elements_object/create_element?type=cardNumber) for the corresponding field type. For example, this code sets a custom placeholder and enables the credit card icon for the card number field
|
220
225
|
|
221
226
|
```js
|
222
227
|
SolidusStripe.Elements.prototype.cardNumberElementOptions = function () {
|
@@ -230,7 +235,7 @@ SolidusStripe.Elements.prototype.cardNumberElementOptions = function () {
|
|
230
235
|
|
231
236
|
### Passing options to the Stripe Elements instance
|
232
237
|
|
233
|
-
By overriding the `SolidusStripe.Payment.prototype.elementsBaseOptions` method and returning a [valid options object](https://stripe.com/docs/js/elements_object/create), you can pass custom options to the Stripe Elements instance.
|
238
|
+
By overriding the `SolidusStripe.Payment.prototype.elementsBaseOptions` method and returning a [valid options object](https://stripe.com/docs/js/elements_object/create), you can pass custom options to the Stripe Elements instance.
|
234
239
|
|
235
240
|
Note that in order to use web fonts with Stripe Elements, you must specify the fonts when creating the Stripe Elements instance. Here's an example specifying a custom web font and locale:
|
236
241
|
|
@@ -247,50 +252,68 @@ SolidusStripe.Payment.prototype.elementsBaseOptions = function () {
|
|
247
252
|
};
|
248
253
|
```
|
249
254
|
|
250
|
-
|
251
|
-
Migrating from solidus_gateway
|
252
|
-
------------------------------
|
255
|
+
## Migrating from solidus_gateway
|
253
256
|
|
254
257
|
If you were previously using `solidus_gateway` gem you might want to
|
255
258
|
check out our [Wiki page](https://github.com/solidusio/solidus_stripe/wiki/Migrating-from-solidus_gateway)
|
256
259
|
that describes how to handle this migration.
|
257
260
|
|
258
|
-
|
259
|
-
|
261
|
+
## Development
|
262
|
+
|
263
|
+
### Testing the extension
|
260
264
|
|
261
|
-
|
262
|
-
run
|
265
|
+
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
|
266
|
+
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
|
267
|
+
`bin/rake extension:test_app`.
|
263
268
|
|
264
269
|
```shell
|
265
|
-
|
270
|
+
bin/rake
|
266
271
|
```
|
267
272
|
|
268
|
-
|
269
|
-
---------
|
273
|
+
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
|
270
274
|
|
271
|
-
|
272
|
-
|
275
|
+
```shell
|
276
|
+
bundle exec rubocop
|
277
|
+
```
|
273
278
|
|
274
|
-
|
275
|
-
|
276
|
-
can simply run:
|
279
|
+
When testing your application's integration with this extension you may use its factories.
|
280
|
+
Simply add this require statement to your spec_helper:
|
277
281
|
|
278
|
-
```
|
279
|
-
|
282
|
+
```ruby
|
283
|
+
require '<%= file_name %>/factories'
|
280
284
|
```
|
281
285
|
|
282
|
-
|
286
|
+
### Running the sandbox
|
283
287
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
- push the tag to the upstream remote
|
288
|
-
- release the new version on RubyGems
|
288
|
+
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
289
|
+
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
|
290
|
+
`sandbox/bin/rails`.
|
289
291
|
|
290
|
-
|
292
|
+
Here's an example:
|
291
293
|
|
292
294
|
```
|
293
|
-
|
294
|
-
|
295
|
-
|
295
|
+
$ bin/rails server
|
296
|
+
=> Booting Puma
|
297
|
+
=> Rails 6.0.2.1 application starting in development
|
298
|
+
* Listening on tcp://127.0.0.1:3000
|
299
|
+
Use Ctrl-C to stop
|
296
300
|
```
|
301
|
+
|
302
|
+
### Updating the changelog
|
303
|
+
|
304
|
+
Before and after releases the changelog should be updated to reflect the up-to-date status of
|
305
|
+
the project:
|
306
|
+
|
307
|
+
```shell
|
308
|
+
bin/rake changelog
|
309
|
+
git add CHANGELOG.md
|
310
|
+
git commit -m "Update the changelog"
|
311
|
+
```
|
312
|
+
|
313
|
+
### Releasing new versions
|
314
|
+
|
315
|
+
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
|
316
|
+
|
317
|
+
## License
|
318
|
+
Copyright (c) 2014 Spree Commerce Inc., released under the New BSD License
|
319
|
+
Copyright (c) 2021 Solidus Team, released under the New BSD License
|
data/Rakefile
CHANGED
@@ -16,11 +16,14 @@ SolidusStripe.CartPageCheckout.prototype.init = function() {
|
|
16
16
|
};
|
17
17
|
|
18
18
|
SolidusStripe.CartPageCheckout.prototype.showError = function(error) {
|
19
|
-
|
19
|
+
var message = error.message || error;
|
20
|
+
|
21
|
+
this.errorElement.text(message).show();
|
20
22
|
};
|
21
23
|
|
22
24
|
SolidusStripe.CartPageCheckout.prototype.submitPayment = function(payment) {
|
23
25
|
var showError = this.showError.bind(this);
|
26
|
+
var prTokenHandler = this.prTokenHandler.bind(this);
|
24
27
|
|
25
28
|
$.ajax({
|
26
29
|
url: $('[data-submit-url]').data('submit-url'),
|
@@ -29,7 +32,7 @@ SolidusStripe.CartPageCheckout.prototype.submitPayment = function(payment) {
|
|
29
32
|
},
|
30
33
|
type: 'PATCH',
|
31
34
|
contentType: 'application/json',
|
32
|
-
data: JSON.stringify(
|
35
|
+
data: JSON.stringify(prTokenHandler(payment.paymentMethod)),
|
33
36
|
success: function() {
|
34
37
|
window.location = $('[data-complete-url]').data('complete-url');
|
35
38
|
},
|
@@ -39,26 +42,57 @@ SolidusStripe.CartPageCheckout.prototype.submitPayment = function(payment) {
|
|
39
42
|
});
|
40
43
|
};
|
41
44
|
|
42
|
-
SolidusStripe.CartPageCheckout.prototype.onPrPayment = function(
|
43
|
-
var
|
45
|
+
SolidusStripe.CartPageCheckout.prototype.onPrPayment = function(payment) {
|
46
|
+
var createIntent = this.createIntent.bind(this);
|
44
47
|
|
45
48
|
fetch('/stripe/update_order', {
|
46
49
|
method: 'POST',
|
47
50
|
headers: { 'Content-Type': 'application/json' },
|
48
51
|
body: JSON.stringify({
|
49
|
-
shipping_address:
|
50
|
-
shipping_option:
|
51
|
-
email:
|
52
|
-
name:
|
52
|
+
shipping_address: payment.shippingAddress,
|
53
|
+
shipping_option: payment.shippingOption,
|
54
|
+
email: payment.payerEmail,
|
55
|
+
name: payment.payerName,
|
56
|
+
phone: payment.payerPhone,
|
53
57
|
authenticity_token: this.authToken
|
54
58
|
})
|
55
59
|
}).then(function(response) {
|
56
60
|
response.json().then(function(json) {
|
57
|
-
|
61
|
+
createIntent(json, payment);
|
58
62
|
})
|
59
63
|
});
|
60
64
|
};
|
61
65
|
|
66
|
+
SolidusStripe.CartPageCheckout.prototype.createIntent = function(result, payment) {
|
67
|
+
var handleServerResponse = this.handleServerResponse.bind(this);
|
68
|
+
|
69
|
+
if (result.error) {
|
70
|
+
this.completePaymentRequest(payment, 'fail');
|
71
|
+
this.showError(result.error);
|
72
|
+
} else {
|
73
|
+
if (payment.error) {
|
74
|
+
this.showError(payment.error.message);
|
75
|
+
} else {
|
76
|
+
fetch('/stripe/create_intent', {
|
77
|
+
method: 'POST',
|
78
|
+
headers: {
|
79
|
+
'Content-Type': 'application/json'
|
80
|
+
},
|
81
|
+
body: JSON.stringify({
|
82
|
+
form_data: payment.shippingAddress,
|
83
|
+
spree_payment_method_id: this.config.id,
|
84
|
+
stripe_payment_method_id: payment.paymentMethod.id,
|
85
|
+
authenticity_token: this.authToken
|
86
|
+
})
|
87
|
+
}).then(function(response) {
|
88
|
+
response.json().then(function(result) {
|
89
|
+
handleServerResponse(result, payment)
|
90
|
+
})
|
91
|
+
});
|
92
|
+
}
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
62
96
|
SolidusStripe.CartPageCheckout.prototype.onPrButtonMounted = function(buttonId, success) {
|
63
97
|
var container = document.getElementById(buttonId).parentElement;
|
64
98
|
|
@@ -21,7 +21,7 @@ SolidusStripe.PaymentIntents.prototype.onPrPayment = function(payment) {
|
|
21
21
|
var that = this;
|
22
22
|
|
23
23
|
this.elementsTokenHandler(payment.paymentMethod);
|
24
|
-
fetch('/stripe/
|
24
|
+
fetch('/stripe/create_intent', {
|
25
25
|
method: 'POST',
|
26
26
|
headers: {
|
27
27
|
'Content-Type': 'application/json'
|
@@ -64,7 +64,7 @@ SolidusStripe.PaymentIntents.prototype.onIntentsPayment = function(payment) {
|
|
64
64
|
var that = this;
|
65
65
|
|
66
66
|
this.elementsTokenHandler(payment.paymentMethod);
|
67
|
-
fetch('/stripe/
|
67
|
+
fetch('/stripe/create_intent', {
|
68
68
|
method: 'POST',
|
69
69
|
headers: {
|
70
70
|
'Content-Type': 'application/json'
|