solidus_paypal_braintree 1.1.2 โ 1.2.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 +3 -0
- data/.github/stale.yml +1 -17
- data/.github_changelog_generator +2 -0
- data/.gitignore +4 -3
- data/.rubocop.yml +1 -2
- data/CHANGELOG.md +32 -0
- data/Gemfile +18 -20
- data/README.md +41 -17
- data/app/assets/stylesheets/spree/backend/solidus_paypal_braintree.css +4 -0
- data/app/models/solidus_paypal_braintree/configuration.rb +1 -3
- data/app/models/solidus_paypal_braintree/gateway.rb +1 -0
- data/app/models/solidus_paypal_braintree/source.rb +4 -2
- data/app/models/solidus_paypal_braintree/transaction_address.rb +1 -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 +103 -0
- data/bin/setup +1 -1
- data/lib/generators/solidus_paypal_braintree/install/install_generator.rb +9 -4
- data/lib/generators/solidus_paypal_braintree/install/templates/initializer.rb +6 -0
- data/lib/solidus_paypal_braintree/engine.rb +6 -5
- data/lib/solidus_paypal_braintree/extension_configuration.rb +23 -0
- data/lib/solidus_paypal_braintree/request_protection.rb +2 -2
- data/lib/solidus_paypal_braintree/{factories.rb โ testing_support/factories.rb} +0 -0
- data/lib/solidus_paypal_braintree/version.rb +1 -1
- data/lib/solidus_paypal_braintree.rb +5 -3
- data/solidus_paypal_braintree.gemspec +39 -39
- data/spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb +99 -0
- data/spec/controllers/solidus_paypal_braintree/client_tokens_controller_spec.rb +55 -0
- data/spec/controllers/solidus_paypal_braintree/configurations_controller_spec.rb +73 -0
- data/spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb +183 -0
- data/spec/features/backend/configuration_spec.rb +23 -0
- data/spec/features/backend/new_payment_spec.rb +137 -0
- data/spec/features/frontend/braintree_credit_card_checkout_spec.rb +191 -0
- data/spec/features/frontend/paypal_checkout_spec.rb +166 -0
- data/spec/features/frontend/venmo_checkout_spec.rb +194 -0
- data/spec/fixtures/cassettes/admin/invalid_credit_card.yml +63 -0
- data/spec/fixtures/cassettes/admin/resubmit_credit_card.yml +352 -0
- data/spec/fixtures/cassettes/admin/valid_credit_card.yml +412 -0
- data/spec/fixtures/cassettes/braintree/create_profile.yml +71 -0
- data/spec/fixtures/cassettes/braintree/generate_token.yml +63 -0
- data/spec/fixtures/cassettes/braintree/token.yml +63 -0
- data/spec/fixtures/cassettes/checkout/invalid_credit_card.yml +63 -0
- data/spec/fixtures/cassettes/checkout/resubmit_credit_card.yml +216 -0
- data/spec/fixtures/cassettes/checkout/update.yml +71 -0
- data/spec/fixtures/cassettes/checkout/valid_credit_card.yml +171 -0
- data/spec/fixtures/cassettes/checkout/valid_venmo_transaction.yml +599 -0
- data/spec/fixtures/cassettes/gateway/authorize/credit_card/address.yml +86 -0
- data/spec/fixtures/cassettes/gateway/authorize/merchant_account/EUR.yml +154 -0
- data/spec/fixtures/cassettes/gateway/authorize/paypal/EUR.yml +90 -0
- data/spec/fixtures/cassettes/gateway/authorize/paypal/address.yml +90 -0
- data/spec/fixtures/cassettes/gateway/authorize.yml +86 -0
- data/spec/fixtures/cassettes/gateway/authorized_transaction.yml +73 -0
- data/spec/fixtures/cassettes/gateway/cancel/missing.yml +63 -0
- data/spec/fixtures/cassettes/gateway/cancel/refunds.yml +272 -0
- data/spec/fixtures/cassettes/gateway/cancel/void.yml +201 -0
- data/spec/fixtures/cassettes/gateway/capture.yml +141 -0
- data/spec/fixtures/cassettes/gateway/complete.yml +157 -0
- data/spec/fixtures/cassettes/gateway/credit.yml +208 -0
- data/spec/fixtures/cassettes/gateway/customer.yml +79 -0
- data/spec/fixtures/cassettes/gateway/purchase.yml +87 -0
- data/spec/fixtures/cassettes/gateway/settled_transaction.yml +140 -0
- data/spec/fixtures/cassettes/gateway/void.yml +137 -0
- data/spec/fixtures/cassettes/source/bin.yml +295 -0
- data/spec/fixtures/cassettes/source/card_type.yml +267 -0
- data/spec/fixtures/cassettes/source/last4.yml +267 -0
- data/spec/fixtures/cassettes/transaction/import/valid/capture.yml +224 -0
- data/spec/fixtures/cassettes/transaction/import/valid.yml +71 -0
- data/spec/fixtures/views/spree/orders/edit.html.erb +50 -0
- data/spec/helpers/solidus_paypal_braintree/braintree_admin_helper_spec.rb +17 -0
- data/spec/helpers/solidus_paypal_braintree/braintree_checkout_helper_spec.rb +70 -0
- data/spec/models/solidus_paypal_braintree/address_spec.rb +71 -0
- data/spec/models/solidus_paypal_braintree/avs_result_spec.rb +317 -0
- data/spec/models/solidus_paypal_braintree/gateway_spec.rb +742 -0
- data/spec/models/solidus_paypal_braintree/response_spec.rb +280 -0
- data/spec/models/solidus_paypal_braintree/source_spec.rb +539 -0
- data/spec/models/solidus_paypal_braintree/transaction_address_spec.rb +235 -0
- data/spec/models/solidus_paypal_braintree/transaction_import_spec.rb +302 -0
- data/spec/models/solidus_paypal_braintree/transaction_spec.rb +86 -0
- data/spec/models/spree/store_spec.rb +14 -0
- data/spec/requests/spree/api/orders_controller_spec.rb +36 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/capybara.rb +7 -0
- data/spec/support/gateway_helpers.rb +29 -0
- data/spec/support/order_ready_for_payment.rb +37 -0
- data/spec/support/vcr.rb +42 -0
- data/spec/support/views.rb +1 -0
- metadata +146 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5a99cf586082f26611d58fc0ab61e282c4cbcc00ccf1bb26702fc1051a41ff0
|
4
|
+
data.tar.gz: fddad0e0df126342b1ae1b4d5267d6cce177b66a41c051ad4cfda28127bbd86a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad6a2ad7d62c46d6a801252db48ff2cadb08d29581601898a207ce5d46338373ec455999e6a46f1be9a62d0eb2785aa1e42373ff380c66bf9bdff029b9b5143a
|
7
|
+
data.tar.gz: 74c45a0105ffe812e456896c96455db6be96f500a400e9f2285e1cb5e650d16a77af68737f57df13d69eb0de6c80aade23ad3fc48f142024494c8271d90604ff
|
data/.circleci/config.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
version: 2.1
|
2
2
|
|
3
3
|
orbs:
|
4
|
+
# Required for feature specs.
|
4
5
|
browser-tools: circleci/browser-tools@1.1
|
5
6
|
|
6
7
|
# Always take the latest version of the orb, this allows us to
|
@@ -23,6 +24,7 @@ jobs:
|
|
23
24
|
lint-code:
|
24
25
|
executor: solidusio_extensions/sqlite-memory
|
25
26
|
steps:
|
27
|
+
- browser-tools/install-browser-tools
|
26
28
|
- solidusio_extensions/lint-code
|
27
29
|
|
28
30
|
workflows:
|
@@ -31,6 +33,7 @@ workflows:
|
|
31
33
|
- run-specs-with-postgres
|
32
34
|
- run-specs-with-mysql
|
33
35
|
- lint-code
|
36
|
+
|
34
37
|
"Weekly run specs against master":
|
35
38
|
triggers:
|
36
39
|
- schedule:
|
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: 7
|
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: wontfix
|
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 will 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/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.2.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.2.0) (2022-12-12)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v1.1.2...v1.2.0)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Sandbox script is not able to install bundle due to empty $BRANCH value [\#337](https://github.com/solidusio/solidus_paypal_braintree/issues/337)
|
10
|
+
- Do not safeguard including of Spree::Preferences::Persistable [\#316](https://github.com/solidusio/solidus_paypal_braintree/pull/316) ([tvdeyen](https://github.com/tvdeyen))
|
11
|
+
|
12
|
+
**Merged pull requests:**
|
13
|
+
|
14
|
+
- Update to the latest dev-support defaults [\#339](https://github.com/solidusio/solidus_paypal_braintree/pull/339) ([elia](https://github.com/elia))
|
15
|
+
- Fix setup intructions on Rails 7 [\#332](https://github.com/solidusio/solidus_paypal_braintree/pull/332) ([waiting-for-dev](https://github.com/waiting-for-dev))
|
16
|
+
- Fix sandbox generator [\#329](https://github.com/solidusio/solidus_paypal_braintree/pull/329) ([RyanofWoods](https://github.com/RyanofWoods))
|
17
|
+
- Fix broken specs [\#328](https://github.com/solidusio/solidus_paypal_braintree/pull/328) ([RyanofWoods](https://github.com/RyanofWoods))
|
18
|
+
- Drop compatibility with Solidus \< 2.4 [\#326](https://github.com/solidusio/solidus_paypal_braintree/pull/326) ([mamhoff](https://github.com/mamhoff))
|
19
|
+
- Add BIN \(bank identification number\) to SolidusPaypalBraintree::Source [\#308](https://github.com/solidusio/solidus_paypal_braintree/pull/308) ([RyanofWoods](https://github.com/RyanofWoods))
|
20
|
+
- Improve README PayPal styling information [\#307](https://github.com/solidusio/solidus_paypal_braintree/pull/307) ([RyanofWoods](https://github.com/RyanofWoods))
|
21
|
+
- Make extension compliant to solidus\_dev\_support [\#289](https://github.com/solidusio/solidus_paypal_braintree/pull/289) ([MinasMazar](https://github.com/MinasMazar))
|
22
|
+
|
23
|
+
## [v1.1.2](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.1.2) (2022-10-14)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v1.1.1...v1.1.2)
|
26
|
+
|
27
|
+
**Merged pull requests:**
|
28
|
+
|
29
|
+
- Fix broken factory [\#325](https://github.com/solidusio/solidus_paypal_braintree/pull/325) ([johnpitchko](https://github.com/johnpitchko))
|
30
|
+
- Update to use forked solidus\_frontend when needed [\#324](https://github.com/solidusio/solidus_paypal_braintree/pull/324) ([waiting-for-dev](https://github.com/waiting-for-dev))
|
31
|
+
- Fix specs to stub spree\_current\_user [\#323](https://github.com/solidusio/solidus_paypal_braintree/pull/323) ([gsmendoza](https://github.com/gsmendoza))
|
32
|
+
- Bump Rubocop TargetRubyVersion from 2.5 to 2.6 [\#319](https://github.com/solidusio/solidus_paypal_braintree/pull/319) ([RyanofWoods](https://github.com/RyanofWoods))
|
33
|
+
- Fix exception when other payment methods active [\#318](https://github.com/solidusio/solidus_paypal_braintree/pull/318) ([embold-tyler](https://github.com/embold-tyler))
|
34
|
+
|
3
35
|
## [v1.1.1](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.1.1) (2022-06-30)
|
4
36
|
|
5
37
|
[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v1.1.0...v1.1.1)
|
data/Gemfile
CHANGED
@@ -4,25 +4,20 @@ 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
|
-
|
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
|
7
|
+
gem 'solidus', github: 'solidusio/solidus', branch: branch
|
14
8
|
|
15
|
-
gem
|
9
|
+
# The solidus_frontend gem has been pulled out since v3.2
|
10
|
+
gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
|
11
|
+
gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem
|
12
|
+
|
13
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
14
|
+
# otherwise it takes forever to resolve them.
|
15
|
+
# See https://github.com/bundler/bundler/issues/6677
|
16
|
+
gem 'rails', '>0.a'
|
16
17
|
|
17
18
|
# Provides basic authentication functionality for testing parts of your engine
|
18
19
|
gem 'solidus_auth_devise'
|
19
20
|
|
20
|
-
# Asset compilation speed
|
21
|
-
gem 'mini_racer'
|
22
|
-
gem 'sassc-rails', platforms: :mri
|
23
|
-
|
24
|
-
gem 'bourbon'
|
25
|
-
|
26
21
|
case ENV.fetch('DB', nil)
|
27
22
|
when 'mysql'
|
28
23
|
gem 'mysql2'
|
@@ -32,13 +27,16 @@ else
|
|
32
27
|
gem 'sqlite3'
|
33
28
|
end
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
# While we still support Ruby < 3 we need to workaround a limitation in
|
31
|
+
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
|
32
|
+
# resolve gems based on the required ruby version.
|
33
|
+
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
|
39
34
|
|
40
35
|
gemspec
|
41
36
|
|
42
37
|
# Use a local Gemfile to include development dependencies that might not be
|
43
|
-
# relevant for the project or for other contributors, e.g
|
44
|
-
|
38
|
+
# relevant for the project or for other contributors, e.g. pry-byebug.
|
39
|
+
#
|
40
|
+
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
41
|
+
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
42
|
+
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
SolidusPaypalBraintree
|
2
|
-
======================
|
1
|
+
# SolidusPaypalBraintree
|
3
2
|
|
4
|
-
[![CircleCI](https://circleci.com/gh/solidusio/solidus_paypal_braintree.svg?style=
|
3
|
+
[![CircleCI](https://circleci.com/gh/solidusio/solidus_paypal_braintree.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_paypal_braintree)
|
4
|
+
[![codecov](https://codecov.io/gh/solidusio/solidus_paypal_braintree/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_paypal_braintree)
|
5
5
|
|
6
6
|
`solidus_paypal_braintree` is an extension that adds support for using [Braintree](https://www.braintreepayments.com) as a payment source in your [Solidus](https://solidus.io/) store. It supports Apple Pay, PayPal, and credit card transactions.
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
๐ง This extension is currently only compatible with the legacy `solidus_frontend` ๐ง
|
9
|
+
|
10
|
+
## Installation
|
10
11
|
|
11
12
|
Add solidus_paypal_braintree to your Gemfile:
|
12
13
|
|
@@ -39,8 +40,8 @@ Payment methods can accept preferences either directly entered in admin, or from
|
|
39
40
|
1. Set static preferences in an initializer
|
40
41
|
```ruby
|
41
42
|
# config/initializers/spree.rb
|
42
|
-
|
43
|
-
|
43
|
+
Rails.application.config.to_prepare do
|
44
|
+
Spree::Config.static_model_preferences.add(
|
44
45
|
SolidusPaypalBraintree::Gateway,
|
45
46
|
'braintree_credentials', {
|
46
47
|
environment: Rails.env.production? ? 'production' : 'sandbox',
|
@@ -198,19 +199,22 @@ Note, other images such as Venmo's full logo and shortened "V" logo are included
|
|
198
199
|
|
199
200
|
Ensure that you follow [Venmo's guidelines](https://developer.paypal.com/braintree/docs/files/venmo-merchant-integration-guidelines.pdf) when making other style changes, otherwise failing to comply can lead to an interruption of your Venmo service.
|
200
201
|
|
201
|
-
PayPal
|
202
|
-
------
|
202
|
+
## PayPal
|
203
203
|
|
204
204
|
A default checkout view is provided that will display PayPal as a payment option.
|
205
205
|
It will only be displayed if the `SolidusPaypalBraintree::Gateway` payment
|
206
206
|
method is configured to display on the frontend and PayPal is enabled in the
|
207
207
|
store's configuration.
|
208
208
|
|
209
|
-
You can find button configuration options in
|
209
|
+
You can find button configuration options in
|
210
210
|
`/solidus_paypal_braintree/configurations/list` if you want to change the color,
|
211
|
-
shape, layout, and a few other options.
|
212
|
-
|
213
|
-
|
211
|
+
shape, layout, and a few other options. For more information check out
|
212
|
+
[PayPal's documentation](https://developer.paypal.com/docs/platforms/checkout/reference/style-guide/#layout).
|
213
|
+
|
214
|
+
Keep in mind that:
|
215
|
+
- `paypal_button_tagline` does not work when the `paypal_button_layout` is set to `vertical`, and will be ignored; and
|
216
|
+
- `paypal_button_layout` of `horizontal` limits financing options/buttons to 2, where as `vertical` is 4.
|
217
|
+
Other available financing options after the limit will not be rendered in the PayPal's iframe DOM.
|
214
218
|
|
215
219
|
The checkout view
|
216
220
|
[initializes the PayPal button](/lib/views/frontend/spree/checkout/payment/_paypal_braintree.html.erb)
|
@@ -336,8 +340,7 @@ Once enabled, you can use the following card numbers to test 3DS 2 on your
|
|
336
340
|
client side in sandbox:
|
337
341
|
https://developers.braintreepayments.com/guides/3d-secure/migration/javascript/v3#client-side-sandbox-testing.
|
338
342
|
|
339
|
-
Testing
|
340
|
-
-------
|
343
|
+
## Testing
|
341
344
|
|
342
345
|
To run the specs it is required to set the Braintree test account data in these environment variables:
|
343
346
|
`BRAINTREE_PUBLIC_KEY`, `BRAINTREE_PRIVATE_KEY`, `BRAINTREE_MERCHANT_ID` and `BRAINTREE_PAYPAL_PAYEE_EMAIL`
|
@@ -356,14 +359,35 @@ Simply add this require statement to your spec_helper:
|
|
356
359
|
require 'solidus_paypal_braintree/factories'
|
357
360
|
```
|
358
361
|
|
359
|
-
Development
|
360
|
-
-------
|
362
|
+
## Development
|
361
363
|
|
362
364
|
### Mocking your buyer country
|
363
365
|
PayPal looks at the buyer's IP geolocation to determine what funding sources should be available to them. Because for example, Venmo is currently only available to US buyers. Because of this, you may want to pretend that you are from US so you can check if 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.
|
364
366
|
|
365
367
|
This preference has no effect on production.
|
366
368
|
|
369
|
+
### Running the sandbox
|
370
|
+
|
371
|
+
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
372
|
+
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
|
373
|
+
`sandbox/bin/rails`.
|
374
|
+
|
375
|
+
Here's an example:
|
376
|
+
|
377
|
+
```
|
378
|
+
$ bin/rails server
|
379
|
+
=> Booting Puma
|
380
|
+
=> Rails 7.0.4 application starting in development
|
381
|
+
* Listening on tcp://127.0.0.1:3000
|
382
|
+
Use Ctrl-C to stop
|
383
|
+
```
|
384
|
+
|
385
|
+
|
386
|
+
### Releasing new versions
|
387
|
+
|
388
|
+
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
|
389
|
+
|
390
|
+
|
367
391
|
## License
|
368
392
|
|
369
393
|
Copyright (c) 2016-2020 Stembolt and others contributors, released under the New BSD License
|
@@ -11,9 +11,7 @@ module SolidusPaypalBraintree
|
|
11
11
|
messaging: { availables: %w[true false], default: 'false' }
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
|
15
|
-
include ::Spree::Preferences::Persistable
|
16
|
-
end
|
14
|
+
include ::Spree::Preferences::Persistable
|
17
15
|
|
18
16
|
belongs_to :store, class_name: 'Spree::Store', optional: false
|
19
17
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'solidus_paypal_braintree/request_protection'
|
4
|
+
|
3
5
|
module SolidusPaypalBraintree
|
4
|
-
class Source <
|
6
|
+
class Source < ::Spree::PaymentSource
|
5
7
|
include RequestProtection
|
6
8
|
|
7
9
|
PAYPAL = "PayPalAccount"
|
@@ -28,7 +30,7 @@ module SolidusPaypalBraintree
|
|
28
30
|
scope(:with_payment_profile, -> { joins(:customer) })
|
29
31
|
scope(:credit_card, -> { where(payment_type: CREDIT_CARD) })
|
30
32
|
|
31
|
-
delegate :last_4, :card_type, :expiration_month, :expiration_year, :email,
|
33
|
+
delegate :bin, :last_4, :card_type, :expiration_month, :expiration_year, :email,
|
32
34
|
:username, :source_description, to: :braintree_payment_method, allow_nil: true
|
33
35
|
|
34
36
|
# Aliases to match Spree::CreditCard's interface
|
data/bin/rails
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
unless File.exist? "#{app_root}/bin/rails"
|
8
|
-
system "bin/rake", app_root or begin
|
9
|
-
warn "Automatic creation of the dummy app failed"
|
10
|
-
exit 1
|
11
|
-
end
|
3
|
+
if %w[g generate].include? ARGV.first
|
4
|
+
exec "#{__dir__}/rails-engine", *ARGV
|
5
|
+
else
|
6
|
+
exec "#{__dir__}/rails-sandbox", *ARGV
|
12
7
|
end
|
13
|
-
|
14
|
-
Dir.chdir app_root
|
15
|
-
exec 'bin/rails', *ARGV
|
data/bin/rails-engine
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_paypal_braintree/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/rails-sandbox
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
app_root = 'sandbox'
|
4
|
+
|
5
|
+
unless File.exist? "#{app_root}/bin/rails"
|
6
|
+
warn 'Creating the sandbox app...'
|
7
|
+
Dir.chdir "#{__dir__}/.." do
|
8
|
+
system "#{__dir__}/sandbox" or begin
|
9
|
+
warn 'Automatic creation of the sandbox app failed'
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir.chdir app_root
|
16
|
+
exec 'bin/rails', *ARGV
|
data/bin/rake
ADDED
data/bin/sandbox
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
if [ -n "$DEBUG" ]
|
5
|
+
then
|
6
|
+
set -x
|
7
|
+
fi
|
8
|
+
|
9
|
+
case "$DB" in
|
10
|
+
postgres|postgresql)
|
11
|
+
RAILSDB="postgresql"
|
12
|
+
;;
|
13
|
+
mysql)
|
14
|
+
RAILSDB="mysql"
|
15
|
+
;;
|
16
|
+
sqlite3|sqlite)
|
17
|
+
RAILSDB="sqlite3"
|
18
|
+
;;
|
19
|
+
'')
|
20
|
+
echo "~~> Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
|
21
|
+
RAILSDB="sqlite3"
|
22
|
+
;;
|
23
|
+
*)
|
24
|
+
echo "Invalid value specified for the Solidus sandbox: DB=\"$DB\"."
|
25
|
+
echo "Please use 'postgres', 'mysql', or 'sqlite' instead."
|
26
|
+
exit 1
|
27
|
+
;;
|
28
|
+
esac
|
29
|
+
echo "~~> Using $RAILSDB as the database engine"
|
30
|
+
|
31
|
+
if [ -z "$SOLIDUS_BRANCH" ]
|
32
|
+
then
|
33
|
+
echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch"
|
34
|
+
SOLIDUS_BRANCH="master"
|
35
|
+
fi
|
36
|
+
echo "~~> Using branch $SOLIDUS_BRANCH of solidus"
|
37
|
+
|
38
|
+
if [ -z "$SOLIDUS_FRONTEND" ]
|
39
|
+
then
|
40
|
+
echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
|
41
|
+
SOLIDUS_FRONTEND="solidus_frontend"
|
42
|
+
fi
|
43
|
+
echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"
|
44
|
+
|
45
|
+
extension_name="solidus_paypal_braintree"
|
46
|
+
|
47
|
+
# Stay away from the bundler env of the containing extension.
|
48
|
+
function unbundled {
|
49
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
|
50
|
+
}
|
51
|
+
|
52
|
+
rm -rf ./sandbox
|
53
|
+
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
|
54
|
+
--skip-bundle \
|
55
|
+
--skip-git \
|
56
|
+
--skip-keeps \
|
57
|
+
--skip-rc \
|
58
|
+
--skip-spring \
|
59
|
+
--skip-test \
|
60
|
+
--skip-javascript
|
61
|
+
|
62
|
+
if [ ! -d "sandbox" ]; then
|
63
|
+
echo 'sandbox rails application failed'
|
64
|
+
exit 1
|
65
|
+
fi
|
66
|
+
|
67
|
+
cd ./sandbox
|
68
|
+
cat <<RUBY >> Gemfile
|
69
|
+
gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
|
70
|
+
gem 'rails-i18n'
|
71
|
+
gem 'solidus_i18n'
|
72
|
+
|
73
|
+
# This Braintree extension contains a user decorator, so the user class must be loaded first.
|
74
|
+
gem "solidus_auth_devise", "~> 2.5"
|
75
|
+
gem '$extension_name', path: '..'
|
76
|
+
|
77
|
+
group :test, :development do
|
78
|
+
platforms :mri do
|
79
|
+
gem 'pry-byebug'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
RUBY
|
83
|
+
|
84
|
+
unbundled bundle install --gemfile Gemfile
|
85
|
+
|
86
|
+
unbundled bundle exec rake db:drop db:create
|
87
|
+
|
88
|
+
# Still request "devise". Solidus will skip installing it again but will include its seeds.
|
89
|
+
unbundled bundle exec rails generate solidus:install \
|
90
|
+
--auto-accept \
|
91
|
+
--user_class=Spree::User \
|
92
|
+
--enforce_available_locales=true \
|
93
|
+
--authentication="devise" \
|
94
|
+
--payment-method=none \
|
95
|
+
--frontend=${SOLIDUS_FRONTEND} \
|
96
|
+
$@
|
97
|
+
|
98
|
+
unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
|
99
|
+
unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations
|
100
|
+
|
101
|
+
echo
|
102
|
+
echo "๐ Sandbox app successfully created for $extension_name!"
|
103
|
+
echo "๐งช This app is intended for test purposes."
|
data/bin/setup
CHANGED
@@ -4,9 +4,14 @@ module SolidusPaypalBraintree
|
|
4
4
|
module Generators
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
6
|
class_option :auto_run_migrations, type: :boolean, default: false
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
def copy_initializer
|
10
|
+
template 'initializer.rb', 'config/initializers/solidus_paypal_braintree.rb'
|
11
|
+
end
|
7
12
|
|
8
13
|
def add_javascripts
|
9
|
-
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require
|
14
|
+
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_paypal_braintree\n" # rubocop:disable Layout/LineLength
|
10
15
|
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_paypal_braintree\n" # rubocop:disable Layout/LineLength
|
11
16
|
end
|
12
17
|
|
@@ -16,7 +21,7 @@ module SolidusPaypalBraintree
|
|
16
21
|
end
|
17
22
|
|
18
23
|
def add_migrations
|
19
|
-
run '
|
24
|
+
run 'bin/rails railties:install:migrations FROM=solidus_paypal_braintree'
|
20
25
|
end
|
21
26
|
|
22
27
|
def mount_engine
|
@@ -28,9 +33,9 @@ module SolidusPaypalBraintree
|
|
28
33
|
def run_migrations
|
29
34
|
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
|
30
35
|
if run_migrations
|
31
|
-
run '
|
36
|
+
run 'bin/rails db:migrate'
|
32
37
|
else
|
33
|
-
|
38
|
+
puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'solidus_core'
|
3
4
|
require 'solidus_support'
|
4
5
|
|
5
6
|
module SolidusPaypalBraintree
|
@@ -13,11 +14,6 @@ module SolidusPaypalBraintree
|
|
13
14
|
inflect.acronym 'AVS'
|
14
15
|
end
|
15
16
|
|
16
|
-
# use rspec for tests
|
17
|
-
config.generators do |g|
|
18
|
-
g.test_framework :rspec
|
19
|
-
end
|
20
|
-
|
21
17
|
initializer "register_solidus_paypal_braintree_gateway", after: "spree.register.payment_methods" do |app|
|
22
18
|
config.to_prepare do
|
23
19
|
app.config.spree.payment_methods << SolidusPaypalBraintree::Gateway
|
@@ -64,5 +60,10 @@ module SolidusPaypalBraintree
|
|
64
60
|
end
|
65
61
|
end
|
66
62
|
end
|
63
|
+
|
64
|
+
# use rspec for tests
|
65
|
+
config.generators do |g|
|
66
|
+
g.test_framework :rspec
|
67
|
+
end
|
67
68
|
end
|
68
69
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusPaypalBraintree
|
4
|
+
# Deviating from the usual `Configuration` name proposed by
|
5
|
+
# `solidus_dev_support` because it's already taken by a model.
|
6
|
+
class ExtensionConfiguration
|
7
|
+
# Define here the settings for this extension, e.g.:
|
8
|
+
#
|
9
|
+
# attr_accessor :my_setting
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def configuration
|
14
|
+
@configuration ||= ExtensionConfiguration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
alias config configuration
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield configuration
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -6,7 +6,7 @@ module SolidusPaypalBraintree
|
|
6
6
|
module RequestProtection
|
7
7
|
include ActiveMerchant::NetworkConnectionRetries
|
8
8
|
|
9
|
-
def protected_request
|
9
|
+
def protected_request(&block)
|
10
10
|
raise ArgumentError unless block_given?
|
11
11
|
|
12
12
|
options = {
|
@@ -15,7 +15,7 @@ module SolidusPaypalBraintree
|
|
15
15
|
},
|
16
16
|
logger: Rails.logger
|
17
17
|
}
|
18
|
-
retry_exceptions(options)
|
18
|
+
retry_exceptions(options, &block)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
File without changes
|