solidus_paypal_commerce_platform 0.7.0 → 1.0.0.beta1
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 +21 -9
- data/.gem_release.yml +1 -1
- data/.gitignore +1 -0
- data/.rspec +0 -1
- data/.rubocop.yml +3 -2
- data/CHANGELOG.md +12 -17
- data/Gemfile +0 -41
- data/README.md +10 -14
- data/Rakefile +6 -1
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +1 -18
- data/bin/dummy-app +37 -0
- data/bin/rails-dummy-app +17 -0
- data/bin/rspec +11 -0
- data/bin/sandbox +3 -8
- data/config/locales/en.yml +0 -1
- data/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb +35 -21
- data/lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +272 -0
- data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform.js +7 -0
- data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb +1 -1
- data/lib/{views/frontend/spree/checkout → generators/solidus_paypal_commerce_platform/install/templates/app/views/checkouts}/payment/_paypal_commerce_platform.html.erb +5 -4
- data/lib/{views/frontend/spree → generators/solidus_paypal_commerce_platform/install/templates/app/views}/orders/payment/_paypal_commerce_platform.html.erb +4 -3
- data/lib/{views/frontend/spree → generators/solidus_paypal_commerce_platform/install/templates/app/views}/products/payment/_paypal_commerce_platform.html.erb +1 -1
- data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/shared/_javascript_sdk_tag.html.erb +4 -2
- data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
- data/solidus_paypal_commerce_platform.gemspec +1 -2
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json +121 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json +121 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json +50 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json +72 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json +50 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json +68 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json +51 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json +63 -0
- data/spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb +44 -0
- data/spec/lib/solidus_paypal_commerce_platform/client_spec.rb +21 -0
- data/spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb +91 -0
- data/spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb +200 -0
- data/spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb +119 -0
- data/spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb +67 -0
- data/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +80 -0
- data/spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb +38 -0
- data/spec/models/solidus_paypal_commerce_platform/wizard_spec.rb +9 -0
- data/spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb +36 -0
- data/spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb +44 -0
- data/spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb +59 -0
- data/spec/solidus_paypal_commerce_platform_spec_helper.rb +5 -0
- data/spec/support/solidus_paypal_commerce_platform/factories.rb +5 -0
- data/spec/support/solidus_paypal_commerce_platform/paypal_sdk_script_tag_helper.rb +13 -0
- data/spec/system/backend/new_payment_method_spec.rb +40 -0
- data/spec/system/frontend/cart_spec.rb +53 -0
- data/spec/system/frontend/checkout_spec.rb +104 -0
- data/spec/system/frontend/product_spec.rb +98 -0
- metadata +53 -37
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +0 -206
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/namespace.js +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/stylesheets/spree/frontend/solidus_paypal_commerce_platform.css +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/orders_controller.rb +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/payments_controller.rb +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/shipping_rates_controller.rb +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/wizard_controller.rb +0 -0
- /data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/cart/_cart_buttons.html.erb +0 -0
- /data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/payments/_payment.html.erb +0 -0
- /data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/product/_product_buttons.html.erb +0 -0
- /data/lib/generators/solidus_paypal_commerce_platform/install/templates/{initializer.rb → config/initializers/solidus_paypal_commerce_platform.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd0c77c30a42db324d623a2bd37e7ca2d80d107d06c11e5c9c5829bf06e793cf
|
4
|
+
data.tar.gz: 33336091ab82d3af94df502291cbfbe0be94d8d5c839e3c73082210a8b4813b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90f698b25df4994cd5037eba1ae264769c1a3667e57f73f415bc38c9d1004bf0e5a4f9404caf57dfba81d65a31340dbe1966d0ef464e673f8ef84b95689ca6b2
|
7
|
+
data.tar.gz: f42016a399a1d7d38d942589df248419f0a5395a62891cda436daa0725c377e4c4518076337a1354553fc9e9a9124424e47f27bfd50f4ebf32ee2863673091dd
|
data/.circleci/config.yml
CHANGED
@@ -9,33 +9,45 @@ orbs:
|
|
9
9
|
# or goes EOL.
|
10
10
|
solidusio_extensions: solidusio/extensions@volatile
|
11
11
|
|
12
|
+
commands:
|
13
|
+
test-with-starter-frontend:
|
14
|
+
steps:
|
15
|
+
- checkout
|
16
|
+
- browser-tools/install-chrome
|
17
|
+
- run:
|
18
|
+
name: Install libvips
|
19
|
+
command: sudo apt-get install -y libvips
|
20
|
+
- solidusio_extensions/test-branch:
|
21
|
+
branch: master
|
22
|
+
command: |
|
23
|
+
export FRONTEND=starter
|
24
|
+
sudo gem update --system
|
25
|
+
gem install bundler
|
26
|
+
bin/dummy-app
|
27
|
+
bin/rspec
|
28
|
+
- solidusio_extensions/store-test-results
|
29
|
+
|
12
30
|
jobs:
|
13
31
|
run-specs-with-postgres:
|
14
32
|
executor:
|
15
33
|
name: solidusio_extensions/postgres
|
16
34
|
ruby_version: '3.1'
|
17
35
|
steps:
|
18
|
-
-
|
19
|
-
- browser-tools/install-chrome
|
20
|
-
- solidusio_extensions/run-tests
|
36
|
+
- test-with-starter-frontend
|
21
37
|
|
22
38
|
run-specs-with-mysql:
|
23
39
|
executor:
|
24
40
|
name: solidusio_extensions/mysql
|
25
41
|
ruby_version: '3.0'
|
26
42
|
steps:
|
27
|
-
-
|
28
|
-
- browser-tools/install-chrome
|
29
|
-
- solidusio_extensions/run-tests
|
43
|
+
- test-with-starter-frontend
|
30
44
|
|
31
45
|
run-specs-with-sqlite:
|
32
46
|
executor:
|
33
47
|
name: solidusio_extensions/sqlite
|
34
48
|
ruby_version: '2.7'
|
35
49
|
steps:
|
36
|
-
-
|
37
|
-
- browser-tools/install-chrome
|
38
|
-
- solidusio_extensions/run-tests
|
50
|
+
- test-with-starter-frontend
|
39
51
|
|
40
52
|
lint-code:
|
41
53
|
executor: solidusio_extensions/sqlite-memory
|
data/.gem_release.yml
CHANGED
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -6,6 +6,7 @@ AllCops:
|
|
6
6
|
TargetRubyVersion: '2.7'
|
7
7
|
Exclude:
|
8
8
|
- sandbox/**/*
|
9
|
+
- dummy-app/**/*
|
9
10
|
- spec/dummy/**/*
|
10
11
|
- vendor/bundle/**/*
|
11
12
|
|
@@ -23,10 +24,10 @@ Naming/VariableNumber:
|
|
23
24
|
RSpec/AnyInstance:
|
24
25
|
Enabled: false
|
25
26
|
|
26
|
-
#
|
27
|
+
# System specs are not describing any class or module.
|
27
28
|
RSpec/DescribeClass:
|
28
29
|
Exclude:
|
29
|
-
- spec/
|
30
|
+
- spec/system/**/*
|
30
31
|
|
31
32
|
# No need to make the code more complex for no real gain.
|
32
33
|
RSpec/MessageSpies:
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v1.0.0.beta1](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v1.0.0.beta1) (2022-12-05)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.6.0...
|
5
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.6.0...v1.0.0.beta1)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Release 0.6 and attach that version to a different branch [\#169](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/169)
|
6
10
|
|
7
11
|
**Merged pull requests:**
|
8
12
|
|
9
|
-
-
|
10
|
-
-
|
13
|
+
- Bugfixes and improvements \(extracted from the SSF support branch\) [\#168](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/168) ([elia](https://github.com/elia))
|
14
|
+
- Reorganize the install generator and deprecate `--skip-migrations` [\#167](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/167) ([elia](https://github.com/elia))
|
15
|
+
- Setup compatibility with the starter frontend [\#166](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/166) ([elia](https://github.com/elia))
|
16
|
+
- Move 'shipping\_preference' preference under PaypalOrder\#to\_json [\#152](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/152) ([retsef](https://github.com/retsef))
|
17
|
+
- Truncate the product name to 127 characters [\#139](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/139) ([DanielePalombo](https://github.com/DanielePalombo))
|
18
|
+
- Fix issue on international transactions [\#129](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/129) ([jtapia](https://github.com/jtapia))
|
11
19
|
|
12
20
|
## [v0.6.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.6.0) (2022-11-25)
|
13
21
|
|
@@ -22,19 +30,6 @@
|
|
22
30
|
- Invalid string length error [\#135](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/135)
|
23
31
|
- PayPal SDK JS Error: Disallowed query param: shipping\_preference [\#133](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/133)
|
24
32
|
|
25
|
-
**Merged pull requests:**
|
26
|
-
|
27
|
-
- More fixes and improvements extracted from SSF support [\#168](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/168) ([elia](https://github.com/elia))
|
28
|
-
* inline the load_order before action
|
29
|
-
* require the payment_method_id param when loading the payment method
|
30
|
-
* mark the javascript_sdk_url as HTML safe
|
31
|
-
* ensure amounts are presented with 2 decimals for the PayPal API
|
32
|
-
* fixed the sign in requests
|
33
|
-
- Reorganize the install generator and deprecate `--skip-migrations` [\#167](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/167) ([elia](https://github.com/elia))
|
34
|
-
- Move 'shipping\_preference' preference under PaypalOrder\#to\_json [\#152](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/152) ([retsef](https://github.com/retsef))
|
35
|
-
- Truncate the product name to 127 characters [\#139](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/139) ([DanielePalombo](https://github.com/DanielePalombo))
|
36
|
-
- Fix issue on international transactions [\#129](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/129) ([jtapia](https://github.com/jtapia))
|
37
|
-
|
38
33
|
## [v0.5.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.5.0) (2022-10-07)
|
39
34
|
|
40
35
|
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.4.0...v0.5.0)
|
data/Gemfile
CHANGED
@@ -1,46 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
|
-
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
-
|
6
|
-
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
7
|
-
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
|
8
|
-
%w[solidusio/solidus solidusio/solidus_frontend]
|
9
|
-
else
|
10
|
-
%w[solidusio/solidus] * 2
|
11
|
-
end
|
12
|
-
gem 'solidus', github: solidus_git, branch: branch
|
13
|
-
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
|
14
|
-
|
15
|
-
# Needed to help Bundler figure out how to resolve dependencies,
|
16
|
-
# otherwise it takes forever to resolve them.
|
17
|
-
# See https://github.com/bundler/bundler/issues/6677
|
18
|
-
gem 'rails', ENV.fetch('RAILS_VERSION', '>0.a')
|
19
|
-
|
20
|
-
# Provides basic authentication functionality for testing parts of your engine
|
21
|
-
gem 'solidus_auth_devise'
|
22
|
-
|
23
|
-
case ENV.fetch('DB', nil)
|
24
|
-
when 'mysql'
|
25
|
-
gem 'mysql2'
|
26
|
-
when 'postgresql'
|
27
|
-
gem 'pg'
|
28
|
-
else
|
29
|
-
gem 'sqlite3'
|
30
|
-
end
|
31
|
-
|
32
|
-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3')
|
33
|
-
# 'net/smtp' is required by 'mail', see:
|
34
|
-
# - https://github.com/ruby/net-protocol/issues/10
|
35
|
-
# - https://stackoverflow.com/a/72474475
|
36
|
-
gem 'net-smtp', require: false
|
37
|
-
end
|
38
4
|
|
39
5
|
gemspec
|
40
|
-
|
41
|
-
# Use a local Gemfile to include development dependencies that might not be
|
42
|
-
# relevant for the project or for other contributors, e.g. pry-byebug.
|
43
|
-
#
|
44
|
-
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
45
|
-
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
46
|
-
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Since PayPal is being used as the checkout if the user checks out on the product
|
|
31
31
|
|
32
32
|
A) Turn off cart and product page checkout - configurable on the admin payment method page for PayPal Commerce Platform.
|
33
33
|
-OR-
|
34
|
-
B) Collect the users phone number
|
34
|
+
B) Collect the users phone number separately
|
35
35
|
|
36
36
|
and then override the `Spree::Address` method `require_phone?` to return `true`.
|
37
37
|
|
@@ -93,6 +93,7 @@ end
|
|
93
93
|
The instances of your wizard class should respond to `#name` and `#partial_name`, where `partial_name` will return the path to the partial you'd like to display on the wizard setup section. In our case, we just display a button to direct the user to PayPal.
|
94
94
|
|
95
95
|
## State Guesser
|
96
|
+
|
96
97
|
PayPal users can change their shipping address directly on PayPal, which will
|
97
98
|
update their address on Solidus as well. However, in some instances, Solidus
|
98
99
|
uses the incorrect subregion level for states, which causes validation problems
|
@@ -101,7 +102,7 @@ with the addresses that PayPal sends to us.
|
|
101
102
|
For instance, if your user lives in Pescara, Italy, then PayPal will return
|
102
103
|
"Pescara" as the state. However on older version of Solidus, the region
|
103
104
|
"Abruzzo" is used, so the address will not be able to validate. To solve this
|
104
|
-
issue, we've
|
105
|
+
issue, we've implemented a class that attempts to guess the state of the user
|
105
106
|
using Carmen subregions if the state cannot be initially found. You can, of
|
106
107
|
course, implement your own state guesser and set it like this:
|
107
108
|
|
@@ -121,6 +122,7 @@ With product and cart page checkout, the user is directed to the checkout confir
|
|
121
122
|
PayPals API does not allow for admin-side payments. Instead, backend users taking payments for customers will need to use the PayPal Virtual Terminal to take payments. [More info is available on the PayPal website.](https://www.paypal.com/merchantapps/appcenter/acceptpayments/virtualterminal?locale.x=en_US)
|
122
123
|
|
123
124
|
## Venmo
|
125
|
+
|
124
126
|
Venmo is currently available to US merchants and buyers. There are also other [prequisites](https://developer.paypal.com/docs/business/checkout/pay-with-venmo/#eligibility).
|
125
127
|
|
126
128
|
If the transaction supports Venmo and it is enabled by the following, then a button should appear for it on checkout payment page. Note, Venmo cannot currently be rendered on the product or cart pages.
|
@@ -135,6 +137,7 @@ See more about preferences([Configuration](#configuration)) below.
|
|
135
137
|
[_As Venmo is only available in the US, you may want to mock your location for testing_](#mocking-your-buyer-country)
|
136
138
|
|
137
139
|
## Configuration
|
140
|
+
|
138
141
|
The easiest way to change the `Payment Method`'s preferences is through admin: `Settings > Payments > "PayPal Commerce Platform" > Edit`.
|
139
142
|
|
140
143
|
See more about preferences [here](https://guides.solidus.io/developers/preferences/add-model-preferences.html#access-your-preferences)/
|
@@ -145,10 +148,10 @@ See more about preferences [here](https://guides.solidus.io/developers/preferenc
|
|
145
148
|
|
146
149
|
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
|
147
150
|
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
|
148
|
-
`bin/
|
151
|
+
`bin/dummy-app`.
|
149
152
|
|
150
153
|
```shell
|
151
|
-
|
154
|
+
bin/setup
|
152
155
|
bin/rake
|
153
156
|
```
|
154
157
|
|
@@ -158,13 +161,6 @@ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
|
|
158
161
|
bundle exec rubocop
|
159
162
|
```
|
160
163
|
|
161
|
-
When testing your application's integration with this extension you may use its factories.
|
162
|
-
Simply add this require statement to your spec_helper:
|
163
|
-
|
164
|
-
```ruby
|
165
|
-
require 'solidus_paypal_commerce_platform/factories'
|
166
|
-
```
|
167
|
-
|
168
164
|
### Running the sandbox
|
169
165
|
|
170
166
|
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
@@ -182,6 +178,7 @@ Use Ctrl-C to stop
|
|
182
178
|
```
|
183
179
|
|
184
180
|
### Mocking your buyer country
|
181
|
+
|
185
182
|
PayPal normally looks at your IP geolocation to see where you are located to determine what funding sources are available to you. For example, Venmo is currently only available to US buyers.
|
186
183
|
Because of this, you may want to pretend you are from US check that that Venmo is correctly integrated for these customers. To do this, set the payment method's preference of `force_buyer_country` to "US". See more information about preferences above.
|
187
184
|
|
@@ -206,8 +203,7 @@ Your new extension version can be released using `gem-release` like this:
|
|
206
203
|
bundle exec gem bump -v 1.6.0
|
207
204
|
bin/rake changelog
|
208
205
|
git commit -a --amend
|
209
|
-
git
|
210
|
-
git push --tags
|
206
|
+
git push
|
211
207
|
bundle exec gem release
|
212
208
|
```
|
213
209
|
|
@@ -217,4 +213,4 @@ By using this extension, you are giving back to Solidus. PayPal will pay a fee t
|
|
217
213
|
|
218
214
|
## License
|
219
215
|
|
220
|
-
Copyright (c)
|
216
|
+
Copyright (c) 2022 Nebulab srls, released under the New BSD License
|
data/Rakefile
CHANGED
@@ -83,7 +83,7 @@ module SolidusPaypalCommercePlatform
|
|
83
83
|
|
84
84
|
parameters = {
|
85
85
|
'client-id': client_id,
|
86
|
-
intent: auto_capture
|
86
|
+
intent: auto_capture ? "capture" : "authorize",
|
87
87
|
commit: commit_immediately ? "false" : "true",
|
88
88
|
components: options[:display_credit_messaging] ? "buttons,messages" : "buttons",
|
89
89
|
currency: currency,
|
@@ -97,22 +97,5 @@ module SolidusPaypalCommercePlatform
|
|
97
97
|
|
98
98
|
"https://www.paypal.com/sdk/js?#{parameters.compact.to_query}".html_safe # rubocop:disable Rails/OutputSafety
|
99
99
|
end
|
100
|
-
|
101
|
-
# Will void the payment depending on its state or return false
|
102
|
-
#
|
103
|
-
# If the payment has not yet been captured, we can void the transaction.
|
104
|
-
# Otherwise, we return false so Solidus creates a refund instead.
|
105
|
-
#
|
106
|
-
# https://developer.paypal.com/docs/api/payments/v2/#authorizations_void
|
107
|
-
#
|
108
|
-
# @api public
|
109
|
-
# @param payment [Spree::Payment] the payment to void
|
110
|
-
# @return [Response|FalseClass]
|
111
|
-
def try_void(payment)
|
112
|
-
void_attempt = void(nil, { originator: payment })
|
113
|
-
return void_attempt if void_attempt.success?
|
114
|
-
|
115
|
-
false
|
116
|
-
end
|
117
100
|
end
|
118
101
|
end
|
data/bin/dummy-app
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
extension_name="solidus_paypal_commerce_platform"
|
6
|
+
|
7
|
+
# Stay away from the bundler env of the containing extension.
|
8
|
+
function unbundled {
|
9
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@"
|
10
|
+
}
|
11
|
+
|
12
|
+
# "sqlite" is set by the ORB extension instead of "sqlite3",
|
13
|
+
# all other options are already in the format expected by `rails new`.
|
14
|
+
test "$DB" = "sqlite" && export DB="sqlite3"
|
15
|
+
|
16
|
+
rm -rf ./dummy-app
|
17
|
+
unbundled bundle exec rails new dummy-app \
|
18
|
+
--database=${DB:-sqlite3} \
|
19
|
+
--skip-bundle \
|
20
|
+
--skip-git \
|
21
|
+
--skip-keeps \
|
22
|
+
--skip-rc \
|
23
|
+
--skip-spring \
|
24
|
+
--skip-javascript
|
25
|
+
|
26
|
+
if [ ! -d "dummy-app" ]; then
|
27
|
+
echo 'dummy-app rails application failed'
|
28
|
+
exit 1
|
29
|
+
fi
|
30
|
+
|
31
|
+
cd ./dummy-app
|
32
|
+
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
|
33
|
+
unbundled bundle exec rake db:drop db:create
|
34
|
+
unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none --no-seed --no-sample "$@"
|
35
|
+
unbundled bundle add $extension_name --path ..
|
36
|
+
unbundled bundle exec rails generate $extension_name:install --migrate --specs=all
|
37
|
+
|
data/bin/rails-dummy-app
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
root = "#{__dir__}/.."
|
4
|
+
app_root = "#{root}/dummy-app"
|
5
|
+
|
6
|
+
unless File.exist? "#{app_root}/bin/rails"
|
7
|
+
warn 'Creating the dummy-app app...'
|
8
|
+
Dir.chdir root do
|
9
|
+
system "#{root}/bin/dummy-app" or begin
|
10
|
+
warn 'Automatic creation of the dummy-app app failed'
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir.chdir app_root
|
17
|
+
exec "#{app_root}/bin/rails", *ARGV
|
data/bin/rspec
ADDED
data/bin/sandbox
CHANGED
@@ -29,7 +29,7 @@ extension_name="solidus_paypal_commerce_platform"
|
|
29
29
|
|
30
30
|
# Stay away from the bundler env of the containing extension.
|
31
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)' -- $@
|
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
33
|
}
|
34
34
|
|
35
35
|
rm -rf ./sandbox
|
@@ -48,14 +48,9 @@ if [ ! -d "sandbox" ]; then
|
|
48
48
|
fi
|
49
49
|
|
50
50
|
cd ./sandbox
|
51
|
-
|
52
|
-
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
|
53
|
-
gem 'pry-byebug', platforms: :mri, groups: [:test, :development]
|
54
|
-
RUBY
|
55
|
-
|
56
|
-
unbundled bundle install --gemfile Gemfile
|
51
|
+
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
|
57
52
|
unbundled bundle exec rake db:drop db:create
|
58
|
-
unbundled bundle exec rails generate solidus:install --auto-accept $@
|
53
|
+
unbundled bundle exec rails generate solidus:install --auto-accept "$@"
|
59
54
|
|
60
55
|
echo
|
61
56
|
echo "🚀 Sandbox app successfully created for $extension_name!"
|
data/config/locales/en.yml
CHANGED
@@ -40,7 +40,6 @@ en:
|
|
40
40
|
success: "Payment refunded for %{amount}"
|
41
41
|
pay_pal_checkout_sdk/payments/authorizations_void_request:
|
42
42
|
success: "Payment voided"
|
43
|
-
failure: "This payment can't be voided"
|
44
43
|
payment_method:
|
45
44
|
gold_button_message: "cannot be 'gold' when Venmo standalone is enabled."
|
46
45
|
paypal_funding_sources:
|
@@ -3,21 +3,22 @@
|
|
3
3
|
module SolidusPaypalCommercePlatform
|
4
4
|
module Generators
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
|
-
class_option :
|
7
|
-
|
8
|
-
|
9
|
-
class_option :
|
6
|
+
class_option :migrate, type: :boolean, default: true
|
7
|
+
class_option :backend, type: :boolean, default: true
|
8
|
+
class_option :starter_frontend, type: :boolean, default: true
|
9
|
+
class_option :specs, type: :string, enum: %w[all frontend], default: 'frontend'
|
10
10
|
|
11
11
|
source_root File.expand_path('templates', __dir__)
|
12
12
|
|
13
13
|
def install_solidus_core_support
|
14
|
-
|
14
|
+
directory 'config/initializers', 'config/initializers'
|
15
15
|
rake 'railties:install:migrations FROM=solidus_paypal_commerce_platform'
|
16
|
+
run 'bin/rails db:migrate' if options[:migrate]
|
16
17
|
route "mount SolidusPaypalCommercePlatform::Engine, at: '/solidus_paypal_commerce_platform'"
|
17
18
|
end
|
18
19
|
|
19
20
|
def install_solidus_backend_support
|
20
|
-
support_code_for(
|
21
|
+
support_code_for(:solidus_backend) do
|
21
22
|
append_file(
|
22
23
|
'vendor/assets/javascripts/spree/backend/all.js',
|
23
24
|
"//= require spree/backend/solidus_paypal_commerce_platform\n"
|
@@ -31,36 +32,49 @@ module SolidusPaypalCommercePlatform
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
-
support_code_for(
|
35
|
+
def install_solidus_starter_frontend_support
|
36
|
+
support_code_for(:solidus_starter_frontend) do
|
37
|
+
directory 'app', 'app'
|
36
38
|
append_file(
|
37
|
-
'
|
38
|
-
"//= require spree/frontend/solidus_paypal_commerce_platform\n"
|
39
|
+
'app/assets/javascripts/solidus_starter_frontend.js',
|
40
|
+
"//= require spree/frontend/solidus_paypal_commerce_platform\n"
|
39
41
|
)
|
40
42
|
inject_into_file(
|
41
|
-
'
|
43
|
+
'app/assets/stylesheets/solidus_starter_frontend.css',
|
42
44
|
" *= require spree/frontend/solidus_paypal_commerce_platform\n",
|
43
45
|
before: %r{\*/},
|
44
46
|
verbose: true,
|
45
47
|
)
|
46
|
-
directory engine.root.join("lib/views/frontend"), 'app/views/'
|
47
|
-
end
|
48
|
-
end
|
49
48
|
|
50
|
-
|
51
|
-
|
49
|
+
spec_paths =
|
50
|
+
case options[:specs]
|
51
|
+
when 'all' then %w[spec]
|
52
|
+
when 'frontend'
|
53
|
+
%w[
|
54
|
+
spec/solidus_paypal_commerce_platform_spec_helper.rb
|
55
|
+
spec/system/frontend
|
56
|
+
spec/support
|
57
|
+
]
|
58
|
+
end
|
52
59
|
|
53
|
-
|
60
|
+
spec_paths.each do |path|
|
61
|
+
if engine.root.join(path).directory?
|
62
|
+
directory engine.root.join(path), path
|
63
|
+
else
|
64
|
+
template engine.root.join(path), path
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
54
68
|
end
|
55
69
|
|
56
70
|
private
|
57
71
|
|
58
|
-
def support_code_for(
|
59
|
-
if
|
60
|
-
say_status :install, "[#{engine.engine_name}] #{
|
72
|
+
def support_code_for(component_name, &block)
|
73
|
+
if options[component_name]
|
74
|
+
say_status :install, "[#{engine.engine_name}] solidus_#{component_name}", :blue
|
61
75
|
shell.indent(&block)
|
62
76
|
else
|
63
|
-
say_status :skip, "[#{engine.engine_name}] #{
|
77
|
+
say_status :skip, "[#{engine.engine_name}] solidus_#{component_name}", :blue
|
64
78
|
end
|
65
79
|
end
|
66
80
|
|