solidus_braintree 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/lint.yml +25 -0
  4. data/.github/workflows/test.yml +77 -0
  5. data/.rubocop.yml +5 -84
  6. data/.standard.yml +6 -0
  7. data/Gemfile +12 -17
  8. data/README.md +7 -5
  9. data/Rakefile +7 -7
  10. data/app/helpers/solidus_braintree/braintree_admin_helper.rb +4 -4
  11. data/app/models/solidus_braintree/avs_result.rb +34 -34
  12. data/app/models/solidus_braintree/base_record.rb +1 -1
  13. data/app/models/solidus_braintree/configuration.rb +11 -11
  14. data/app/models/solidus_braintree/gateway.rb +14 -16
  15. data/app/models/solidus_braintree/response.rb +9 -9
  16. data/app/models/solidus_braintree/source.rb +5 -5
  17. data/app/models/solidus_braintree/transaction.rb +2 -2
  18. data/app/models/solidus_braintree/transaction_address.rb +5 -5
  19. data/app/models/solidus_braintree/transaction_import.rb +2 -2
  20. data/app/{decorators/models/solidus_braintree/spree_store_decorator.rb → patches/models/solidus_braintree/spree_store_patch.rb} +1 -1
  21. data/app/{decorators/models/solidus_braintree/spree_user_decorator.rb → patches/models/solidus_braintree/spree_user_patch.rb} +2 -2
  22. data/bin/dummy-app +22 -3
  23. data/bin/rails-sandbox +4 -4
  24. data/bin/rspec +6 -0
  25. data/bin/sandbox +55 -31
  26. data/db/migrate/20161114231422_create_solidus_paypal_braintree_configurations.rb +2 -2
  27. data/db/migrate/20170508085402_add_not_null_constraint_to_sources_payment_type.rb +2 -2
  28. data/db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb +3 -3
  29. data/lib/controllers/api/solidus_braintree/client_tokens_controller.rb +2 -2
  30. data/lib/controllers/backend/solidus_braintree/configurations_controller.rb +4 -4
  31. data/lib/generators/solidus_braintree/install/install_generator.rb +48 -40
  32. data/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb +7 -7
  33. data/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/transactions_controller.rb +7 -7
  34. data/lib/generators/solidus_braintree/install/templates/app/helpers/solidus_braintree/braintree_checkout_helper.rb +5 -5
  35. data/{app/decorators/controllers/solidus_braintree/admin_payments_controller_decorator.rb → lib/patches/backend/controllers/solidus_braintree/admin_payments_controller_patch.rb} +1 -1
  36. data/lib/solidus_braintree/engine.rb +13 -24
  37. data/lib/solidus_braintree/extension_configuration.rb +1 -1
  38. data/lib/solidus_braintree/request_protection.rb +2 -2
  39. data/lib/solidus_braintree/version.rb +1 -1
  40. data/lib/solidus_braintree.rb +8 -8
  41. data/lib/solidus_paypal_braintree.rb +2 -2
  42. data/mise.toml +2 -0
  43. data/solidus_braintree.gemspec +23 -22
  44. metadata +59 -147
  45. data/.circleci/config.yml +0 -79
  46. data/lib/views/backend_v1.2/spree/admin/payments/source_forms/_braintree.html.erb +0 -16
  47. data/lib/views/backend_v2.4/spree/admin/shared/preference_fields/_hash.html.erb +0 -12
  48. data/spec/controllers/solidus_braintree/checkouts_controller_spec.rb +0 -99
  49. data/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb +0 -55
  50. data/spec/controllers/solidus_braintree/configurations_controller_spec.rb +0 -73
  51. data/spec/controllers/solidus_braintree/transactions_controller_spec.rb +0 -183
  52. data/spec/fixtures/cassettes/admin/invalid_credit_card.yml +0 -63
  53. data/spec/fixtures/cassettes/admin/resubmit_credit_card.yml +0 -352
  54. data/spec/fixtures/cassettes/admin/valid_credit_card.yml +0 -412
  55. data/spec/fixtures/cassettes/braintree/create_profile.yml +0 -71
  56. data/spec/fixtures/cassettes/braintree/generate_token.yml +0 -63
  57. data/spec/fixtures/cassettes/braintree/token.yml +0 -63
  58. data/spec/fixtures/cassettes/checkout/invalid_credit_card.yml +0 -63
  59. data/spec/fixtures/cassettes/checkout/resubmit_credit_card.yml +0 -216
  60. data/spec/fixtures/cassettes/checkout/update.yml +0 -71
  61. data/spec/fixtures/cassettes/checkout/valid_credit_card.yml +0 -171
  62. data/spec/fixtures/cassettes/checkout/valid_venmo_transaction.yml +0 -599
  63. data/spec/fixtures/cassettes/gateway/authorize/credit_card/address.yml +0 -86
  64. data/spec/fixtures/cassettes/gateway/authorize/merchant_account/EUR.yml +0 -154
  65. data/spec/fixtures/cassettes/gateway/authorize/paypal/EUR.yml +0 -90
  66. data/spec/fixtures/cassettes/gateway/authorize/paypal/address.yml +0 -90
  67. data/spec/fixtures/cassettes/gateway/authorize.yml +0 -86
  68. data/spec/fixtures/cassettes/gateway/authorized_transaction.yml +0 -73
  69. data/spec/fixtures/cassettes/gateway/cancel/missing.yml +0 -63
  70. data/spec/fixtures/cassettes/gateway/cancel/refunds.yml +0 -272
  71. data/spec/fixtures/cassettes/gateway/cancel/void.yml +0 -201
  72. data/spec/fixtures/cassettes/gateway/capture.yml +0 -141
  73. data/spec/fixtures/cassettes/gateway/complete.yml +0 -157
  74. data/spec/fixtures/cassettes/gateway/credit.yml +0 -208
  75. data/spec/fixtures/cassettes/gateway/customer.yml +0 -79
  76. data/spec/fixtures/cassettes/gateway/purchase.yml +0 -87
  77. data/spec/fixtures/cassettes/gateway/settled_transaction.yml +0 -140
  78. data/spec/fixtures/cassettes/gateway/void.yml +0 -137
  79. data/spec/fixtures/cassettes/source/bin.yml +0 -295
  80. data/spec/fixtures/cassettes/source/card_type.yml +0 -267
  81. data/spec/fixtures/cassettes/source/last4.yml +0 -267
  82. data/spec/fixtures/cassettes/transaction/import/valid/capture.yml +0 -224
  83. data/spec/fixtures/cassettes/transaction/import/valid.yml +0 -71
  84. data/spec/fixtures/views/carts/_cart_footer.html.erb +0 -18
  85. data/spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb +0 -17
  86. data/spec/helpers/solidus_braintree/braintree_checkout_helper_spec.rb +0 -70
  87. data/spec/models/solidus_braintree/address_spec.rb +0 -71
  88. data/spec/models/solidus_braintree/avs_result_spec.rb +0 -317
  89. data/spec/models/solidus_braintree/gateway_spec.rb +0 -774
  90. data/spec/models/solidus_braintree/response_spec.rb +0 -280
  91. data/spec/models/solidus_braintree/source_spec.rb +0 -555
  92. data/spec/models/solidus_braintree/transaction_address_spec.rb +0 -235
  93. data/spec/models/solidus_braintree/transaction_import_spec.rb +0 -302
  94. data/spec/models/solidus_braintree/transaction_spec.rb +0 -86
  95. data/spec/models/spree/store_spec.rb +0 -14
  96. data/spec/requests/spree/api/orders_controller_spec.rb +0 -36
  97. data/spec/solidus_braintree_spec_helper.rb +0 -9
  98. data/spec/support/solidus_braintree/capybara.rb +0 -7
  99. data/spec/support/solidus_braintree/factories.rb +0 -55
  100. data/spec/support/solidus_braintree/gateway_helpers.rb +0 -29
  101. data/spec/support/solidus_braintree/order_ready_for_payment.rb +0 -44
  102. data/spec/support/solidus_braintree/order_walkthrough.rb +0 -87
  103. data/spec/support/solidus_braintree/vcr.rb +0 -38
  104. data/spec/support/solidus_braintree/with_prepended_view_fixtures.rb +0 -19
  105. data/spec/system/backend/configuration_spec.rb +0 -23
  106. data/spec/system/backend/new_payment_spec.rb +0 -136
  107. data/spec/system/frontend/braintree_credit_card_checkout_spec.rb +0 -199
  108. data/spec/system/frontend/paypal_checkout_spec.rb +0 -168
  109. data/spec/system/frontend/venmo_checkout_spec.rb +0 -193
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c477c4fb737d9baee566d1ab8b32a9c7392568ff6eeb50626fc6051a207a8bd
4
- data.tar.gz: 571f9fcea4d239cba51c81df5f8b4ce311041531a1f1224d38f0958cdce662f1
3
+ metadata.gz: 20decb10931454aa4855df2b427a24c1f22f502b363ebba35b13e2757eeb53b3
4
+ data.tar.gz: 3d93d374dc39443b75e2473de2c073d0357b087df6d44a5436cf8fc4fb37c0d8
5
5
  SHA512:
