solidus_paypal_commerce_platform 0.5.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/.github/stale.yml +1 -17
- data/.gitignore +1 -0
- data/.rspec +0 -1
- data/.rubocop.yml +3 -2
- data/CHANGELOG.md +42 -9
- data/Gemfile +0 -41
- data/README.md +9 -12
- data/Rakefile +6 -1
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +6 -5
- data/app/models/solidus_paypal_commerce_platform/paypal_address.rb +6 -2
- data/app/models/solidus_paypal_commerce_platform/paypal_order.rb +22 -15
- data/bin/dummy-app +37 -0
- data/bin/rails-dummy-app +17 -0
- data/bin/rspec +11 -0
- data/bin/sandbox +3 -29
- data/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb +62 -23
- 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/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/javascripts/spree/frontend/solidus_paypal_commerce_platform.js +7 -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 +2 -1
- 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/paypal_orders_controller.rb +1 -1
- 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/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/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/{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/generators/solidus_paypal_commerce_platform/install/templates/{initializer.rb → config/initializers/solidus_paypal_commerce_platform.rb} +0 -0
- data/lib/paypal/paypal_checkout_sdk/orders/orders_authorize_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_capture_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_create_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_get_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_patch_request.rb +0 -52
- data/lib/paypal/paypal_checkout_sdk/orders/orders_validate_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_capture_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_get_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_reauthorize_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_void_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/captures_get_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/captures_refund_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/refunds_get_request.rb +0 -2
- data/lib/paypal/paypal_http_client.rb +4 -4
- data/lib/solidus_paypal_commerce_platform/client.rb +6 -3
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_patch_request.rb +1 -54
- 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 -203
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/.github/stale.yml
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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/.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,5 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.0.0.beta1](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v1.0.0.beta1) (2022-12-05)
|
4
|
+
|
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)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
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))
|
19
|
+
|
20
|
+
## [v0.6.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.6.0) (2022-11-25)
|
21
|
+
|
22
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.5.0...v0.6.0)
|
23
|
+
|
24
|
+
**Fixed bugs:**
|
25
|
+
|
26
|
+
- Gem does not support Ruby 3.0 [\#145](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/145)
|
27
|
+
|
28
|
+
**Closed issues:**
|
29
|
+
|
30
|
+
- Invalid string length error [\#135](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/135)
|
31
|
+
- PayPal SDK JS Error: Disallowed query param: shipping\_preference [\#133](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/133)
|
32
|
+
|
3
33
|
## [v0.5.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.5.0) (2022-10-07)
|
4
34
|
|
5
35
|
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.4.0...v0.5.0)
|
@@ -7,8 +37,7 @@
|
|
7
37
|
**Merged pull requests:**
|
8
38
|
|
9
39
|
- Update links after moving to @solidusio [\#164](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/164) ([elia](https://github.com/elia))
|
10
|
-
-
|
11
|
-
- Require Solidus 3 & Ruby 2.7 [\#163](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/163) ([elia](https://github.com/elia))
|
40
|
+
- Assign created orders to users / Require Solidus 3 & Ruby 2.7 [\#163](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/163) ([elia](https://github.com/elia))
|
12
41
|
- Fix master, import paypal-checkout-sdk [\#161](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/161) ([cpfergus1](https://github.com/cpfergus1))
|
13
42
|
- Update to use forked solidus\_frontend when needed [\#160](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/160) ([waiting-for-dev](https://github.com/waiting-for-dev))
|
14
43
|
- Fix paypal\_order name address bug [\#153](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/153) ([RyanofWoods](https://github.com/RyanofWoods))
|
@@ -108,13 +137,7 @@
|
|
108
137
|
|
109
138
|
## [v0.2.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.2.0) (2020-10-13)
|
110
139
|
|
111
|
-
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.
|
112
|
-
|
113
|
-
**Closed issues:**
|
114
|
-
|
115
|
-
- README lists two different types of PayPal credentials [\#97](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/97)
|
116
|
-
- `paypal_email_confirmed` is not an actual preference [\#96](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/96)
|
117
|
-
- Make this extension the default option for Solidus [\#88](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/88)
|
140
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.2.0.alpha.1...v0.2.0)
|
118
141
|
|
119
142
|
**Merged pull requests:**
|
120
143
|
|
@@ -126,6 +149,16 @@
|
|
126
149
|
- Add skip migration option to installer [\#94](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/94) ([seand7565](https://github.com/seand7565))
|
127
150
|
- Update README to reflect referral fee [\#93](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/93) ([seand7565](https://github.com/seand7565))
|
128
151
|
|
152
|
+
## [v0.2.0.alpha.1](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.2.0.alpha.1) (2020-10-07)
|
153
|
+
|
154
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.1.0...v0.2.0.alpha.1)
|
155
|
+
|
156
|
+
**Closed issues:**
|
157
|
+
|
158
|
+
- README lists two different types of PayPal credentials [\#97](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/97)
|
159
|
+
- `paypal_email_confirmed` is not an actual preference [\#96](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/96)
|
160
|
+
- Make this extension the default option for Solidus [\#88](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/88)
|
161
|
+
|
129
162
|
## [v0.1.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.1.0) (2020-09-03)
|
130
163
|
|
131
164
|
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.0.1...v0.1.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
|
|
@@ -216,4 +213,4 @@ By using this extension, you are giving back to Solidus. PayPal will pay a fee t
|
|
216
213
|
|
217
214
|
## License
|
218
215
|
|
219
|
-
Copyright (c)
|
216
|
+
Copyright (c) 2022 Nebulab srls, released under the New BSD License
|
data/Rakefile
CHANGED
@@ -74,6 +74,8 @@ module SolidusPaypalCommercePlatform
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def javascript_sdk_url(order: nil, currency: nil)
|
77
|
+
# Ref: https://developer.paypal.com/sdk/js/configuration/
|
78
|
+
|
77
79
|
# Both instance and class respond to checkout_steps.
|
78
80
|
step_names = order ? order.checkout_steps : ::Spree::Order.checkout_steps.keys
|
79
81
|
|
@@ -84,17 +86,16 @@ module SolidusPaypalCommercePlatform
|
|
84
86
|
intent: auto_capture ? "capture" : "authorize",
|
85
87
|
commit: commit_immediately ? "false" : "true",
|
86
88
|
components: options[:display_credit_messaging] ? "buttons,messages" : "buttons",
|
87
|
-
currency: currency
|
89
|
+
currency: currency,
|
88
90
|
}
|
89
91
|
|
90
|
-
parameters[:shipping_preference] = 'NO_SHIPPING' if step_names.exclude? 'delivery'
|
91
92
|
parameters['enable-funding'] = 'venmo' if venmo_standalone_enabled?
|
92
93
|
|
93
|
-
|
94
|
-
parameters['buyer-country'] = options[:force_buyer_country]
|
94
|
+
unless Rails.env.production?
|
95
|
+
parameters['buyer-country'] = options[:force_buyer_country].presence
|
95
96
|
end
|
96
97
|
|
97
|
-
"https://www.paypal.com/sdk/js?#{parameters.to_query}"
|
98
|
+
"https://www.paypal.com/sdk/js?#{parameters.compact.to_query}".html_safe # rubocop:disable Rails/OutputSafety
|
98
99
|
end
|
99
100
|
end
|
100
101
|
end
|
@@ -61,12 +61,16 @@ module SolidusPaypalCommercePlatform
|
|
61
61
|
|
62
62
|
def address_attributes(address, recipient)
|
63
63
|
country = ::Spree::Country.find_by(iso: address[:country_code])
|
64
|
+
state = find_state(
|
65
|
+
address[:admin_area_1] || address[:admin_area_2] || address[:state],
|
66
|
+
country,
|
67
|
+
)
|
64
68
|
|
65
69
|
attributes = {
|
66
70
|
address1: address[:address_line_1],
|
67
71
|
address2: address[:address_line_2],
|
68
|
-
|
69
|
-
state_name:
|
72
|
+
state_id: state.try(:id),
|
73
|
+
state_name: state.try(:name),
|
70
74
|
city: address[:admin_area_2] || address[:city],
|
71
75
|
country: country,
|
72
76
|
zipcode: address[:postal_code],
|
@@ -10,14 +10,15 @@ module SolidusPaypalCommercePlatform
|
|
10
10
|
{
|
11
11
|
intent: intent,
|
12
12
|
purchase_units: purchase_units,
|
13
|
-
payer: (payer if @order.bill_address)
|
13
|
+
payer: (payer if @order.bill_address),
|
14
|
+
application_context: application_context
|
14
15
|
}
|
15
16
|
end
|
16
17
|
|
17
18
|
def to_replace_json
|
18
19
|
{
|
19
20
|
op: 'replace',
|
20
|
-
path:
|
21
|
+
path: "/purchase_units/@reference_id=='default'",
|
21
22
|
value: purchase_units(include_shipping_address: false)[0]
|
22
23
|
}
|
23
24
|
end
|
@@ -55,10 +56,10 @@ module SolidusPaypalCommercePlatform
|
|
55
56
|
def purchase_units(include_shipping_address: true)
|
56
57
|
[
|
57
58
|
{
|
58
|
-
amount:
|
59
|
+
amount: price(@order.total).merge(breakdown: breakdown),
|
59
60
|
items: line_items,
|
60
61
|
shipping: (shipping_info if @order.ship_address && include_shipping_address)
|
61
|
-
}
|
62
|
+
}.compact
|
62
63
|
]
|
63
64
|
end
|
64
65
|
|
@@ -79,21 +80,13 @@ module SolidusPaypalCommercePlatform
|
|
79
80
|
def line_items
|
80
81
|
@order.line_items.map{ |line_item|
|
81
82
|
{
|
82
|
-
name: line_item.product.name,
|
83
|
+
name: line_item.product.name.truncate(127),
|
83
84
|
unit_amount: price(line_item.price),
|
84
|
-
quantity: line_item.quantity
|
85
|
+
quantity: line_item.quantity.to_i.to_s
|
85
86
|
}
|
86
87
|
}
|
87
88
|
end
|
88
89
|
|
89
|
-
def amount
|
90
|
-
{
|
91
|
-
currency_code: @order.currency,
|
92
|
-
value: @order.total,
|
93
|
-
breakdown: breakdown
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
90
|
def breakdown
|
98
91
|
{
|
99
92
|
item_total: price(@order.item_total),
|
@@ -106,8 +99,22 @@ module SolidusPaypalCommercePlatform
|
|
106
99
|
def price(amount)
|
107
100
|
{
|
108
101
|
currency_code: @order.currency,
|
109
|
-
value: amount
|
102
|
+
value: ('%.2f' % amount.to_f)
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
def application_context
|
107
|
+
{
|
108
|
+
shipping_preference: require_shipping? ? 'SET_PROVIDED_ADDRESS' : 'NO_SHIPPING'
|
110
109
|
}
|
111
110
|
end
|
111
|
+
|
112
|
+
def require_shipping?
|
113
|
+
step_names.include? :delivery
|
114
|
+
end
|
115
|
+
|
116
|
+
def step_names
|
117
|
+
@order ? @order.checkout_steps.map(&:to_sym) : ::Spree::Order.checkout_steps.keys
|
118
|
+
end
|
112
119
|
end
|
113
120
|
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,35 +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 '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
|
-
|
51
|
+
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
|
68
52
|
unbundled bundle exec rake db:drop db:create
|
69
|
-
|
70
|
-
unbundled bundle exec rails generate solidus:install \
|
71
|
-
--auto-accept \
|
72
|
-
--user_class=Spree::User \
|
73
|
-
--enforce_available_locales=true \
|
74
|
-
--with-authentication=false \
|
75
|
-
--payment-method=none \
|
76
|
-
$@
|
77
|
-
|
78
|
-
unbundled bundle exec rails generate solidus:auth:install
|
79
|
-
unbundled bundle exec rails generate ${extension_name}:install
|
53
|
+
unbundled bundle exec rails generate solidus:install --auto-accept "$@"
|
80
54
|
|
81
55
|
echo
|
82
56
|
echo "🚀 Sandbox app successfully created for $extension_name!"
|