solidus_braintree 3.2.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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/test.yml +77 -0
- data/.rubocop.yml +5 -84
- data/.standard.yml +6 -0
- data/7.2 +0 -0
- data/Gemfile +12 -20
- data/README.md +7 -5
- data/Rakefile +7 -7
- data/app/helpers/solidus_braintree/braintree_admin_helper.rb +4 -4
- data/app/models/solidus_braintree/avs_result.rb +34 -34
- data/app/models/solidus_braintree/base_record.rb +11 -0
- data/app/models/solidus_braintree/configuration.rb +12 -12
- data/app/models/solidus_braintree/customer.rb +1 -1
- data/app/models/solidus_braintree/gateway.rb +14 -17
- data/app/models/solidus_braintree/response.rb +9 -9
- data/app/models/solidus_braintree/source.rb +9 -7
- data/app/models/solidus_braintree/transaction.rb +2 -2
- data/app/models/solidus_braintree/transaction_address.rb +5 -5
- data/app/models/solidus_braintree/transaction_import.rb +2 -2
- data/app/{decorators/models/solidus_braintree/spree_store_decorator.rb → patches/models/solidus_braintree/spree_store_patch.rb} +1 -1
- data/app/{decorators/models/solidus_braintree/spree_user_decorator.rb → patches/models/solidus_braintree/spree_user_patch.rb} +2 -2
- data/bin/dummy-app +23 -3
- data/bin/rails-sandbox +4 -4
- data/bin/rspec +6 -0
- data/bin/sandbox +55 -31
- data/db/migrate/20161114231422_create_solidus_paypal_braintree_configurations.rb +2 -2
- data/db/migrate/20170508085402_add_not_null_constraint_to_sources_payment_type.rb +2 -2
- data/db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb +3 -3
- data/{app/decorators/controllers → lib/controllers/api}/solidus_braintree/client_tokens_controller.rb +2 -2
- data/lib/controllers/backend/solidus_braintree/configurations_controller.rb +4 -4
- data/lib/generators/solidus_braintree/install/install_generator.rb +48 -40
- data/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb +7 -7
- data/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/transactions_controller.rb +7 -7
- data/lib/generators/solidus_braintree/install/templates/app/helpers/solidus_braintree/braintree_checkout_helper.rb +5 -5
- data/{app/decorators/controllers/solidus_braintree/admin_payments_controller_decorator.rb → lib/patches/backend/controllers/solidus_braintree/admin_payments_controller_patch.rb} +1 -1
- data/lib/solidus_braintree/engine.rb +13 -24
- data/lib/solidus_braintree/extension_configuration.rb +1 -1
- data/lib/solidus_braintree/request_protection.rb +2 -2
- data/lib/solidus_braintree/version.rb +1 -1
- data/lib/solidus_braintree.rb +8 -10
- data/lib/solidus_paypal_braintree.rb +2 -2
- data/mise.toml +2 -0
- data/solidus_braintree.gemspec +23 -22
- metadata +62 -152
- data/.circleci/config.yml +0 -80
- data/app/models/application_record.rb +0 -5
- data/lib/views/backend_v1.2/spree/admin/payments/source_forms/_braintree.html.erb +0 -16
- data/lib/views/backend_v2.4/spree/admin/shared/preference_fields/_hash.html.erb +0 -12
- data/spec/controllers/solidus_braintree/checkouts_controller_spec.rb +0 -99
- data/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb +0 -55
- data/spec/controllers/solidus_braintree/configurations_controller_spec.rb +0 -73
- data/spec/controllers/solidus_braintree/transactions_controller_spec.rb +0 -183
- data/spec/fixtures/cassettes/admin/invalid_credit_card.yml +0 -63
- data/spec/fixtures/cassettes/admin/resubmit_credit_card.yml +0 -352
- data/spec/fixtures/cassettes/admin/valid_credit_card.yml +0 -412
- data/spec/fixtures/cassettes/braintree/create_profile.yml +0 -71
- data/spec/fixtures/cassettes/braintree/generate_token.yml +0 -63
- data/spec/fixtures/cassettes/braintree/token.yml +0 -63
- data/spec/fixtures/cassettes/checkout/invalid_credit_card.yml +0 -63
- data/spec/fixtures/cassettes/checkout/resubmit_credit_card.yml +0 -216
- data/spec/fixtures/cassettes/checkout/update.yml +0 -71
- data/spec/fixtures/cassettes/checkout/valid_credit_card.yml +0 -171
- data/spec/fixtures/cassettes/checkout/valid_venmo_transaction.yml +0 -599
- data/spec/fixtures/cassettes/gateway/authorize/credit_card/address.yml +0 -86
- data/spec/fixtures/cassettes/gateway/authorize/merchant_account/EUR.yml +0 -154
- data/spec/fixtures/cassettes/gateway/authorize/paypal/EUR.yml +0 -90
- data/spec/fixtures/cassettes/gateway/authorize/paypal/address.yml +0 -90
- data/spec/fixtures/cassettes/gateway/authorize.yml +0 -86
- data/spec/fixtures/cassettes/gateway/authorized_transaction.yml +0 -73
- data/spec/fixtures/cassettes/gateway/cancel/missing.yml +0 -63
- data/spec/fixtures/cassettes/gateway/cancel/refunds.yml +0 -272
- data/spec/fixtures/cassettes/gateway/cancel/void.yml +0 -201
- data/spec/fixtures/cassettes/gateway/capture.yml +0 -141
- data/spec/fixtures/cassettes/gateway/complete.yml +0 -157
- data/spec/fixtures/cassettes/gateway/credit.yml +0 -208
- data/spec/fixtures/cassettes/gateway/customer.yml +0 -79
- data/spec/fixtures/cassettes/gateway/purchase.yml +0 -87
- data/spec/fixtures/cassettes/gateway/settled_transaction.yml +0 -140
- data/spec/fixtures/cassettes/gateway/void.yml +0 -137
- data/spec/fixtures/cassettes/source/bin.yml +0 -295
- data/spec/fixtures/cassettes/source/card_type.yml +0 -267
- data/spec/fixtures/cassettes/source/last4.yml +0 -267
- data/spec/fixtures/cassettes/transaction/import/valid/capture.yml +0 -224
- data/spec/fixtures/cassettes/transaction/import/valid.yml +0 -71
- data/spec/fixtures/views/carts/_cart_footer.html.erb +0 -18
- data/spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb +0 -17
- data/spec/helpers/solidus_braintree/braintree_checkout_helper_spec.rb +0 -70
- data/spec/models/solidus_braintree/address_spec.rb +0 -71
- data/spec/models/solidus_braintree/avs_result_spec.rb +0 -317
- data/spec/models/solidus_braintree/gateway_spec.rb +0 -774
- data/spec/models/solidus_braintree/response_spec.rb +0 -280
- data/spec/models/solidus_braintree/source_spec.rb +0 -555
- data/spec/models/solidus_braintree/transaction_address_spec.rb +0 -235
- data/spec/models/solidus_braintree/transaction_import_spec.rb +0 -302
- data/spec/models/solidus_braintree/transaction_spec.rb +0 -86
- data/spec/models/spree/store_spec.rb +0 -14
- data/spec/requests/spree/api/orders_controller_spec.rb +0 -36
- data/spec/solidus_braintree_spec_helper.rb +0 -9
- data/spec/support/solidus_braintree/capybara.rb +0 -7
- data/spec/support/solidus_braintree/factories.rb +0 -55
- data/spec/support/solidus_braintree/gateway_helpers.rb +0 -29
- data/spec/support/solidus_braintree/order_ready_for_payment.rb +0 -44
- data/spec/support/solidus_braintree/order_walkthrough.rb +0 -87
- data/spec/support/solidus_braintree/vcr.rb +0 -38
- data/spec/support/solidus_braintree/with_prepended_view_fixtures.rb +0 -19
- data/spec/system/backend/configuration_spec.rb +0 -23
- data/spec/system/backend/new_payment_spec.rb +0 -136
- data/spec/system/frontend/braintree_credit_card_checkout_spec.rb +0 -199
- data/spec/system/frontend/paypal_checkout_spec.rb +0 -168
- 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20decb10931454aa4855df2b427a24c1f22f502b363ebba35b13e2757eeb53b3
|
|
4
|
+
data.tar.gz: 3d93d374dc39443b75e2473de2c073d0357b087df6d44a5436cf8fc4fb37c0d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63729983efe298f30fdbaa79e951c8f8e8ec3dcea9378dce4d7249054784f286518cc4ec7fbbb1c39e9e662617bd6b15ebf3354dfcc6f79c80b39da0bc47888f
|
|
7
|
+
data.tar.gz: d18c988f0d90d5045bb3e6ecd00bd925afd638d4deebdd846d7dd2ac27aa22a8feb56eeedde53a87d1cf62efc000fb6aeb93664fbeb605dd12a9bb8b52aa9d6e
|
|
@@ -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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
45
|
-
|
|
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
data/7.2
ADDED
|
File without changes
|
data/Gemfile
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
source
|
|
3
|
+
source "https://rubygems.org"
|
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
5
|
|
|
6
|
-
branch = ENV.fetch(
|
|
7
|
-
gem
|
|
6
|
+
branch = ENV.fetch("SOLIDUS_BRANCH", "main")
|
|
7
|
+
gem "solidus", github: "solidusio/solidus", branch: branch
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
# otherwise it takes forever to resolve them.
|
|
11
|
-
# See https://github.com/bundler/bundler/issues/6677
|
|
12
|
-
gem 'rails', '>0.a'
|
|
9
|
+
gem "rails", "~> #{ENV.fetch("RAILS_VERSION", "8.1")}"
|
|
13
10
|
|
|
14
11
|
# Provides basic authentication functionality for testing parts of your engine
|
|
15
|
-
gem
|
|
12
|
+
gem "solidus_auth_devise"
|
|
16
13
|
|
|
17
|
-
case ENV.fetch(
|
|
18
|
-
when
|
|
19
|
-
gem
|
|
20
|
-
when
|
|
21
|
-
gem
|
|
14
|
+
case ENV.fetch("DB", nil)
|
|
15
|
+
when "mysql"
|
|
16
|
+
gem "mysql2"
|
|
17
|
+
when "postgresql"
|
|
18
|
+
gem "pg"
|
|
22
19
|
else
|
|
23
|
-
gem
|
|
20
|
+
gem "sqlite3"
|
|
24
21
|
end
|
|
25
22
|
|
|
26
|
-
# While we still support Ruby < 3 we need to workaround a limitation in
|
|
27
|
-
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
|
|
28
|
-
# resolve gems based on the required ruby version.
|
|
29
|
-
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
|
|
30
|
-
|
|
31
23
|
gemspec
|
|
32
24
|
|
|
33
25
|
# Use a local Gemfile to include development dependencies that might not be
|
|
@@ -35,4 +27,4 @@ gemspec
|
|
|
35
27
|
#
|
|
36
28
|
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
|
37
29
|
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
|
38
|
-
send(:eval_gemfile,
|
|
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
|
-
[](https://github.com/solidusio/solidus_braintree/actions/workflows/test.yml)
|
|
4
4
|
[](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
|
-
|
|
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
|
|
4
|
-
require
|
|
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
|
|
8
|
+
require "bundler"
|
|
9
9
|
Bundler.with_unbundled_env do
|
|
10
|
-
sh
|
|
10
|
+
sh "bin/rspec"
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
CLOBBER.include(
|
|
15
|
-
CLOBBER.include(
|
|
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 ==
|
|
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:
|
|
18
|
-
target:
|
|
19
|
-
rel:
|
|
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
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
"M" => {
|
|
10
|
+
"M" => "M",
|
|
11
|
+
"N" => "A",
|
|
12
|
+
"U" => "B",
|
|
13
|
+
"I" => "B",
|
|
14
|
+
"A" => "B"
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
"N" => {
|
|
17
|
+
"M" => "Z",
|
|
18
|
+
"N" => "C",
|
|
19
|
+
"U" => "C",
|
|
20
|
+
"I" => "C",
|
|
21
|
+
"A" => "C"
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
"U" => {
|
|
24
|
+
"M" => "P",
|
|
25
|
+
"N" => "N",
|
|
26
|
+
"U" => "I",
|
|
27
|
+
"I" => "I",
|
|
28
|
+
"A" => "I"
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
"I" => {
|
|
31
|
+
"M" => "P",
|
|
32
|
+
"N" => "C",
|
|
33
|
+
"U" => "I",
|
|
34
|
+
"I" => "I",
|
|
35
|
+
"A" => "I"
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
"A" => {
|
|
38
|
+
"M" => "P",
|
|
39
|
+
"N" => "C",
|
|
40
|
+
"U" => "I",
|
|
41
|
+
"I" => "I",
|
|
42
|
+
"A" => "I"
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
"B" => {
|
|
45
|
+
"B" => "B"
|
|
46
46
|
},
|
|
47
|
-
nil => {
|
|
47
|
+
nil => {nil => nil}
|
|
48
48
|
}.freeze
|
|
49
49
|
|
|
50
50
|
class << self
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusBraintree
|
|
4
|
-
class Configuration <
|
|
4
|
+
class Configuration < BaseRecord
|
|
5
5
|
PAYPAL_BUTTON_PREFERENCES = {
|
|
6
|
-
color: {
|
|
7
|
-
shape: {
|
|
8
|
-
label: {
|
|
9
|
-
tagline: {
|
|
10
|
-
layout: {
|
|
11
|
-
messaging: {
|
|
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:
|
|
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}"
|
|
21
|
-
attribute_name = "preferred_#{preference_name}"
|
|
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:
|
|
29
|
-
preference :venmo_button_width, :preference_select, default:
|
|
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,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusBraintree
|
|
4
|
-
class Customer <
|
|
4
|
+
class Customer < BaseRecord
|
|
5
5
|
belongs_to :user, class_name: ::Spree::UserClassHandle.new, optional: true
|
|
6
6
|
has_many :sources, class_name: "SolidusBraintree::Source", inverse_of: :customer, dependent: :destroy
|
|
7
7
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require 'solidus_braintree/request_protection'
|
|
3
|
+
require "solidus_braintree/request_protection"
|
|
5
4
|
|
|
6
5
|
module SolidusBraintree
|
|
7
6
|
class Gateway < ::Spree::PaymentMethod
|
|
@@ -12,9 +11,9 @@ module SolidusBraintree
|
|
|
12
11
|
# Error message from Braintree that gets returned by a non voidable transaction
|
|
13
12
|
NON_VOIDABLE_STATUS_ERROR_REGEXP = /can only be voided if status is authorized/
|
|
14
13
|
|
|
15
|
-
TOKEN_GENERATION_DISABLED_MESSAGE =
|
|
16
|
-
|
|
17
|
-
|
|
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`."
|
|
18
17
|
|
|
19
18
|
ALLOWED_BRAINTREE_OPTIONS = [
|
|
20
19
|
:device_data,
|
|
@@ -36,9 +35,9 @@ module SolidusBraintree
|
|
|
36
35
|
preference(:token_generation_enabled, :boolean, default: true)
|
|
37
36
|
|
|
38
37
|
# Preferences for configuration of Braintree credentials
|
|
39
|
-
preference(:environment, :string, default:
|
|
38
|
+
preference(:environment, :string, default: "sandbox")
|
|
40
39
|
preference(:merchant_id, :string, default: nil)
|
|
41
|
-
preference(:public_key,
|
|
40
|
+
preference(:public_key, :string, default: nil)
|
|
42
41
|
preference(:private_key, :string, default: nil)
|
|
43
42
|
preference(:http_open_timeout, :integer, default: 60)
|
|
44
43
|
preference(:http_read_timeout, :integer, default: 60)
|
|
@@ -46,7 +45,7 @@ module SolidusBraintree
|
|
|
46
45
|
preference(:paypal_payee_email_map, :hash, default: {})
|
|
47
46
|
|
|
48
47
|
# Which checkout flow to use (vault/checkout)
|
|
49
|
-
preference(:paypal_flow, :string, default:
|
|
48
|
+
preference(:paypal_flow, :string, default: "vault")
|
|
50
49
|
|
|
51
50
|
# A hash that gets passed to the `style` key when initializing the credit card fields.
|
|
52
51
|
# See https://developers.braintreepayments.com/guides/hosted-fields/styling/javascript/v3
|
|
@@ -302,7 +301,7 @@ module SolidusBraintree
|
|
|
302
301
|
# Whether to store this payment method in the PayPal Vault. This only works when the checkout
|
|
303
302
|
# flow is "vault", so make sure to call +super+ if you override it.
|
|
304
303
|
def store_in_vault
|
|
305
|
-
preferred_paypal_flow ==
|
|
304
|
+
preferred_paypal_flow == "vault"
|
|
306
305
|
end
|
|
307
306
|
|
|
308
307
|
def logger
|
|
@@ -335,26 +334,24 @@ module SolidusBraintree
|
|
|
335
334
|
end
|
|
336
335
|
|
|
337
336
|
def transaction_options(source, options, submit_for_settlement: false)
|
|
338
|
-
params = options.
|
|
339
|
-
ALLOWED_BRAINTREE_OPTIONS.include?(key)
|
|
340
|
-
end
|
|
337
|
+
params = options.slice(*ALLOWED_BRAINTREE_OPTIONS)
|
|
341
338
|
|
|
342
339
|
params[:channel] = "Solidus"
|
|
343
|
-
params[:options] = {
|
|
340
|
+
params[:options] = {store_in_vault_on_success: store_in_vault}
|
|
344
341
|
|
|
345
342
|
if submit_for_settlement
|
|
346
343
|
params[:options][:submit_for_settlement] = true
|
|
347
344
|
end
|
|
348
345
|
|
|
349
|
-
if paypal_email = paypal_payee_email_for(source, options)
|
|
350
|
-
params[:options][:paypal] = {
|
|
346
|
+
if (paypal_email = paypal_payee_email_for(source, options))
|
|
347
|
+
params[:options][:paypal] = {payee_email: paypal_email}
|
|
351
348
|
end
|
|
352
349
|
|
|
353
350
|
if source.venmo? && venmo_business_profile_id
|
|
354
|
-
params[:options][:venmo] = {
|
|
351
|
+
params[:options][:venmo] = {profile_id: venmo_business_profile_id}
|
|
355
352
|
end
|
|
356
353
|
|
|
357
|
-
if merchant_account_id = merchant_account_for(source, options)
|
|
354
|
+
if (merchant_account_id = merchant_account_for(source, options))
|
|
358
355
|
params[:merchant_account_id] = merchant_account_id
|
|
359
356
|
end
|
|
360
357
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require_relative
|
|
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
|
|
60
|
+
when "gateway_rejected"
|
|
61
61
|
I18n.t(transaction.gateway_rejection_reason,
|
|
62
|
-
scope:
|
|
62
|
+
scope: "solidus_braintree.gateway_rejection_reasons",
|
|
63
63
|
default: "#{transaction.status.humanize} #{transaction.gateway_rejection_reason.humanize}")
|
|
64
|
-
when
|
|
64
|
+
when "processor_declined"
|
|
65
65
|
I18n.t(transaction.processor_response_code,
|
|
66
|
-
scope:
|
|
66
|
+
scope: "solidus_braintree.processor_response_codes",
|
|
67
67
|
default: "#{transaction.processor_response_text} (#{transaction.processor_response_code})")
|
|
68
|
-
when
|
|
68
|
+
when "settlement_declined"
|
|
69
69
|
I18n.t(transaction.processor_settlement_response_code,
|
|
70
|
-
scope:
|
|
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:
|
|
74
|
+
scope: "solidus_braintree.transaction_statuses",
|
|
75
75
|
default: transaction.status.humanize)
|
|
76
76
|
end
|
|
77
77
|
end
|