6
- metadata.gz: 34832b18ee08aa908a519c85c3c4e5d1b2593a540503791105f7a49f23599d851aa58544795e8ae5e5e30c2e2feddc1e7762c9d0e7ee80a6ca682ec3848d66e0
7
- data.tar.gz: '085b9c9baad9f06b98239ecaf625fdfe6b32aa025ebd58d5672d06a0202934416262f89675fdea4e9e1c6f0ac321872446e8cecb8e87cca0c4da609b2c7a0dae'
6
+ metadata.gz: 63729983efe298f30fdbaa79e951c8f8e8ec3dcea9378dce4d7249054784f286518cc4ec7fbbb1c39e9e662617bd6b15ebf3354dfcc6f79c80b39da0bc47888f
7
+ data.tar.gz: d18c988f0d90d5045bb3e6ecd00bd925afd638d4deebdd846d7dd2ac27aa22a8feb56eeedde53a87d1cf62efc000fb6aeb93664fbeb605dd12a9bb8b52aa9d6e
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
@@ -0,0 +1,25 @@
1
+ name: Lint
2
+
3
+ on: [pull_request]
4
+
5
+ concurrency:
6
+ group: lint-${{ github.ref_name }}
7
+ cancel-in-progress: ${{ github.ref_name != 'main' }}
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ ruby:
14
+ name: Check Ruby
15
+ runs-on: ubuntu-24.04
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v3
19
+ - name: Install Ruby and gems
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: "3.2"
23
+ bundler-cache: true
24
+ - name: Lint Ruby files
25
+ run: bundle exec standardrb
@@ -0,0 +1,77 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ schedule:
9
+ - cron: "0 0 * * 4" # every Thursday
10
+
11
+ concurrency:
12
+ group: test-${{ github.ref_name }}
13
+ cancel-in-progress: ${{ github.ref_name != 'main' }}
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ rspec:
20
+ name: Solidus ${{ matrix.solidus_branch }}, Rails ${{ matrix.rails_version }} and Ruby ${{ matrix.ruby_version }} on ${{ matrix.database }}
21
+ runs-on: ubuntu-24.04
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ rails_version: ["8.1", "8.0"]
26
+ ruby_version: ["3.4", "4.0"]
27
+ solidus_branch: ["v4.6", "v4.7", "v4.8"]
28
+ database: ["postgresql", "mysql", "sqlite"]
29
+ exclude:
30
+ - solidus_branch: "v4.6"
31
+ rails_version: "8.1"
32
+ env:
33
+ BRAINTREE_PUBLIC_KEY: ${{ secrets.BRAINTREE_PUBLIC_KEY }}
34
+ BRAINTREE_PRIVATE_KEY: ${{ secrets.BRAINTREE_PRIVATE_KEY }}
35
+ BRAINTREE_MERCHANT_ID: ${{ secrets.BRAINTREE_MERCHANT_ID }}
36
+ BRAINTREE_PAYPAL_PAYEE_EMAIL: ${{ secrets.BRAINTREE_PAYPAL_PAYEE_EMAIL }}
37
+ services:
38
+ postgres:
39
+ image: postgres:18
40
+ env:
41
+ POSTGRES_HOST_AUTH_METHOD: trust
42
+ options: >-
43
+ --health-cmd="pg_isready"
44
+ --health-interval=10s
45
+ --health-timeout=5s
46
+ --health-retries=5
47
+ ports:
48
+ - 5432:5432
49
+ mysql:
50
+ image: mysql:8
51
+ env:
52
+ MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
53
+ options: >-
54
+ --health-cmd="mysqladmin ping"
55
+ --health-interval=10s
56
+ --health-timeout=5s
57
+ --health-retries=5
58
+ ports:
59
+ - 3306:3306
60
+ steps:
61
+ - uses: actions/checkout@v4
62
+ - name: Run extension tests
63
+ uses: solidusio/test-solidus-extension@main
64
+ with:
65
+ database: ${{ matrix.database }}
66
+ rails-version: ${{ matrix.rails_version }}
67
+ ruby-version: ${{ matrix.ruby_version }}
68
+ solidus-branch: ${{ matrix.solidus_branch }}
69
+ - name: Upload failure artifacts
70
+ if: failure()
71
+ uses: actions/upload-artifact@v4
72
+ with:
73
+ name: failures-solidus${{ matrix.solidus_branch }}-rails${{ matrix.rails_version }}-ruby${{ matrix.ruby_version }}-${{ matrix.database }}
74
+ path: |
75
+ dummy-app/tmp/capybara
76
+ dummy-app/log/test.log
77
+ if-no-files-found: ignore
data/.rubocop.yml CHANGED
@@ -1,86 +1,7 @@
1
- require:
2
- - solidus_dev_support/rubocop
1
+ require: standard
3
2
 
4
- AllCops:
5
- NewCops: disable
6
- TargetRubyVersion: '3.0'
7
- Exclude:
8
- - sandbox/**/*
9
- - dummy-app/**/*
10
- - spec/dummy/**/*
11
- - vendor/bundle/**/*
12
-
13
- Layout/FirstArgumentIndentation:
14
- EnforcedStyle: consistent
15
-
16
- Layout/FirstArrayElementIndentation:
17
- EnforcedStyle: consistent
18
-
19
- Layout/FirstHashElementIndentation:
20
- EnforcedStyle: consistent
21
-
22
- Layout/MultilineMethodCallIndentation:
23
- EnforcedStyle: indented
24
-
25
- Naming/VariableNumber:
26
- Enabled: false
27
-
28
- # We use this extensively, the alternatives are not viable or desirable.
29
- RSpec/AnyInstance:
30
- Enabled: false
31
-
32
- # No need to make the code more complex for no real gain.
33
- RSpec/MessageSpies:
34
- Enabled: false
35
-
36
- # Let's consider legitimate to have multiple expectations within an example.
37
- RSpec/MultipleExpectations:
38
- Enabled: false
39
-
40
- # Allow to use subject as is, no big deal.
41
- RSpec/NamedSubject:
42
- Enabled: false
3
+ inherit_gem:
4
+ standard: config/base.yml
43
5
 
44
- # Let's set this to some really exagerate value.
45
- RSpec/NestedGroups:
46
- Max: 8
47
-
48
- # We don't use the FactoryBot mixin
49
- RSpec/FactoryBot/SyntaxMethods:
50
- Enabled: false
51
-
52
- RSpec/VerifiedDoubles:
53
- # Sometimes you really need an "anything" double
54
- IgnoreSymbolicNames: true
55
-
56
- Style/FrozenStringLiteralComment:
57
- Exclude:
58
- - spec/**/*
59
- - db/migrate/**/*
60
- - bin/**/*
61
-
62
- Style/ExplicitBlockArgument:
63
- Exclude:
64
- - lib/solidus_braintree/request_protection.rb
65
-
66
- Rails/SkipsModelValidations:
67
- Exclude:
68
- - db/migrate/**/*
69
-
70
- Rails/ReflectionClassName:
71
- Exclude:
72
- - app/models/solidus_braintree/customer.rb
73
- - app/models/solidus_braintree/source.rb
74
-
75
- RSpec/MultipleMemoizedHelpers:
76
- Exclude:
77
- - spec/models/solidus_braintree/transaction_import_spec.rb
78
- - spec/models/solidus_braintree/response_spec.rb
79
- - spec/models/solidus_braintree/gateway_spec.rb
80
- - spec/controllers/solidus_braintree/client_tokens_controller_spec.rb
81
- - spec/system/frontend/braintree_credit_card_checkout_spec.rb
82
- - spec/system/frontend/paypal_checkout_spec.rb
83
-
84
- Rails/ApplicationRecord:
85
- Exclude:
86
- - db/migrate/*
6
+ AllCops:
7
+ TargetRubyVersion: 3.1
data/.standard.yml ADDED
@@ -0,0 +1,6 @@
1
+ parallel: true
2
+ format: progress
3
+ ruby_version: 3.1
4
+ ignore:
5
+ - "spec/dummy/**/*"
6
+ - "dummy-app/**/*"
data/Gemfile CHANGED
@@ -1,30 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7
- gem 'solidus', github: 'solidusio/solidus', branch: branch
6
+ branch = ENV.fetch("SOLIDUS_BRANCH", "main")
7
+ gem "solidus", github: "solidusio/solidus", branch: branch
8
8
 
9
- gem 'rails', ENV.fetch('RAILS_VERSION', '~> 7.0')
9
+ gem "rails", "~> #{ENV.fetch("RAILS_VERSION", "8.1")}"
10
10
 
11
11
  # Provides basic authentication functionality for testing parts of your engine
12
- gem 'solidus_auth_devise'
12
+ gem "solidus_auth_devise"
13
13
 
14
- case ENV.fetch('DB', nil)
15
- when 'mysql'
16
- gem 'mysql2'
17
- when 'postgresql'
18
- gem 'pg'
14
+ case ENV.fetch("DB", nil)
15
+ when "mysql"
16
+ gem "mysql2"
17
+ when "postgresql"
18
+ gem "pg"
19
19
  else
20
- gem 'sqlite3'
20
+ gem "sqlite3"
21
21
  end
22
22
 
23
- # While we still support Ruby < 3 we need to workaround a limitation in
24
- # the 'async' gem that relies on the latest ruby, since RubyGems doesn't
25
- # resolve gems based on the required ruby version.
26
- gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
27
-
28
23
  gemspec
29
24
 
30
25
  # Use a local Gemfile to include development dependencies that might not be
@@ -32,4 +27,4 @@ gemspec
32
27
  #
33
28
  # We use `send` instead of calling `eval_gemfile` to work around an issue with
34
29
  # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
35
- send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
30
+ send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SolidusBraintree
2
2
 
3
- [![CircleCI](https://circleci.com/gh/solidusio/solidus_braintree.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_braintree)
3
+ [![Test](https://github.com/solidusio/solidus_braintree/actions/workflows/test.yml/badge.svg)](https://github.com/solidusio/solidus_braintree/actions/workflows/test.yml)
4
4
  [![codecov](https://codecov.io/gh/solidusio/solidus_braintree/branch/main/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_braintree)
5
5
 
6
6
  `solidus_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 uses Braintree's [JavaScript v3 SDK](https://braintree.github.io/braintree-web/current/) to support the following Braintree payment method types:
@@ -365,16 +365,18 @@ default configuration that gets created by overriding the private
365
365
 
366
366
  ## Testing
367
367
 
368
- To run the specs it is required to set the Braintree test account data in these environment variables:
369
- `BRAINTREE_PUBLIC_KEY`, `BRAINTREE_PRIVATE_KEY`, `BRAINTREE_MERCHANT_ID` and `BRAINTREE_PAYPAL_PAYEE_EMAIL`
370
-
371
- First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
368
+ The specs run inside a Rails app with the storefront installed, which `bin/dummy-app` generates into `dummy-app/`. First bundle your dependencies, then run `rake`. It builds the dummy app if it does not exist yet and runs the specs inside it. `SOLIDUS_BRANCH`, `RAILS_VERSION` and `DB` (`sqlite`, `mysql` or `postgresql`) select the versions to test against, and `rake clobber` removes the dummy app so that it is rebuilt from scratch.
372
369
 
373
370
  ```shell
374
371
  bundle
375
372
  bundle exec rake
373
+ bundle exec standardrb
376
374
  ```
377
375
 
376
+ Specs that use the Braintree JavaScript SDK in the browser need a Braintree sandbox account and are skipped unless `BRAINTREE_PUBLIC_KEY`, `BRAINTREE_PRIVATE_KEY` and `BRAINTREE_MERCHANT_ID` are set. The sandbox account needs a linked PayPal sandbox account, because PayPal Checkout does not work with Braintree's mocked PayPal flow. The Venmo specs additionally need Venmo to be enabled for the sandbox account and only run when `BRAINTREE_VENMO_ENABLED` is set. `BRAINTREE_PAYPAL_PAYEE_EMAIL` optionally sets the PayPal payee email used for EUR payments.
377
+
378
+ When re-recording VCR cassettes, disable duplicate transaction checking for the sandbox account, as several specs charge the same amount to the same test card.
379
+
378
380
  When testing your applications integration with this extension you may use it's factories.
379
381
  Simply add this require statement to your spec_helper:
380
382
 
data/Rakefile CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'solidus_dev_support/rake_tasks'
5
- SolidusDevSupport::RakeTasks.install
3
+ require "bundler/gem_tasks"
4
+ require "solidus_dev_support/rake_tasks"
5
+ SolidusDevSupport::RakeTasks.install(user_class: "Spree::User")
6
6
 
7
7
  task :default do
8
- require 'bundler'
8
+ require "bundler"
9
9
  Bundler.with_unbundled_env do
10
- sh 'bin/rspec'
10
+ sh "bin/rspec"
11
11
  end
12
12
  end
13
13
 
14
- CLOBBER.include('dummy-app')
15
- CLOBBER.include('sandbox')
14
+ CLOBBER.include("dummy-app")
15
+ CLOBBER.include("sandbox")
@@ -4,7 +4,7 @@ module SolidusBraintree
4
4
  module BraintreeAdminHelper
5
5
  # Returns a link to the Braintree web UI for the given Braintree payment
6
6
  def braintree_transaction_link(payment)
7
- environment = payment.payment_method.preferred_environment == 'sandbox' ? 'sandbox' : 'www'
7
+ environment = (payment.payment_method.preferred_environment == "sandbox") ? "sandbox" : "www"
8
8
  merchant_id = payment.payment_method.preferred_merchant_id
9
9
  response_code = payment.response_code
10
10
 
@@ -14,9 +14,9 @@ module SolidusBraintree
14
14
  link_to(
15
15
  response_code,
16
16
  "https://#{environment}.braintreegateway.com/merchants/#{merchant_id}/transactions/#{response_code}",
17
- title: 'Show payment on Braintree',
18
- target: '_blank',
19
- rel: 'noopener'
17
+ title: "Show payment on Braintree",
18
+ target: "_blank",
19
+ rel: "noopener"
20
20
  )
21
21
  end
22
22
  end
@@ -1,50 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_merchant/billing/avs_result'
3
+ require "active_merchant/billing/avs_result"
4
4
 
5
5
  module SolidusBraintree
6
6
  class AVSResult < ActiveMerchant::Billing::AVSResult
7
7
  # Mapping took from ActiveMerchant::Billing::BraintreeBlueGateway
8
8
  AVS_MAPPING = {
9
- 'M' => {
10
- 'M' => 'M',
11
- 'N' => 'A',
12
- 'U' => 'B',
13
- 'I' => 'B',
14
- 'A' => 'B'
9
+ "M" => {
10
+ "M" => "M",
11
+ "N" => "A",
12
+ "U" => "B",
13
+ "I" => "B",
14
+ "A" => "B"
15
15
  },
16
- 'N' => {
17
- 'M' => 'Z',
18
- 'N' => 'C',
19
- 'U' => 'C',
20
- 'I' => 'C',
21
- 'A' => 'C'
16
+ "N" => {
17
+ "M" => "Z",
18
+ "N" => "C",
19
+ "U" => "C",
20
+ "I" => "C",
21
+ "A" => "C"
22
22
  },
23
- 'U' => {
24
- 'M' => 'P',
25
- 'N' => 'N',
26
- 'U' => 'I',
27
- 'I' => 'I',
28
- 'A' => 'I'
23
+ "U" => {
24
+ "M" => "P",
25
+ "N" => "N",
26
+ "U" => "I",
27
+ "I" => "I",
28
+ "A" => "I"
29
29
  },
30
- 'I' => {
31
- 'M' => 'P',
32
- 'N' => 'C',
33
- 'U' => 'I',
34
- 'I' => 'I',
35
- 'A' => 'I'
30
+ "I" => {
31
+ "M" => "P",
32
+ "N" => "C",
33
+ "U" => "I",
34
+ "I" => "I",
35
+ "A" => "I"
36
36
  },
37
- 'A' => {
38
- 'M' => 'P',
39
- 'N' => 'C',
40
- 'U' => 'I',
41
- 'I' => 'I',
42
- 'A' => 'I'
37
+ "A" => {
38
+ "M" => "P",
39
+ "N" => "C",
40
+ "U" => "I",
41
+ "I" => "I",
42
+ "A" => "I"
43
43
  },
44
- 'B' => {
45
- 'B' => 'B'
44
+ "B" => {
45
+ "B" => "B"
46
46
  },
47
- nil => { nil => nil }
47
+ nil => {nil => nil}
48
48
  }.freeze
49
49
 
50
50
  class << self
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SolidusBraintree
4
4
  def self.table_name_prefix
5
- 'solidus_paypal_braintree_'
5
+ "solidus_paypal_braintree_"
6
6
  end
7
7
 
8
8
  class BaseRecord < ::Spree::Base
@@ -3,30 +3,30 @@
3
3
  module SolidusBraintree
4
4
  class Configuration < BaseRecord
5
5
  PAYPAL_BUTTON_PREFERENCES = {
6
- color: { availables: %w[gold blue silver white black], default: 'white' },
7
- shape: { availables: %w[pill rect], default: 'rect' },
8
- label: { availables: %w[checkout credit pay buynow paypal installment], default: 'checkout' },
9
- tagline: { availables: %w[true false], default: 'false' },
10
- layout: { availables: %w[horizontal vertical], default: 'horizontal' },
11
- messaging: { availables: %w[true false], default: 'false' }
6
+ color: {availables: %w[gold blue silver white black], default: "white"},
7
+ shape: {availables: %w[pill rect], default: "rect"},
8
+ label: {availables: %w[checkout credit pay buynow paypal installment], default: "checkout"},
9
+ tagline: {availables: %w[true false], default: "false"},
10
+ layout: {availables: %w[horizontal vertical], default: "horizontal"},
11
+ messaging: {availables: %w[true false], default: "false"}
12
12
  }.freeze
13
13
 
14
14
  include ::Spree::Preferences::Persistable
15
15
 
16
- belongs_to :store, class_name: 'Spree::Store', optional: false
16
+ belongs_to :store, class_name: "Spree::Store", optional: false
17
17
 
18
18
  # Preferences for Paypal button
19
19
  PAYPAL_BUTTON_PREFERENCES.each do |name, desc|
20
- preference_name = "paypal_button_#{name}".to_sym
21
- attribute_name = "preferred_#{preference_name}".to_sym
20
+ preference_name = :"paypal_button_#{name}"
21
+ attribute_name = :"preferred_#{preference_name}"
22
22
 
23
23
  preference preference_name, :string, default: desc[:default]
24
24
 
25
25
  validates attribute_name, inclusion: desc[:availables]
26
26
  end
27
27
 
28
- preference :venmo_button_color, :preference_select, default: 'blue'
29
- preference :venmo_button_width, :preference_select, default: '320'
28
+ preference :venmo_button_color, :preference_select, default: "blue"
29
+ preference :venmo_button_width, :preference_select, default: "320"
30
30
 
31
31
  def preferred_venmo_button_color_options
32
32
  [["Blue", "blue"], ["White", "white"]]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'solidus_braintree/request_protection'
3
+ require "solidus_braintree/request_protection"
4
4
 
5
5
  module SolidusBraintree
6
6
  class Gateway < ::Spree::PaymentMethod
@@ -11,9 +11,9 @@ module SolidusBraintree
11
11
  # Error message from Braintree that gets returned by a non voidable transaction
12
12
  NON_VOIDABLE_STATUS_ERROR_REGEXP = /can only be voided if status is authorized/
13
13
 
14
- TOKEN_GENERATION_DISABLED_MESSAGE = 'Token generation is disabled. ' \
15
- 'To re-enable set the `token_generation_enabled` preference on the ' \
16
- 'gateway to `true`.'
14
+ TOKEN_GENERATION_DISABLED_MESSAGE = "Token generation is disabled. " \
15
+ "To re-enable set the `token_generation_enabled` preference on the " \
16
+ "gateway to `true`."
17
17
 
18
18
  ALLOWED_BRAINTREE_OPTIONS = [
19
19
  :device_data,
@@ -35,9 +35,9 @@ module SolidusBraintree
35
35
  preference(:token_generation_enabled, :boolean, default: true)
36
36
 
37
37
  # Preferences for configuration of Braintree credentials
38
- preference(:environment, :string, default: 'sandbox')
38
+ preference(:environment, :string, default: "sandbox")
39
39
  preference(:merchant_id, :string, default: nil)
40
- preference(:public_key, :string, default: nil)
40
+ preference(:public_key, :string, default: nil)
41
41
  preference(:private_key, :string, default: nil)
42
42
  preference(:http_open_timeout, :integer, default: 60)
43
43
  preference(:http_read_timeout, :integer, default: 60)
@@ -45,7 +45,7 @@ module SolidusBraintree
45
45
  preference(:paypal_payee_email_map, :hash, default: {})
46
46
 
47
47
  # Which checkout flow to use (vault/checkout)
48
- preference(:paypal_flow, :string, default: 'vault')
48
+ preference(:paypal_flow, :string, default: "vault")
49
49
 
50
50
  # A hash that gets passed to the `style` key when initializing the credit card fields.
51
51
  # See https://developers.braintreepayments.com/guides/hosted-fields/styling/javascript/v3
@@ -301,7 +301,7 @@ module SolidusBraintree
301
301
  # Whether to store this payment method in the PayPal Vault. This only works when the checkout
302
302
  # flow is "vault", so make sure to call +super+ if you override it.
303
303
  def store_in_vault
304
- preferred_paypal_flow == 'vault'
304
+ preferred_paypal_flow == "vault"
305
305
  end
306
306
 
307
307
  def logger
@@ -334,26 +334,24 @@ module SolidusBraintree
334
334
  end
335
335
 
336
336
  def transaction_options(source, options, submit_for_settlement: false)
337
- params = options.select do |key, _|
338
- ALLOWED_BRAINTREE_OPTIONS.include?(key)
339
- end
337
+ params = options.slice(*ALLOWED_BRAINTREE_OPTIONS)
340
338
 
341
339
  params[:channel] = "Solidus"
342
- params[:options] = { store_in_vault_on_success: store_in_vault }
340
+ params[:options] = {store_in_vault_on_success: store_in_vault}
343
341
 
344
342
  if submit_for_settlement
345
343
  params[:options][:submit_for_settlement] = true
346
344
  end
347
345
 
348
- if paypal_email = paypal_payee_email_for(source, options)
349
- params[:options][:paypal] = { payee_email: paypal_email }
346
+ if (paypal_email = paypal_payee_email_for(source, options))
347
+ params[:options][:paypal] = {payee_email: paypal_email}
350
348
  end
351
349
 
352
350
  if source.venmo? && venmo_business_profile_id
353
- params[:options][:venmo] = { profile_id: venmo_business_profile_id }
351
+ params[:options][:venmo] = {profile_id: venmo_business_profile_id}
354
352
  end
355
353
 
356
- if merchant_account_id = merchant_account_for(source, options)
354
+ if (merchant_account_id = merchant_account_for(source, options))
357
355
  params[:merchant_account_id] = merchant_account_id
358
356
  end
359
357
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_merchant/billing/response'
4
- require_relative 'avs_result'
3
+ require "active_merchant/billing/response"
4
+ require_relative "avs_result"
5
5
 
6
6
  # Response object that all actions on the gateway should return
7
7
  module SolidusBraintree
@@ -57,21 +57,21 @@ module SolidusBraintree
57
57
  # Human readable error message for transaction responses
58
58
  def transaction_error_message(transaction)
59
59
  case transaction.status
60
- when 'gateway_rejected'
60
+ when "gateway_rejected"
61
61
  I18n.t(transaction.gateway_rejection_reason,
62
- scope: 'solidus_braintree.gateway_rejection_reasons',
62
+ scope: "solidus_braintree.gateway_rejection_reasons",
63
63
  default: "#{transaction.status.humanize} #{transaction.gateway_rejection_reason.humanize}")
64
- when 'processor_declined'
64
+ when "processor_declined"
65
65
  I18n.t(transaction.processor_response_code,
66
- scope: 'solidus_braintree.processor_response_codes',
66
+ scope: "solidus_braintree.processor_response_codes",
67
67
  default: "#{transaction.processor_response_text} (#{transaction.processor_response_code})")
68
- when 'settlement_declined'
68
+ when "settlement_declined"
69
69
  I18n.t(transaction.processor_settlement_response_code,
70
- scope: 'solidus_braintree.processor_settlement_response_codes',
70
+ scope: "solidus_braintree.processor_settlement_response_codes",
71
71
  default: "#{transaction.processor_settlement_response_text} (#{transaction.processor_settlement_response_code})") # rubocop:disable Layout/LineLength
72
72
  else
73
73
  I18n.t(transaction.status,
74
- scope: 'solidus_braintree.transaction_statuses',
74
+ scope: "solidus_braintree.transaction_statuses",
75
75
  default: transaction.status.humanize)
76
76
  end
77
77
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'solidus_braintree/request_protection'
3
+ require "solidus_braintree/request_protection"
4
4
 
5
5
  module SolidusBraintree
6
6
  class Source < ::Spree::PaymentSource
@@ -20,7 +20,7 @@ module SolidusBraintree
20
20
  }, suffix: :funding
21
21
 
22
22
  belongs_to :user, class_name: ::Spree::UserClassHandle.new, optional: true
23
- belongs_to :payment_method, class_name: 'Spree::PaymentMethod'
23
+ belongs_to :payment_method, class_name: "Spree::PaymentMethod"
24
24
  has_many :payments, as: :source, class_name: "Spree::Payment", dependent: :destroy
25
25
 
26
26
  belongs_to :customer, class_name: "SolidusBraintree::Customer", optional: true
@@ -100,18 +100,18 @@ module SolidusBraintree
100
100
  elsif venmo?
101
101
  username
102
102
  else
103
- "XXXX-XXXX-XXXX-#{last_digits.to_s.rjust(4, 'X')}"
103
+ "XXXX-XXXX-XXXX-#{last_digits.to_s.rjust(4, "X")}"
104
104
  end
105
105
  end
106
106
 
107
107
  def display_paypal_funding_source
108
108
  I18n.t(paypal_funding_source,
109
- scope: 'solidus_braintree.paypal_funding_sources',
109
+ scope: "solidus_braintree.paypal_funding_sources",
110
110
  default: paypal_funding_source)
111
111
  end
112
112
 
113
113
  def display_payment_type
114
- "#{I18n.t('solidus_braintree.payment_type.label')}: #{friendly_payment_type}"
114
+ "#{I18n.t("solidus_braintree.payment_type.label")}: #{friendly_payment_type}"
115
115
  end
116
116
 
117
117
  private