From ff966bb4c30db79ca8463e27fdf01f9786090b45 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Tue, 14 Feb 2023 18:22:57 +0800 Subject: [PATCH 01/66] Replace OrderWalkthrough with local version The extension currently modifies the address factory so that it can set a fixed zipcode for the addresses created by OrderWalkthrough. However, once we change the frontend of this gem to SolidusStarterFrontend and run this extension's specs together with the frontend specs, the address modification would cause the frontend's coupon code spec to fail. See https://app.circleci.com/pipelines/github/solidusio/solidus_braintree/239/workflows/06370bde-ef25-49cf-8fc2-1aefd5a2f86e/jobs/623/parallel-runs/0/steps/0-108. To prevent that, we're going to avoid modifying the address by having a local version of the OrderWalkthrough class. --- spec/features/backend/new_payment_spec.rb | 1 - .../braintree_credit_card_checkout_spec.rb | 3 +- spec/features/frontend/venmo_checkout_spec.rb | 3 +- spec/support/order_walkthrough.rb | 83 +++++++++++++++++++ 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 spec/support/order_walkthrough.rb diff --git a/spec/features/backend/new_payment_spec.rb b/spec/features/backend/new_payment_spec.rb index 528675d3..5b608333 100644 --- a/spec/features/backend/new_payment_spec.rb +++ b/spec/features/backend/new_payment_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -require 'spree/testing_support/order_walkthrough' shared_context "with backend checkout setup" do let(:braintree) { new_gateway(active: true) } diff --git a/spec/features/frontend/braintree_credit_card_checkout_spec.rb b/spec/features/frontend/braintree_credit_card_checkout_spec.rb index b0bf0524..e15db19f 100644 --- a/spec/features/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/features/frontend/braintree_credit_card_checkout_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -require 'spree/testing_support/order_walkthrough' shared_context "with frontend checkout setup" do let(:braintree) { new_gateway(active: true) } @@ -26,7 +25,7 @@ end order = if Spree.solidus_gem_version >= Gem::Version.new('2.6.0') - Spree::TestingSupport::OrderWalkthrough.up_to(:delivery) + SolidusBraintree::OrderWalkthrough.up_to(:delivery) else OrderWalkthrough.up_to(:delivery) end diff --git a/spec/features/frontend/venmo_checkout_spec.rb b/spec/features/frontend/venmo_checkout_spec.rb index 31a08540..ebf98a18 100644 --- a/spec/features/frontend/venmo_checkout_spec.rb +++ b/spec/features/frontend/venmo_checkout_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'spec_helper' -require 'spree/testing_support/order_walkthrough' describe "Checkout", type: :feature, js: true do let(:braintree_preferences) { { venmo: true }.merge(preferences) } @@ -134,7 +133,7 @@ def go_to_payment_checkout_page(order_number: 'R300000001' ) order = if Spree.solidus_gem_version >= Gem::Version.new('2.6.0') - Spree::TestingSupport::OrderWalkthrough.up_to(:address) + SolidusBraintree::OrderWalkthrough.up_to(:address) else OrderWalkthrough.up_to(:address) end diff --git a/spec/support/order_walkthrough.rb b/spec/support/order_walkthrough.rb new file mode 100644 index 00000000..02af8902 --- /dev/null +++ b/spec/support/order_walkthrough.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module SolidusBraintree + class OrderWalkthrough + def self.up_to(state, user: nil) + new.up_to(state, user: user) + end + + def up_to(state, user: nil) + # Need to create a valid zone too... + @zone = ::FactoryBot.create(:zone) + @country = ::FactoryBot.create(:country) + @state = ::FactoryBot.create(:state, country: @country) + + @zone.members << ::Spree::ZoneMember.create(zoneable: @country) + + # A shipping method must exist for rates to be displayed on checkout page + ::FactoryBot.create(:shipping_method, zones: [@zone]).tap do |sm| + sm.calculator.preferred_amount = 10 + sm.calculator.preferred_currency = ::Spree::Config[:currency] + sm.calculator.save + end + + order = ::Spree::Order.create!( + user: user, + email: "solidus@example.com", + store: ::Spree::Store.first || ::FactoryBot.create(:store) + ) + add_line_item!(order) + order.next! + + states_to_process = if state == :complete + states + else + end_state_position = states.index(state.to_sym) + states[..end_state_position] + end + + states_to_process.each do |state_to_process| + send(state_to_process, order) + end + + order + end + + private + + def add_line_item!(order) + ::FactoryBot.create(:line_item, order: order) + order.reload + end + + def address(order) + order.bill_address = ::FactoryBot.create(:address, country: @country, state: @state) + order.ship_address = ::FactoryBot.create(:address, country: @country, state: @state) + order.next! + end + + def delivery(order) + order.next! + end + + def payment(order) + credit_card = ::FactoryBot.create(:credit_card, user: order.user) + order.payments.create!(payment_method: credit_card.payment_method, amount: order.total, source: credit_card) + # TODO: maybe look at some way of making this payment_state change automatic + order.payment_state = 'paid' + order.next! + end + + def confirm(order) + order.complete! + end + + def complete(order) + # noop? + end + + def states + [:address, :delivery, :payment, :confirm] + end + end +end From cdb7cc5f70213daf893219dc351d16e517e0227e Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 10:34:50 +0800 Subject: [PATCH 02/66] Avoid modifying the address factory We'll be changing the frontend of the extension to SolidusStarterFrontend in the following commits. In the resulting update, specs for this extension and specs for the frontend will be run together in a single dummy app. Based on my tests, it seems the factory modifications are causing the coupon code spec from the starter frontend spec suite to break. Instead of modifying the address factory, we're taking the route of creating a subclass of the factory that is namespaced to solidus_braintree. This makes it safer to merge the extension's specs with the starter frontend specs. Done: * Created solidus_braintree_address factory. * Created with_first_and_last_name trait. * Created with_fixed_zipcode trait. * Used with_fixed_zipcode trait in OrderWalkthrough class. --- .../testing_support/factories.rb | 32 ++++++++++--------- spec/support/order_ready_for_payment.rb | 9 +++++- spec/support/order_walkthrough.rb | 8 +++-- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/lib/solidus_braintree/testing_support/factories.rb b/lib/solidus_braintree/testing_support/factories.rb index a69697a3..341cae6a 100644 --- a/lib/solidus_braintree/testing_support/factories.rb +++ b/lib/solidus_braintree/testing_support/factories.rb @@ -28,26 +28,28 @@ payment_type { SolidusBraintree::Source::APPLE_PAY } end end -end -FactoryBot.modify do - # The Solidus address factory randomizes the zipcode. - # The OrderWalkThrough we use in the credit card checkout spec uses this factory for the user addresses. - # For credit card payments we transmit the billing address to braintree, for paypal payments the shipping address. - # As we match the body in our VCR settings VCR can not match the request anymore and therefore cannot replay existing - # cassettes. - # + factory :solidus_braintree_address, parent: :address do + trait :with_fixed_zipcode do + # The Solidus address factory randomizes the zipcode. + # The OrderWalkThrough we use in the credit card checkout spec uses this factory for the user addresses. + # For credit card payments we transmit the billing address to braintree, for paypal payments the shipping address. + # As we match the body in our VCR settings VCR can not match the request anymore and therefore cannot replay existing + # cassettes. + # - factory :address do - zipcode { '21088-0255' } + zipcode { '21088-0255' } + end if SolidusSupport.combined_first_and_last_name_in_address? - transient do - firstname { "John" } - lastname { "Doe" } - end + trait :with_first_and_last_name do + transient do + firstname { "John" } + lastname { "Doe" } + end - name { "#{firstname} #{lastname}" } + name { "#{firstname} #{lastname}" } + end end end end diff --git a/spec/support/order_ready_for_payment.rb b/spec/support/order_ready_for_payment.rb index c7c25835..da1e6b62 100644 --- a/spec/support/order_ready_for_payment.rb +++ b/spec/support/order_ready_for_payment.rb @@ -2,7 +2,14 @@ let!(:country) { create :country } let(:user) { create :user } - let(:address) { create :address, zipcode: "90210", lastname: "Doe", country: country } + + let(:address) do + create :solidus_braintree_address, + :with_first_and_last_name, + zipcode: "90210", + lastname: "Doe", + country: country + end before do create :shipping_method, cost: 5 diff --git a/spec/support/order_walkthrough.rb b/spec/support/order_walkthrough.rb index 02af8902..184f39be 100644 --- a/spec/support/order_walkthrough.rb +++ b/spec/support/order_walkthrough.rb @@ -51,8 +51,12 @@ def add_line_item!(order) end def address(order) - order.bill_address = ::FactoryBot.create(:address, country: @country, state: @state) - order.ship_address = ::FactoryBot.create(:address, country: @country, state: @state) + order.bill_address = + ::FactoryBot.create(:solidus_braintree_address, :with_fixed_zipcode, country: @country, state: @state) + + order.ship_address = + ::FactoryBot.create(:solidus_braintree_address, :with_fixed_zipcode, country: @country, state: @state) + order.next! end From f8e81f3bd0030871dadc072a9f34a497979d1754 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 6 Feb 2023 15:25:29 +0800 Subject: [PATCH 03/66] Rename auto_run_migrations option to migrate --- lib/generators/solidus_braintree/install/install_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 32dec1ae..523dfc41 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -3,7 +3,7 @@ module SolidusBraintree module Generators class InstallGenerator < Rails::Generators::Base - class_option :auto_run_migrations, type: :boolean, default: false + class_option :migrate, type: :boolean, default: false source_root File.expand_path('templates', __dir__) def setup_initializer @@ -59,7 +59,7 @@ def mount_engine end def run_migrations - run_migrations = options[:auto_run_migrations] || + run_migrations = options[:migrate] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) if run_migrations From 1281da6917a79acdadfed3f81acf1fc4ccf0ca9b Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 6 Feb 2023 15:12:55 +0800 Subject: [PATCH 04/66] [BREAKS BUILD] Run specs on solidus_starter_frontend * Copy Rakefile and dependencies from SolidusPaypalCommercePlatform * Rename references to solidus_paypal_commerce_platform to solidus_braintree. * Ignore dummy-app directory. --- .gitignore | 1 + Rakefile | 7 ++++++- bin/dummy-app | 37 +++++++++++++++++++++++++++++++++++++ bin/rails-dummy-app | 17 +++++++++++++++++ bin/rspec | 11 +++++++++++ 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100755 bin/dummy-app create mode 100755 bin/rails-dummy-app create mode 100755 bin/rspec diff --git a/.gitignore b/.gitignore index 325c3c99..14b329f7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ .project .sass-cache coverage +dummy-app Gemfile.lock tmp nbproject diff --git a/Rakefile b/Rakefile index c08aa468..8e964326 100644 --- a/Rakefile +++ b/Rakefile @@ -3,4 +3,9 @@ require 'solidus_dev_support/rake_tasks' SolidusDevSupport::RakeTasks.install -task default: 'extension:specs' +task :default do + require 'bundler' + Bundler.with_unbundled_env do + sh 'bin/rspec' + end +end diff --git a/bin/dummy-app b/bin/dummy-app new file mode 100755 index 00000000..c070bf9f --- /dev/null +++ b/bin/dummy-app @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e + +extension_name="solidus_braintree" + +# Stay away from the bundler env of the containing extension. +function unbundled { + ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@" +} + +# "sqlite" is set by the ORB extension instead of "sqlite3", +# all other options are already in the format expected by `rails new`. +test "$DB" = "sqlite" && export DB="sqlite3" + +rm -rf ./dummy-app +rails new dummy-app \ + --database=${DB:-sqlite3} \ + --skip-git \ + --skip-keeps \ + --skip-rc \ + --skip-bootsnap \ + --skip-test + +if [ ! -d "dummy-app" ]; then + echo 'dummy-app rails application failed' + exit 1 +fi + +cd ./dummy-app +unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a' +unbundled bundle exec rake db:drop db:create +unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none --no-seed --no-sample "$@" +unbundled bundle add $extension_name --path .. +unbundled bundle exec rails generate $extension_name:install --migrate --specs=all + + diff --git a/bin/rails-dummy-app b/bin/rails-dummy-app new file mode 100755 index 00000000..58a3513d --- /dev/null +++ b/bin/rails-dummy-app @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +root = "#{__dir__}/.." +app_root = "#{root}/dummy-app" + +unless File.exist? "#{app_root}/bin/rails" + warn 'Creating the dummy-app app...' + Dir.chdir root do + system "#{root}/bin/dummy-app" or begin + warn 'Automatic creation of the dummy-app app failed' + exit 1 + end + end +end + +Dir.chdir app_root +exec "#{app_root}/bin/rails", *ARGV diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 00000000..4631ba92 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -e + +bin/rails-dummy-app generate solidus_braintree:install --force --migrate --specs=all + +cd dummy-app/ +rspec "$@" +exit_status=$? +cd - +exit $exit_status From e9e24d5e7bc1719b7c4ca0662f3290a674ad464e Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 6 Feb 2023 16:13:33 +0800 Subject: [PATCH 05/66] Indent commands in setup_javascripts --- .../solidus_braintree/install/install_generator.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 523dfc41..ff97731a 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -25,12 +25,14 @@ def setup_javascripts gsub_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_paypal_braintree\n", '' - append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_braintree\n" + append_file 'vendor/assets/javascripts/spree/frontend/all.js', + "//= require spree/frontend/solidus_braintree\n" gsub_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_paypal_braintree\n", '' - append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_braintree\n" + append_file 'vendor/assets/javascripts/spree/backend/all.js', + "//= require spree/backend/solidus_braintree\n" end def setup_stylesheets From 990a39c07530038d22cf84b8dbe379d0c94aaec4 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 6 Feb 2023 16:14:42 +0800 Subject: [PATCH 06/66] Move SolidusBraintree requirement calls to StarterFrontend assets Allows extension assets to be required after StarterFrontend assets. --- lib/generators/solidus_braintree/install/install_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index ff97731a..9d03309c 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -25,7 +25,7 @@ def setup_javascripts gsub_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_paypal_braintree\n", '' - append_file 'vendor/assets/javascripts/spree/frontend/all.js', + append_file 'app/assets/javascripts/solidus_starter_frontend.js', "//= require spree/frontend/solidus_braintree\n" gsub_file 'vendor/assets/javascripts/spree/backend/all.js', @@ -39,7 +39,7 @@ def setup_stylesheets gsub_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_paypal_braintree\n", '' - inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', + inject_into_file 'app/assets/stylesheets/solidus_starter_frontend.css', " *= require spree/frontend/solidus_braintree\n", before: %r{\*/}, verbose: true gsub_file 'vendor/assets/stylesheets/spree/backend/all.css', From 6f144fef8451e22307f9b5d00d749f83ed9a38ab Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 6 Feb 2023 16:42:12 +0800 Subject: [PATCH 07/66] Separate frontend and backend JavaScript assets --- .../javascripts/solidus_braintree/frontend.js | 14 - .../spree/backend/solidus_braintree.js | 8 +- .../backend}/solidus_braintree/client.js | 0 .../backend}/solidus_braintree/constants.js | 0 .../backend}/solidus_braintree/hosted_form.js | 0 .../backend}/solidus_braintree/promise.js | 0 .../spree/frontend/paypal_button.js | 2 +- .../spree/frontend/solidus_braintree.js | 2 +- .../solidus_braintree/apple_pay_button.js | 2 +- .../frontend}/solidus_braintree/checkout.js | 2 +- .../frontend/solidus_braintree/client.js | 239 ++++++++++++++++++ .../frontend/solidus_braintree/constants.js | 89 +++++++ .../frontend/solidus_braintree/frontend.js | 14 + .../frontend/solidus_braintree/hosted_form.js | 46 ++++ .../solidus_braintree/paypal_button.js | 2 +- .../solidus_braintree/paypal_messaging.js | 2 +- .../frontend/solidus_braintree/promise.js | 20 ++ .../solidus_braintree/venmo_button.js | 2 +- 18 files changed, 419 insertions(+), 25 deletions(-) delete mode 100644 app/assets/javascripts/solidus_braintree/frontend.js rename app/assets/javascripts/{ => spree/backend}/solidus_braintree/client.js (100%) rename app/assets/javascripts/{ => spree/backend}/solidus_braintree/constants.js (100%) rename app/assets/javascripts/{ => spree/backend}/solidus_braintree/hosted_form.js (100%) rename app/assets/javascripts/{ => spree/backend}/solidus_braintree/promise.js (100%) rename app/assets/javascripts/{ => spree/frontend}/solidus_braintree/apple_pay_button.js (99%) rename app/assets/javascripts/{ => spree/frontend}/solidus_braintree/checkout.js (98%) create mode 100644 app/assets/javascripts/spree/frontend/solidus_braintree/client.js create mode 100644 app/assets/javascripts/spree/frontend/solidus_braintree/constants.js create mode 100644 app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js create mode 100644 app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js rename app/assets/javascripts/{ => spree/frontend}/solidus_braintree/paypal_button.js (99%) rename app/assets/javascripts/{ => spree/frontend}/solidus_braintree/paypal_messaging.js (91%) create mode 100644 app/assets/javascripts/spree/frontend/solidus_braintree/promise.js rename app/assets/javascripts/{ => spree/frontend}/solidus_braintree/venmo_button.js (98%) diff --git a/app/assets/javascripts/solidus_braintree/frontend.js b/app/assets/javascripts/solidus_braintree/frontend.js deleted file mode 100644 index 70a8fa5a..00000000 --- a/app/assets/javascripts/solidus_braintree/frontend.js +++ /dev/null @@ -1,14 +0,0 @@ -// This is a manifest file that'll be compiled into including all the files listed below. -// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically -// be included in the compiled file accessible from http://example.com/assets/application.js -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// the compiled file. -// -//= require solidus_braintree/constants -//= require solidus_braintree/promise -//= require solidus_braintree/client -//= require solidus_braintree/hosted_form -//= require solidus_braintree/paypal_button -//= require solidus_braintree/paypal_messaging -//= require solidus_braintree/apple_pay_button -//= require solidus_braintree/venmo_button diff --git a/app/assets/javascripts/spree/backend/solidus_braintree.js b/app/assets/javascripts/spree/backend/solidus_braintree.js index a75f8056..06075ac4 100644 --- a/app/assets/javascripts/spree/backend/solidus_braintree.js +++ b/app/assets/javascripts/spree/backend/solidus_braintree.js @@ -1,7 +1,7 @@ -//= require solidus_braintree/constants -//= require solidus_braintree/client -//= require solidus_braintree/promise -//= require solidus_braintree/hosted_form +//= require spree/backend/solidus_braintree/constants +//= require spree/backend/solidus_braintree/client +//= require spree/backend/solidus_braintree/promise +//= require spree/backend/solidus_braintree/hosted_form $(function() { var $paymentForm = $("#new_payment"), diff --git a/app/assets/javascripts/solidus_braintree/client.js b/app/assets/javascripts/spree/backend/solidus_braintree/client.js similarity index 100% rename from app/assets/javascripts/solidus_braintree/client.js rename to app/assets/javascripts/spree/backend/solidus_braintree/client.js diff --git a/app/assets/javascripts/solidus_braintree/constants.js b/app/assets/javascripts/spree/backend/solidus_braintree/constants.js similarity index 100% rename from app/assets/javascripts/solidus_braintree/constants.js rename to app/assets/javascripts/spree/backend/solidus_braintree/constants.js diff --git a/app/assets/javascripts/solidus_braintree/hosted_form.js b/app/assets/javascripts/spree/backend/solidus_braintree/hosted_form.js similarity index 100% rename from app/assets/javascripts/solidus_braintree/hosted_form.js rename to app/assets/javascripts/spree/backend/solidus_braintree/hosted_form.js diff --git a/app/assets/javascripts/solidus_braintree/promise.js b/app/assets/javascripts/spree/backend/solidus_braintree/promise.js similarity index 100% rename from app/assets/javascripts/solidus_braintree/promise.js rename to app/assets/javascripts/spree/backend/solidus_braintree/promise.js diff --git a/app/assets/javascripts/spree/frontend/paypal_button.js b/app/assets/javascripts/spree/frontend/paypal_button.js index f2454bd5..57aa10bb 100644 --- a/app/assets/javascripts/spree/frontend/paypal_button.js +++ b/app/assets/javascripts/spree/frontend/paypal_button.js @@ -1,4 +1,4 @@ -//= require solidus_braintree/paypal_button +//= require spree/frontend/solidus_braintree/paypal_button // This is the PayPal button on the cart page $(document).ready(function() { diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree.js b/app/assets/javascripts/spree/frontend/solidus_braintree.js index 36faf819..1aef5cee 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree.js @@ -1 +1 @@ -//= require solidus_braintree/frontend +//= require spree/frontend/solidus_braintree/frontend diff --git a/app/assets/javascripts/solidus_braintree/apple_pay_button.js b/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js similarity index 99% rename from app/assets/javascripts/solidus_braintree/apple_pay_button.js rename to app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js index c31d3483..9c8b0701 100644 --- a/app/assets/javascripts/solidus_braintree/apple_pay_button.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js @@ -1,4 +1,4 @@ -//= require solidus_braintree/constants +//= require spree/frontend/solidus_braintree/constants /** * Constructor for Apple Pay button object * @constructor diff --git a/app/assets/javascripts/solidus_braintree/checkout.js b/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js similarity index 98% rename from app/assets/javascripts/solidus_braintree/checkout.js rename to app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js index fe17080f..198d9c49 100644 --- a/app/assets/javascripts/solidus_braintree/checkout.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js @@ -1,4 +1,4 @@ -//= require solidus_braintree/frontend +//= require spree/frontend/solidus_braintree/frontend $(function() { /* This provides a default error handler for Braintree. Since we prevent diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/client.js b/app/assets/javascripts/spree/frontend/solidus_braintree/client.js new file mode 100644 index 00000000..883184e7 --- /dev/null +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/client.js @@ -0,0 +1,239 @@ +/** + * Braintree client interface + * @external "braintree.Client" + * @see {@link https://braintree.github.io/braintree-web/current/Client.html|Braintree Client Docs} +**/ + +/** + * Braintree paypal interface + * @external "braintree.PayPal" + * @see {@link https://braintree.github.io/braintree-web/current/PayPal.html|Braintree Paypal Docs} +**/ + +/** + * Braintree paypal interface + * @external "braintree.ApplePay" + * @see {@link https://braintree.github.io/braintree-web/current/ApplePay.html|Braintree Apple Pay Docs} +**/ + +/** + * Braintree dataCollector interface + * @external "braintree.DataCollector" + * @see {@link https://braintree.github.io/braintree-web/current/DataCollector.html|Braintree DataCollector Docs} +**/ + +/** + * jQuery.Deferred interface + * + * We use this for our promises because ES6 promises are non standard, and because jquery 1/2 + * promises do not play nicely with them. + * @external "jQuery.Deferred" + * @see {@link https://api.jquery.com/category/deferred-object/|jQuery Deferred Documentation} +**/ + +/** + * Represents a wrapper around the braintree js library. + * + * This class is responsible for fetching tokens from a solidus store and using them + * to manage a braintree client. It takes a number of options as capabilities for the client + * depending on if you want to use use the data collector or paypal. + * + * We use this class mostly to hide the token operations for users. + * + * After creating the class, a call should be made to initialize before using it. + * @see initialize + * + * @constructor + * @param {Object} config Initalization options for the client + * @param {Boolean} config.useDataCollector Use data collector capabilities for the braintree client + * @param {Boolean} config.usePaypal Use Paypal capabilities for the braintree client + * @param {requestCallback} config.readyCallback A callback to be invoked when the client is ready to go. + * @param {Number} config.paymentMethodId A number indicating a specific payment method to be preferrred. + * +**/ +SolidusBraintree.Client = function(config) { + this.paymentMethodId = config.paymentMethodId; + this.readyCallback = config.readyCallback; + this.useDataCollector = config.useDataCollector; + this.usePaypal = config.usePaypal; + this.useApplepay = config.useApplepay; + this.useVenmo = config.useVenmo; + this.flow = config.flow; + this.venmoNewTabSupported = config.newBrowserTabSupported + this.useThreeDSecure = config.useThreeDSecure; + + this._braintreeInstance = null; + this._dataCollectorInstance = null; + this._paypalInstance = null; + this._venmoInstance = null; + this._threeDSecureInstance = null; +}; + +/** + * Fetches a client token from the backend and initializes the braintree client. + * @returns {external:"jQuery.Deferred"} Promise to be invoked after initialization is complete +**/ +SolidusBraintree.Client.prototype.initialize = function() { + var initializationPromise = this._fetchToken(). + then(this._createBraintreeInstance.bind(this)); + + if (this.useDataCollector) { + initializationPromise = initializationPromise.then(this._createDataCollector.bind(this)); + } + + if (this.usePaypal) { + initializationPromise = initializationPromise.then(this._createPaypal.bind(this)); + } + + if (this.useApplepay) { + initializationPromise = initializationPromise.then(this._createApplepay.bind(this)); + } + + if (this.useVenmo) { + initializationPromise = initializationPromise.then(this._createVenmo.bind(this)); + } + + if (this.useThreeDSecure) { + initializationPromise = initializationPromise.then(this._createThreeDSecure.bind(this)); + } + + return initializationPromise.then(this._invokeReadyCallback.bind(this)); +}; + +/** + * Returns the braintree client instance + * @returns {external:"braintree.Client"} The braintree client that was initialized by this class +**/ +SolidusBraintree.Client.prototype.getBraintreeInstance = function() { + return this._braintreeInstance; +}; + +/** + * Returns the braintree paypal instance + * @returns {external:"braintree.PayPal"} The braintree paypal that was initialized by this class +**/ +SolidusBraintree.Client.prototype.getPaypalInstance = function() { + return this._paypalInstance; +}; + +/** + * Returns the braintree Apple Pay instance + * @returns {external:"braintree.ApplePay"} The Braintree Apple Pay that was initialized by this class +**/ +SolidusBraintree.Client.prototype.getApplepayInstance = function() { + return this._applepayInstance; +}; + +/** + * Returns the braintree Venmo instance + * @returns {external:"braintree.Venmo"} The Braintree Venmo that was initialized by this class +**/ +SolidusBraintree.Client.prototype.getVenmoInstance = function() { + return this._venmoInstance; +}; + +/** + * Returns the braintree dataCollector instance + * @returns {external:"braintree.DataCollector"} The braintree dataCollector that was initialized by this class +**/ +SolidusBraintree.Client.prototype.getDataCollectorInstance = function() { + return this._dataCollectorInstance; +}; + + +SolidusBraintree.Client.prototype._fetchToken = function() { + var payload = { + dataType: 'json', + type: 'POST', + url: SolidusBraintree.config.paths.clientTokens, + error: function(xhr) { + console.error("Error fetching braintree token"); + } + }; + + if (this.paymentMethodId) { + payload.data = { + payment_method_id: this.paymentMethodId + }; + } + + return Spree.ajax(payload); +}; + +SolidusBraintree.Client.prototype._createBraintreeInstance = function(tokenResponse) { + this.paymentMethodId = tokenResponse.payment_method_id; + + return SolidusBraintree.PromiseShim.convertBraintreePromise(braintree.client.create, [{ + authorization: tokenResponse.client_token + }]).then(function (clientInstance) { + this._braintreeInstance = clientInstance; + return clientInstance; + }.bind(this)); +}; + +SolidusBraintree.Client.prototype._invokeReadyCallback = function() { + if(this.readyCallback) { + this.readyCallback(this._braintreeInstance); + } + + return this; +}; + +SolidusBraintree.Client.prototype._createDataCollector = function() { + return SolidusBraintree.PromiseShim.convertBraintreePromise(braintree.dataCollector.create, [{ + client: this._braintreeInstance, + paypal: !!this.usePaypal + }]).then(function (dataCollectorInstance) { + this._dataCollectorInstance = dataCollectorInstance; + return dataCollectorInstance; + }.bind(this)); +}; + +SolidusBraintree.Client.prototype._createPaypal = function() { + return SolidusBraintree.PromiseShim.convertBraintreePromise(braintree.paypalCheckout.create, [{ + client: this._braintreeInstance + }]).then(function (paypalInstance) { + this._paypalInstance = paypalInstance; + return paypalInstance; + }.bind(this), function(error) { + console.error(error.name + ':', error.message); + }); +}; + +SolidusBraintree.Client.prototype._createApplepay = function() { + return SolidusBraintree.PromiseShim.convertBraintreePromise(braintree.applePay.create, [{ + client: this._braintreeInstance + }]).then(function (applePayInstance) { + this._applepayInstance = applePayInstance; + return applePayInstance; + }.bind(this)); +}; + +SolidusBraintree.Client.prototype._createVenmo = function() { + return SolidusBraintree.PromiseShim.convertBraintreePromise(braintree.venmo.create, [{ + client: this._braintreeInstance, + allowDesktop: true, + paymentMethodUsage: this.flow === 'vault' ? 'multi_use' : 'single_use', + allowNewBrowserTab: this.venmoNewTabSupported + }]).then(function (venmoInstance) { + // Verify browser support before proceeding. + if (!venmoInstance.isBrowserSupported()) { + console.log('Browser does not support Venmo'); + return; + } + + this._venmoInstance = venmoInstance; + return venmoInstance; + }.bind(this)); +}; + +SolidusBraintree.Client.prototype._createThreeDSecure = function() { + return SolidusBraintree.PromiseShim.convertBraintreePromise(braintree.threeDSecure.create, [{ + client: this._braintreeInstance, + version: 2 + }]).then(function (threeDSecureInstance) { + this._threeDSecureInstance = threeDSecureInstance; + }.bind(this), function(error) { + console.log(error); + }); +}; diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js b/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js new file mode 100644 index 00000000..a0d6d7fd --- /dev/null +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js @@ -0,0 +1,89 @@ +SolidusBraintree = { + APPLE_PAY_API_VERSION: 1, + + config: { + paths: { + clientTokens: Spree.pathFor('solidus_braintree/client_token'), + transactions: Spree.pathFor('solidus_braintree/transactions') + }, + + // Override to provide your own error messages. + braintreeErrorHandle: function(braintreeError) { + BraintreeError.getErrorFromSlug(braintreeError.code); + SolidusBraintree.showError(error); + }, + + classes: { + hostedForm: function() { + return SolidusBraintree.HostedForm; + }, + + client: function() { + return SolidusBraintree.Client; + }, + + paypalButton: function() { + return SolidusBraintree.PaypalButton; + }, + + paypalMessaging: function() { + return SolidusBraintree.PaypalMessaging; + }, + + applepayButton: function() { + return SolidusBraintree.ApplepayButton; + }, + + venmoButton: function() { + return SolidusBraintree.VenmoButton; + } + } + }, + + showError: function(error) { + var $contentContainer = $("#content"); + var $flash = $("
" + error + "
"); + $contentContainer.prepend($flash); + $flash.show().delay(5000).fadeOut(500); + }, + + createHostedForm: function() { + return SolidusBraintree._factory(SolidusBraintree.config.classes.hostedForm(), arguments); + }, + + createClient: function() { + return SolidusBraintree._factory(SolidusBraintree.config.classes.client(), arguments); + }, + + createPaypalButton: function() { + return SolidusBraintree._factory(SolidusBraintree.config.classes.paypalButton(), arguments); + }, + + createPaypalMessaging: function() { + return SolidusBraintree._factory(SolidusBraintree.config.classes.paypalMessaging(), arguments); + }, + + createApplePayButton: function() { + return SolidusBraintree._factory(SolidusBraintree.config.classes.applepayButton(), arguments); + }, + + createVenmoButton: function() { + return SolidusBraintree._factory(SolidusBraintree.config.classes.venmoButton(), arguments); + }, + + _factory: function(klass, args) { + var normalizedArgs = Array.prototype.slice.call(args); + return new (Function.prototype.bind.apply(klass, [null].concat(normalizedArgs))); + } +}; + +BraintreeError = { + DEFAULT: "Something bad happened!", + + getErrorFromSlug: function(slug) { + error = BraintreeError.DEFAULT + if (slug in BraintreeError) + error = BraintreeError[slug] + return error + } +} diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js b/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js new file mode 100644 index 00000000..c78dd5b2 --- /dev/null +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js @@ -0,0 +1,14 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require spree/frontend/solidus_braintree/constants +//= require spree/frontend/solidus_braintree/promise +//= require spree/frontend/solidus_braintree/client +//= require spree/frontend/solidus_braintree/hosted_form +//= require spree/frontend/solidus_braintree/paypal_button +//= require spree/frontend/solidus_braintree/paypal_messaging +//= require spree/frontend/solidus_braintree/apple_pay_button +//= require spree/frontend/solidus_braintree/venmo_button diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js b/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js new file mode 100644 index 00000000..4329e03d --- /dev/null +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js @@ -0,0 +1,46 @@ +SolidusBraintree.HostedForm = function(paymentMethodId) { + this.paymentMethodId = paymentMethodId; + this.client = null; +}; + +SolidusBraintree.HostedForm.prototype.initialize = function() { + this.client = SolidusBraintree.createClient({ + paymentMethodId: this.paymentMethodId, + useThreeDSecure: (typeof(window.threeDSecureOptions) !== 'undefined'), + }); + + return this.client.initialize(). + then(this._createHostedFields.bind(this)); +}; + +SolidusBraintree.HostedForm.prototype._createHostedFields = function () { + if (!this.client) { + throw new Error("Client not initialized, please call initialize first!"); + } + + var opts = { + _solidusClient: this.client, + client: this.client.getBraintreeInstance(), + + fields: { + number: { + selector: "#card_number" + this.paymentMethodId, + placeholder: placeholder_text["number"] + }, + + cvv: { + selector: "#card_code" + this.paymentMethodId, + placeholder: placeholder_text["cvv"] + }, + + expirationDate: { + selector: "#card_expiry" + this.paymentMethodId, + placeholder: placeholder_text["expirationDate"] + } + }, + + styles: credit_card_fields_style + }; + + return SolidusBraintree.PromiseShim.convertBraintreePromise(braintree.hostedFields.create, [opts]); +}; diff --git a/app/assets/javascripts/solidus_braintree/paypal_button.js b/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js similarity index 99% rename from app/assets/javascripts/solidus_braintree/paypal_button.js rename to app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js index cdeeadfc..2e0cab45 100644 --- a/app/assets/javascripts/solidus_braintree/paypal_button.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js @@ -1,4 +1,4 @@ -//= require solidus_braintree/constants +//= require spree/frontend/solidus_braintree/constants /** * Constructor for PayPal button object * @constructor diff --git a/app/assets/javascripts/solidus_braintree/paypal_messaging.js b/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js similarity index 91% rename from app/assets/javascripts/solidus_braintree/paypal_messaging.js rename to app/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js index 5266f48b..2823c8a3 100644 --- a/app/assets/javascripts/solidus_braintree/paypal_messaging.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js @@ -1,4 +1,4 @@ -//= require solidus_braintree/constants +//= require spree/frontend/solidus_braintree/constants SolidusBraintree.PaypalMessaging = function(paypalOptions) { this._paypalOptions = paypalOptions || {}; diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/promise.js b/app/assets/javascripts/spree/frontend/solidus_braintree/promise.js new file mode 100644 index 00000000..15003dff --- /dev/null +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/promise.js @@ -0,0 +1,20 @@ +SolidusBraintree.PromiseShim = { + convertBraintreePromise: function(fn, args, context) { + var jqPromise = $.Deferred(); + + args = args || []; + context = context || this; + + args = args.concat(function(error, data) { + if (error) { + jqPromise.reject(error); + } else { + jqPromise.resolve(data); + } + }); + + fn.apply(context, args); + + return jqPromise.promise(); + } +} diff --git a/app/assets/javascripts/solidus_braintree/venmo_button.js b/app/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js similarity index 98% rename from app/assets/javascripts/solidus_braintree/venmo_button.js rename to app/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js index 1e547795..1b233e85 100644 --- a/app/assets/javascripts/solidus_braintree/venmo_button.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js @@ -1,4 +1,4 @@ -//= require solidus_braintree/constants +//= require spree/frontend/solidus_braintree/constants /** * Constructor for Venmo button object * @constructor From 998f4a867dc5f15961b14c6330f8079c80efc02b Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 6 Feb 2023 16:19:08 +0800 Subject: [PATCH 08/66] Update Spree.pathFor references --- .../javascripts/spree/frontend/solidus_braintree/constants.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js b/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js index a0d6d7fd..eedb9ca0 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js @@ -3,8 +3,8 @@ SolidusBraintree = { config: { paths: { - clientTokens: Spree.pathFor('solidus_braintree/client_token'), - transactions: Spree.pathFor('solidus_braintree/transactions') + clientTokens: Solidus.pathFor('solidus_braintree/client_token'), + transactions: Solidus.pathFor('solidus_braintree/transactions') }, // Override to provide your own error messages. From 6c64a50469ee5053747ff9933a61f05dfc4213e7 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 6 Feb 2023 16:52:16 +0800 Subject: [PATCH 09/66] Move checkout view directories out of spree Consolidate `checkouts` directories to app directory. --- .../checkout => checkouts}/existing_payment/_braintree.html.erb | 0 .../checkout => app/views/checkouts}/payment/_braintree.html.erb | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename app/views/{spree/checkout => checkouts}/existing_payment/_braintree.html.erb (100%) rename {lib/views/frontend/spree/checkout => app/views/checkouts}/payment/_braintree.html.erb (100%) diff --git a/app/views/spree/checkout/existing_payment/_braintree.html.erb b/app/views/checkouts/existing_payment/_braintree.html.erb similarity index 100% rename from app/views/spree/checkout/existing_payment/_braintree.html.erb rename to app/views/checkouts/existing_payment/_braintree.html.erb diff --git a/lib/views/frontend/spree/checkout/payment/_braintree.html.erb b/app/views/checkouts/payment/_braintree.html.erb similarity index 100% rename from lib/views/frontend/spree/checkout/payment/_braintree.html.erb rename to app/views/checkouts/payment/_braintree.html.erb From 1aa4e330bdd7e21a790aff2c6fcfed4e3688649d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 08:51:38 +0800 Subject: [PATCH 10/66] Update path to checkout.js --- app/views/spree/shared/_braintree_head_scripts.html.erb | 2 +- lib/solidus_braintree/engine.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/spree/shared/_braintree_head_scripts.html.erb b/app/views/spree/shared/_braintree_head_scripts.html.erb index c45e9e82..c1ab1b86 100644 --- a/app/views/spree/shared/_braintree_head_scripts.html.erb +++ b/app/views/spree/shared/_braintree_head_scripts.html.erb @@ -22,5 +22,5 @@ <% end %> - <%= javascript_include_tag "solidus_braintree/checkout" %> + <%= javascript_include_tag "spree/frontend/solidus_braintree/checkout" %> <% end %> diff --git a/lib/solidus_braintree/engine.rb b/lib/solidus_braintree/engine.rb index 5f6e364c..cf21ce44 100644 --- a/lib/solidus_braintree/engine.rb +++ b/lib/solidus_braintree/engine.rb @@ -24,7 +24,7 @@ class Engine < Rails::Engine if SolidusSupport.frontend_available? config.assets.precompile += [ - 'solidus_braintree/checkout.js', + 'spree/frontend/solidus_braintree/checkout.js', 'solidus_braintree/frontend.js', 'spree/frontend/apple_pay_button.js', 'solidus_braintree_manifest.js' From 22de4ec789ac9cb69ec879b47eae7f5c6fa8e63f Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 08:53:16 +0800 Subject: [PATCH 11/66] Add jQuery to solidus_braintree jQuery needs to be defined before rails-ujs in order for CSRF tokens to be passed to ajax requests. --- .../solidus_braintree/install/install_generator.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 9d03309c..849aed07 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -22,6 +22,11 @@ def setup_initializer end def setup_javascripts + inject_into_file 'vendor/assets/javascripts/spree/frontend/all.js', + "//= require jquery3\n", + before: '//= require rails-ujs', + verbose: true + gsub_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_paypal_braintree\n", '' From 5350374d74e9b5d284d56649c1575f5382ff1a94 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 08:56:06 +0800 Subject: [PATCH 12/66] Add SolidusBraintree.ajax Copied from Spree.ajax. See https://github.com/solidusio/solidus/blob/e878076f2ed670d07654ab6293a16588743f2fa6/core/app/assets/javascripts/spree.js.erb#L25. --- .../spree/frontend/solidus_braintree/ajax.js | 13 +++++++++++++ .../frontend/solidus_braintree/apple_pay_button.js | 2 +- .../spree/frontend/solidus_braintree/client.js | 2 +- .../spree/frontend/solidus_braintree/frontend.js | 1 + .../frontend/solidus_braintree/paypal_button.js | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js b/app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js new file mode 100644 index 00000000..c96f4d90 --- /dev/null +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js @@ -0,0 +1,13 @@ +SolidusBraintree.ajax = function(url, options) { + if (typeof url === "object") { + options = url; + url = undefined; + } + options = options || {}; + options = $.extend(options, { + headers: { + 'Authorization': 'Bearer ' + } + }); + return $.ajax(url, options); +}; diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js b/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js index 9c8b0701..f9924d32 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js @@ -94,7 +94,7 @@ SolidusBraintree.ApplepayButton.prototype.tokenize = function (session, payment) }; SolidusBraintree.ApplepayButton.prototype._createTransaction = function (session, payment, payload) { - Spree.ajax({ + SolidusBraintree.ajax({ data: this._transactionParams(payload, payment.shippingContact), dataType: 'json', type: 'POST', diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/client.js b/app/assets/javascripts/spree/frontend/solidus_braintree/client.js index 883184e7..a09890ab 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/client.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/client.js @@ -157,7 +157,7 @@ SolidusBraintree.Client.prototype._fetchToken = function() { }; } - return Spree.ajax(payload); + return SolidusBraintree.ajax(payload); }; SolidusBraintree.Client.prototype._createBraintreeInstance = function(tokenResponse) { diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js b/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js index c78dd5b2..0bddfbea 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js @@ -5,6 +5,7 @@ // the compiled file. // //= require spree/frontend/solidus_braintree/constants +//= require spree/frontend/solidus_braintree/ajax //= require spree/frontend/solidus_braintree/promise //= require spree/frontend/solidus_braintree/client //= require spree/frontend/solidus_braintree/hosted_form diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js b/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js index 2e0cab45..dc6468b7 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js @@ -99,7 +99,7 @@ SolidusBraintree.PaypalButton.prototype._tokenizeCallback = function(tokenizeErr var params = this._transactionParams(payload); - return Spree.ajax({ + return SolidusBraintree.ajax({ url: SolidusBraintree.config.paths.transactions, type: 'POST', dataType: 'json', From 6c751fcfecad1d0e1435cea6d7702a28761319f8 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 08:58:35 +0800 Subject: [PATCH 13/66] [SSF specs passing] Loosen selector for checkout submit element * The element was changed from input to button in SolidusStarterFrontend. * Manual checkout is now successful. * The SoliduStarterFrontend specs are now passing with the dummy app. However, the dummy app doesn't include yet the SolidusBraintree specs. --- .../javascripts/spree/frontend/solidus_braintree/checkout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js b/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js index 198d9c49..0099a7b4 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js @@ -84,7 +84,7 @@ $(function() { var $paymentForm = $("#checkout_form_payment"); var $hostedFields = $("[data-braintree-hosted-fields]"); - var $submitButton = $("input[type='submit']", $paymentForm); + var $submitButton = $("[type='submit']", $paymentForm); // If we're not using hosted fields, the form doesn't need to wait. if ($hostedFields.length > 0) { From 50e5912723243f0cae429ea9ccc5fd482d019f4b Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 10:01:49 +0800 Subject: [PATCH 14/66] Move feature specs to system --- spec/{features => system}/backend/configuration_spec.rb | 0 spec/{features => system}/backend/new_payment_spec.rb | 0 .../frontend/braintree_credit_card_checkout_spec.rb | 0 spec/{features => system}/frontend/paypal_checkout_spec.rb | 0 spec/{features => system}/frontend/venmo_checkout_spec.rb | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename spec/{features => system}/backend/configuration_spec.rb (100%) rename spec/{features => system}/backend/new_payment_spec.rb (100%) rename spec/{features => system}/frontend/braintree_credit_card_checkout_spec.rb (100%) rename spec/{features => system}/frontend/paypal_checkout_spec.rb (100%) rename spec/{features => system}/frontend/venmo_checkout_spec.rb (100%) diff --git a/spec/features/backend/configuration_spec.rb b/spec/system/backend/configuration_spec.rb similarity index 100% rename from spec/features/backend/configuration_spec.rb rename to spec/system/backend/configuration_spec.rb diff --git a/spec/features/backend/new_payment_spec.rb b/spec/system/backend/new_payment_spec.rb similarity index 100% rename from spec/features/backend/new_payment_spec.rb rename to spec/system/backend/new_payment_spec.rb diff --git a/spec/features/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb similarity index 100% rename from spec/features/frontend/braintree_credit_card_checkout_spec.rb rename to spec/system/frontend/braintree_credit_card_checkout_spec.rb diff --git a/spec/features/frontend/paypal_checkout_spec.rb b/spec/system/frontend/paypal_checkout_spec.rb similarity index 100% rename from spec/features/frontend/paypal_checkout_spec.rb rename to spec/system/frontend/paypal_checkout_spec.rb diff --git a/spec/features/frontend/venmo_checkout_spec.rb b/spec/system/frontend/venmo_checkout_spec.rb similarity index 100% rename from spec/features/frontend/venmo_checkout_spec.rb rename to spec/system/frontend/venmo_checkout_spec.rb From 81f71a9f92e1315f6f41affe97a3e78230e78d3d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 10:04:30 +0800 Subject: [PATCH 15/66] Install SolidusBraintree specs when generating extension * Copy installer from SolidusPaypalCommercePlatform. * Replace spec helper with solidus_braintree helper. * Move solidus_braintree spec support files in own directory. --- .../install/install_generator.rb | 31 ++++++++++++++++++ spec/solidus_braintree_helper.rb | 6 ++++ spec/spec_helper.rb | 32 ------------------- .../{ => solidus_braintree}/capybara.rb | 0 .../gateway_helpers.rb | 0 .../order_ready_for_payment.rb | 0 .../order_walkthrough.rb | 0 spec/support/{ => solidus_braintree}/vcr.rb | 0 spec/support/{ => solidus_braintree}/views.rb | 0 9 files changed, 37 insertions(+), 32 deletions(-) create mode 100644 spec/solidus_braintree_helper.rb delete mode 100644 spec/spec_helper.rb rename spec/support/{ => solidus_braintree}/capybara.rb (100%) rename spec/support/{ => solidus_braintree}/gateway_helpers.rb (100%) rename spec/support/{ => solidus_braintree}/order_ready_for_payment.rb (100%) rename spec/support/{ => solidus_braintree}/order_walkthrough.rb (100%) rename spec/support/{ => solidus_braintree}/vcr.rb (100%) rename spec/support/{ => solidus_braintree}/views.rb (100%) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 849aed07..6719dec7 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -6,6 +6,10 @@ class InstallGenerator < Rails::Generators::Base class_option :migrate, type: :boolean, default: false source_root File.expand_path('templates', __dir__) + # This is only used to run all-specs during development and CI, regular installation limits + # installed specs to frontend, which are the ones related to code copied to the target application. + class_option :specs, type: :string, enum: %w[all frontend], default: 'frontend', hide: true + def setup_initializer legacy_initializer_pathname = Pathname.new(destination_root).join('config/initializers/solidus_paypal_braintree.rb') @@ -75,6 +79,33 @@ def run_migrations puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output end end + + def install_specs + spec_paths = + case options[:specs] + when 'all' then %w[spec] + when 'frontend' + %w[ + spec/solidus_braintree_helper.rb + spec/system/frontend + spec/support + ] + end + + spec_paths.each do |path| + if engine.root.join(path).directory? + directory engine.root.join(path), path + else + template engine.root.join(path), path + end + end + end + + private + + def engine + SolidusBraintree::Engine + end end end end diff --git a/spec/solidus_braintree_helper.rb b/spec/solidus_braintree_helper.rb new file mode 100644 index 00000000..f40ed49c --- /dev/null +++ b/spec/solidus_braintree_helper.rb @@ -0,0 +1,6 @@ +require 'solidus_starter_frontend_helper' + +require 'support/solidus_braintree/capybara' +require 'support/solidus_braintree/gateway_helpers' +require 'support/solidus_braintree/order_walkthrough' +require 'support/solidus_braintree/vcr' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index 4ae2bad1..00000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Configure Rails Environment -ENV['RAILS_ENV'] = 'test' - -# Run Coverage report -require 'solidus_dev_support/rspec/coverage' -require 'rails-controller-testing' - -# Create the dummy app if it's still missing. -dummy_env = "#{__dir__}/dummy/config/environment.rb" -system 'bin/rake extension:test_app' unless File.exist? dummy_env -require dummy_env - -# Requires factories and other useful helpers defined in spree_core. -require 'solidus_dev_support/rspec/feature_helper' - -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f } - -# Requires factories defined in lib/solidus_braintree/testing_support/factories.rb -SolidusDevSupport::TestingSupport::Factories.load_for(SolidusBraintree::Engine) - -RSpec.configure do |config| - config.infer_spec_type_from_file_location! - config.use_transactional_fixtures = false - - if Spree.solidus_gem_version < Gem::Version.new('2.11') - config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system - end -end diff --git a/spec/support/capybara.rb b/spec/support/solidus_braintree/capybara.rb similarity index 100% rename from spec/support/capybara.rb rename to spec/support/solidus_braintree/capybara.rb diff --git a/spec/support/gateway_helpers.rb b/spec/support/solidus_braintree/gateway_helpers.rb similarity index 100% rename from spec/support/gateway_helpers.rb rename to spec/support/solidus_braintree/gateway_helpers.rb diff --git a/spec/support/order_ready_for_payment.rb b/spec/support/solidus_braintree/order_ready_for_payment.rb similarity index 100% rename from spec/support/order_ready_for_payment.rb rename to spec/support/solidus_braintree/order_ready_for_payment.rb diff --git a/spec/support/order_walkthrough.rb b/spec/support/solidus_braintree/order_walkthrough.rb similarity index 100% rename from spec/support/order_walkthrough.rb rename to spec/support/solidus_braintree/order_walkthrough.rb diff --git a/spec/support/vcr.rb b/spec/support/solidus_braintree/vcr.rb similarity index 100% rename from spec/support/vcr.rb rename to spec/support/solidus_braintree/vcr.rb diff --git a/spec/support/views.rb b/spec/support/solidus_braintree/views.rb similarity index 100% rename from spec/support/views.rb rename to spec/support/solidus_braintree/views.rb From 7138b2b979b7f633d74a277ffcc30b1c2148cc05 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 10:15:59 +0800 Subject: [PATCH 16/66] Namespace RSpec describe and shared_context blocks --- .../solidus_braintree/client_tokens_controller_spec.rb | 2 +- .../solidus_braintree/configurations_controller_spec.rb | 2 +- spec/models/solidus_braintree/transaction_address_spec.rb | 2 +- spec/models/solidus_braintree/transaction_import_spec.rb | 2 +- spec/models/solidus_braintree/transaction_spec.rb | 2 +- spec/models/spree/store_spec.rb | 2 +- spec/requests/spree/api/orders_controller_spec.rb | 2 +- spec/support/solidus_braintree/order_ready_for_payment.rb | 2 +- spec/system/backend/new_payment_spec.rb | 4 ++-- spec/system/frontend/braintree_credit_card_checkout_spec.rb | 4 ++-- spec/system/frontend/paypal_checkout_spec.rb | 2 +- spec/system/frontend/venmo_checkout_spec.rb | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb b/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb index 75dbf1ef..9755d427 100644 --- a/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb +++ b/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SolidusBraintree::ClientTokensController do +RSpec.describe SolidusBraintree::ClientTokensController do routes { SolidusBraintree::Engine.routes } cassette_options = { cassette_name: "braintree/token" } diff --git a/spec/controllers/solidus_braintree/configurations_controller_spec.rb b/spec/controllers/solidus_braintree/configurations_controller_spec.rb index b2c32c8e..1f7dae9a 100644 --- a/spec/controllers/solidus_braintree/configurations_controller_spec.rb +++ b/spec/controllers/solidus_braintree/configurations_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SolidusBraintree::ConfigurationsController, type: :controller do +RSpec.describe SolidusBraintree::ConfigurationsController, type: :controller do routes { SolidusBraintree::Engine.routes } let!(:store_1) { create :store } diff --git a/spec/models/solidus_braintree/transaction_address_spec.rb b/spec/models/solidus_braintree/transaction_address_spec.rb index 43c65662..0ac744d1 100644 --- a/spec/models/solidus_braintree/transaction_address_spec.rb +++ b/spec/models/solidus_braintree/transaction_address_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SolidusBraintree::TransactionAddress do +RSpec.describe SolidusBraintree::TransactionAddress do describe "#valid?" do subject { address.valid? } diff --git a/spec/models/solidus_braintree/transaction_import_spec.rb b/spec/models/solidus_braintree/transaction_import_spec.rb index 2fd707f6..73e67e38 100644 --- a/spec/models/solidus_braintree/transaction_import_spec.rb +++ b/spec/models/solidus_braintree/transaction_import_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SolidusBraintree::TransactionImport do +RSpec.describe SolidusBraintree::TransactionImport do let(:order) { Spree::Order.new } let!(:country) { create :country, iso: "US" } let(:braintree_gateway) { SolidusBraintree::Gateway.new } diff --git a/spec/models/solidus_braintree/transaction_spec.rb b/spec/models/solidus_braintree/transaction_spec.rb index 8b1f58a6..1f2472a4 100644 --- a/spec/models/solidus_braintree/transaction_spec.rb +++ b/spec/models/solidus_braintree/transaction_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SolidusBraintree::Transaction do +RSpec.describe SolidusBraintree::Transaction do describe "#valid?" do subject { transaction.valid? } diff --git a/spec/models/spree/store_spec.rb b/spec/models/spree/store_spec.rb index 89426d6b..56d7b380 100644 --- a/spec/models/spree/store_spec.rb +++ b/spec/models/spree/store_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Spree::Store do +RSpec.describe Spree::Store do describe 'before_create :build_default_configuration' do context 'when a braintree_configuration record already exists' do it 'does not overwrite it' do diff --git a/spec/requests/spree/api/orders_controller_spec.rb b/spec/requests/spree/api/orders_controller_spec.rb index 2375ed30..5d7ee08d 100644 --- a/spec/requests/spree/api/orders_controller_spec.rb +++ b/spec/requests/spree/api/orders_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Spree::Api::OrdersController, type: :request do +RSpec.describe Spree::Api::OrdersController, type: :request do stub_authorization! describe 'get show' do diff --git a/spec/support/solidus_braintree/order_ready_for_payment.rb b/spec/support/solidus_braintree/order_ready_for_payment.rb index da1e6b62..f4e2bd4d 100644 --- a/spec/support/solidus_braintree/order_ready_for_payment.rb +++ b/spec/support/solidus_braintree/order_ready_for_payment.rb @@ -1,4 +1,4 @@ -shared_context 'when order is ready for payment' do +RSpec.shared_context 'when order is ready for payment' do let!(:country) { create :country } let(:user) { create :user } diff --git a/spec/system/backend/new_payment_spec.rb b/spec/system/backend/new_payment_spec.rb index 5b608333..6ac0377d 100644 --- a/spec/system/backend/new_payment_spec.rb +++ b/spec/system/backend/new_payment_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -shared_context "with backend checkout setup" do +RSpec.shared_context "with backend checkout setup" do let(:braintree) { new_gateway(active: true) } let!(:gateway) { create :payment_method } let(:order) { create(:completed_order_with_totals, number: 'R9999999') } @@ -25,7 +25,7 @@ end end -describe 'creating a new payment', type: :feature, js: true do +RSpec.describe 'creating a new payment', type: :feature, js: true do stub_authorization! context "with valid credit card data", vcr: { diff --git a/spec/system/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb index e15db19f..107f5078 100644 --- a/spec/system/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/system/frontend/braintree_credit_card_checkout_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -shared_context "with frontend checkout setup" do +RSpec.shared_context "with frontend checkout setup" do let(:braintree) { new_gateway(active: true) } let!(:gateway) { create :payment_method } let(:three_d_secure_enabled) { false } @@ -51,7 +51,7 @@ end end -describe 'entering credit card details', type: :feature, js: true do +RSpec.describe 'entering credit card details', type: :feature, js: true do context 'when page loads' do include_context "with frontend checkout setup" diff --git a/spec/system/frontend/paypal_checkout_spec.rb b/spec/system/frontend/paypal_checkout_spec.rb index 2981055a..bcc88758 100644 --- a/spec/system/frontend/paypal_checkout_spec.rb +++ b/spec/system/frontend/paypal_checkout_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Checkout", type: :feature, js: true do +RSpec.describe "Checkout", type: :feature, js: true do Capybara.default_max_wait_time = 60 # let!(:store) do diff --git a/spec/system/frontend/venmo_checkout_spec.rb b/spec/system/frontend/venmo_checkout_spec.rb index ebf98a18..b7e47ba0 100644 --- a/spec/system/frontend/venmo_checkout_spec.rb +++ b/spec/system/frontend/venmo_checkout_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe "Checkout", type: :feature, js: true do +RSpec.describe "Checkout", type: :feature, js: true do let(:braintree_preferences) { { venmo: true }.merge(preferences) } let(:preferences) { {} } let(:user) { create(:user) } From 176855642c9053958f0b2d6650077cf00c538698 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 10:17:07 +0800 Subject: [PATCH 17/66] Replace spec helper with solidus braintree helper --- spec/controllers/solidus_braintree/checkouts_controller_spec.rb | 2 +- .../solidus_braintree/client_tokens_controller_spec.rb | 2 +- .../solidus_braintree/configurations_controller_spec.rb | 2 +- .../solidus_braintree/transactions_controller_spec.rb | 2 +- spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb | 2 +- .../helpers/solidus_braintree/braintree_checkout_helper_spec.rb | 2 +- spec/models/solidus_braintree/address_spec.rb | 2 +- spec/models/solidus_braintree/avs_result_spec.rb | 2 +- spec/models/solidus_braintree/gateway_spec.rb | 2 +- spec/models/solidus_braintree/response_spec.rb | 2 +- spec/models/solidus_braintree/source_spec.rb | 2 +- spec/models/solidus_braintree/transaction_address_spec.rb | 2 +- spec/models/solidus_braintree/transaction_import_spec.rb | 2 +- spec/models/solidus_braintree/transaction_spec.rb | 2 +- spec/models/spree/store_spec.rb | 2 +- spec/requests/spree/api/orders_controller_spec.rb | 2 +- spec/system/backend/configuration_spec.rb | 2 +- spec/system/backend/new_payment_spec.rb | 2 +- spec/system/frontend/braintree_credit_card_checkout_spec.rb | 2 +- spec/system/frontend/paypal_checkout_spec.rb | 2 +- spec/system/frontend/venmo_checkout_spec.rb | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/spec/controllers/solidus_braintree/checkouts_controller_spec.rb b/spec/controllers/solidus_braintree/checkouts_controller_spec.rb index 92153a74..fcf2382b 100644 --- a/spec/controllers/solidus_braintree/checkouts_controller_spec.rb +++ b/spec/controllers/solidus_braintree/checkouts_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' require 'support/order_ready_for_payment' RSpec.describe SolidusBraintree::CheckoutsController, type: :controller do diff --git a/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb b/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb index 9755d427..39359f17 100644 --- a/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb +++ b/spec/controllers/solidus_braintree/client_tokens_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::ClientTokensController do routes { SolidusBraintree::Engine.routes } diff --git a/spec/controllers/solidus_braintree/configurations_controller_spec.rb b/spec/controllers/solidus_braintree/configurations_controller_spec.rb index 1f7dae9a..4b24a564 100644 --- a/spec/controllers/solidus_braintree/configurations_controller_spec.rb +++ b/spec/controllers/solidus_braintree/configurations_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::ConfigurationsController, type: :controller do routes { SolidusBraintree::Engine.routes } diff --git a/spec/controllers/solidus_braintree/transactions_controller_spec.rb b/spec/controllers/solidus_braintree/transactions_controller_spec.rb index 82d94a51..5f8c1c78 100644 --- a/spec/controllers/solidus_braintree/transactions_controller_spec.rb +++ b/spec/controllers/solidus_braintree/transactions_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::TransactionsController, type: :controller do routes { SolidusBraintree::Engine.routes } diff --git a/spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb b/spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb index 37acac18..7e9ecbb7 100644 --- a/spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb +++ b/spec/helpers/solidus_braintree/braintree_admin_helper_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::BraintreeAdminHelper do describe '#braintree_transaction_link' do diff --git a/spec/helpers/solidus_braintree/braintree_checkout_helper_spec.rb b/spec/helpers/solidus_braintree/braintree_checkout_helper_spec.rb index 45c3653c..06024236 100644 --- a/spec/helpers/solidus_braintree/braintree_checkout_helper_spec.rb +++ b/spec/helpers/solidus_braintree/braintree_checkout_helper_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::BraintreeCheckoutHelper do let!(:store) { create :store } diff --git a/spec/models/solidus_braintree/address_spec.rb b/spec/models/solidus_braintree/address_spec.rb index dcf33e24..8e1c87ca 100644 --- a/spec/models/solidus_braintree/address_spec.rb +++ b/spec/models/solidus_braintree/address_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::Address do describe "::split_name" do diff --git a/spec/models/solidus_braintree/avs_result_spec.rb b/spec/models/solidus_braintree/avs_result_spec.rb index 7fc139e4..d501cf1e 100644 --- a/spec/models/solidus_braintree/avs_result_spec.rb +++ b/spec/models/solidus_braintree/avs_result_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::AVSResult do describe 'AVS response message' do diff --git a/spec/models/solidus_braintree/gateway_spec.rb b/spec/models/solidus_braintree/gateway_spec.rb index b2f2a2a4..9333e6d4 100644 --- a/spec/models/solidus_braintree/gateway_spec.rb +++ b/spec/models/solidus_braintree/gateway_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' require 'webmock' require 'support/order_ready_for_payment' diff --git a/spec/models/solidus_braintree/response_spec.rb b/spec/models/solidus_braintree/response_spec.rb index 65b078d4..3db7eb7e 100644 --- a/spec/models/solidus_braintree/response_spec.rb +++ b/spec/models/solidus_braintree/response_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::Response do let(:failed_transaction) { nil } diff --git a/spec/models/solidus_braintree/source_spec.rb b/spec/models/solidus_braintree/source_spec.rb index 4289a3fb..13d449d5 100644 --- a/spec/models/solidus_braintree/source_spec.rb +++ b/spec/models/solidus_braintree/source_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::Source, type: :model do include_context 'when order is ready for payment' diff --git a/spec/models/solidus_braintree/transaction_address_spec.rb b/spec/models/solidus_braintree/transaction_address_spec.rb index 0ac744d1..184a7697 100644 --- a/spec/models/solidus_braintree/transaction_address_spec.rb +++ b/spec/models/solidus_braintree/transaction_address_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::TransactionAddress do describe "#valid?" do diff --git a/spec/models/solidus_braintree/transaction_import_spec.rb b/spec/models/solidus_braintree/transaction_import_spec.rb index 73e67e38..cee47fb2 100644 --- a/spec/models/solidus_braintree/transaction_import_spec.rb +++ b/spec/models/solidus_braintree/transaction_import_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::TransactionImport do let(:order) { Spree::Order.new } diff --git a/spec/models/solidus_braintree/transaction_spec.rb b/spec/models/solidus_braintree/transaction_spec.rb index 1f2472a4..83eb470f 100644 --- a/spec/models/solidus_braintree/transaction_spec.rb +++ b/spec/models/solidus_braintree/transaction_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe SolidusBraintree::Transaction do describe "#valid?" do diff --git a/spec/models/spree/store_spec.rb b/spec/models/spree/store_spec.rb index 56d7b380..98250c01 100644 --- a/spec/models/spree/store_spec.rb +++ b/spec/models/spree/store_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe Spree::Store do describe 'before_create :build_default_configuration' do diff --git a/spec/requests/spree/api/orders_controller_spec.rb b/spec/requests/spree/api/orders_controller_spec.rb index 5d7ee08d..2873de4f 100644 --- a/spec/requests/spree/api/orders_controller_spec.rb +++ b/spec/requests/spree/api/orders_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe Spree::Api::OrdersController, type: :request do stub_authorization! diff --git a/spec/system/backend/configuration_spec.rb b/spec/system/backend/configuration_spec.rb index 72d52abd..d68a0bb0 100644 --- a/spec/system/backend/configuration_spec.rb +++ b/spec/system/backend/configuration_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe "viewing the configuration interface" do stub_authorization! diff --git a/spec/system/backend/new_payment_spec.rb b/spec/system/backend/new_payment_spec.rb index 6ac0377d..0f393be6 100644 --- a/spec/system/backend/new_payment_spec.rb +++ b/spec/system/backend/new_payment_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.shared_context "with backend checkout setup" do let(:braintree) { new_gateway(active: true) } diff --git a/spec/system/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb index 107f5078..774058de 100644 --- a/spec/system/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/system/frontend/braintree_credit_card_checkout_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.shared_context "with frontend checkout setup" do let(:braintree) { new_gateway(active: true) } diff --git a/spec/system/frontend/paypal_checkout_spec.rb b/spec/system/frontend/paypal_checkout_spec.rb index bcc88758..49673dcd 100644 --- a/spec/system/frontend/paypal_checkout_spec.rb +++ b/spec/system/frontend/paypal_checkout_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe "Checkout", type: :feature, js: true do Capybara.default_max_wait_time = 60 diff --git a/spec/system/frontend/venmo_checkout_spec.rb b/spec/system/frontend/venmo_checkout_spec.rb index b7e47ba0..b856ff2c 100644 --- a/spec/system/frontend/venmo_checkout_spec.rb +++ b/spec/system/frontend/venmo_checkout_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'spec_helper' +require 'solidus_braintree_helper' RSpec.describe "Checkout", type: :feature, js: true do let(:braintree_preferences) { { venmo: true }.merge(preferences) } From 777205299a67a1b35d6de0fcd9cf05d4c666f540 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 10:40:52 +0800 Subject: [PATCH 18/66] Install vcr and webmock as test gems Needed to change generator to an AppBase generator so that we can call the `bundle_command` method. https://github.com/solidusio/solidus_braintree/pull/102#discussion_r1106927621 --- .../install/install_generator.rb | 23 ++++++++++++++++++- solidus_braintree.gemspec | 2 -- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 6719dec7..8ff33dfd 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -1,8 +1,12 @@ # frozen_string_literal: true +require 'rails/generators/app_base' + module SolidusBraintree module Generators - class InstallGenerator < Rails::Generators::Base + class InstallGenerator < Rails::Generators::AppBase + argument :app_path, type: :string, default: Rails.root + class_option :migrate, type: :boolean, default: false source_root File.expand_path('templates', __dir__) @@ -10,6 +14,16 @@ class InstallGenerator < Rails::Generators::Base # installed specs to frontend, which are the ones related to code copied to the target application. class_option :specs, type: :string, enum: %w[all frontend], default: 'frontend', hide: true + def add_test_gems + gem_group :test do + ['vcr', 'webmock'].each do |gem_name| + gem gem_name unless Bundler.locked_gems.dependencies[gem_name] + end + end + + bundle_command 'install' + end + def setup_initializer legacy_initializer_pathname = Pathname.new(destination_root).join('config/initializers/solidus_paypal_braintree.rb') @@ -106,6 +120,13 @@ def install_specs def engine SolidusBraintree::Engine end + + def bundle_command(command, env = {}) + # Make `bundle install` less verbose by skipping the "Using ..." messages + super(command, env.reverse_merge('BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES' => 'true')) + ensure + Bundler.reset_paths! + end end end end diff --git a/solidus_braintree.gemspec b/solidus_braintree.gemspec index d245a2f7..9f00591e 100644 --- a/solidus_braintree.gemspec +++ b/solidus_braintree.gemspec @@ -37,8 +37,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails-controller-testing' spec.add_development_dependency 'solidus_dev_support', '~> 2.5' - spec.add_development_dependency 'vcr' - spec.add_development_dependency 'webmock' spec.post_install_message = "If you're upgrading to v2.0.0, please see the README for upgrade instructions." end From 9a394984ba45bd8b98cbf055581179a328e65059 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 10:46:08 +0800 Subject: [PATCH 19/66] Fix path to order_ready_for_payment --- spec/controllers/solidus_braintree/checkouts_controller_spec.rb | 2 +- spec/models/solidus_braintree/gateway_spec.rb | 2 +- spec/models/solidus_braintree/source_spec.rb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/controllers/solidus_braintree/checkouts_controller_spec.rb b/spec/controllers/solidus_braintree/checkouts_controller_spec.rb index fcf2382b..3cbe0d1d 100644 --- a/spec/controllers/solidus_braintree/checkouts_controller_spec.rb +++ b/spec/controllers/solidus_braintree/checkouts_controller_spec.rb @@ -1,5 +1,5 @@ require 'solidus_braintree_helper' -require 'support/order_ready_for_payment' +require 'support/solidus_braintree/order_ready_for_payment' RSpec.describe SolidusBraintree::CheckoutsController, type: :controller do routes { SolidusBraintree::Engine.routes } diff --git a/spec/models/solidus_braintree/gateway_spec.rb b/spec/models/solidus_braintree/gateway_spec.rb index 9333e6d4..f72eaf53 100644 --- a/spec/models/solidus_braintree/gateway_spec.rb +++ b/spec/models/solidus_braintree/gateway_spec.rb @@ -1,6 +1,6 @@ require 'solidus_braintree_helper' require 'webmock' -require 'support/order_ready_for_payment' +require 'support/solidus_braintree/order_ready_for_payment' RSpec.describe SolidusBraintree::Gateway do let(:gateway) do diff --git a/spec/models/solidus_braintree/source_spec.rb b/spec/models/solidus_braintree/source_spec.rb index 13d449d5..093bcdae 100644 --- a/spec/models/solidus_braintree/source_spec.rb +++ b/spec/models/solidus_braintree/source_spec.rb @@ -1,4 +1,5 @@ require 'solidus_braintree_helper' +require 'support/solidus_braintree/order_ready_for_payment' RSpec.describe SolidusBraintree::Source, type: :model do include_context 'when order is ready for payment' From 70fd14bf40ce96e5fb2f5534692da2e48319be68 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 10:51:02 +0800 Subject: [PATCH 20/66] Update superclasses of SolidusBraintree controllers --- .../frontend/solidus_braintree/checkouts_controller.rb | 2 +- .../frontend/solidus_braintree/transactions_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/controllers/frontend/solidus_braintree/checkouts_controller.rb b/lib/controllers/frontend/solidus_braintree/checkouts_controller.rb index 663587af..ac292f9b 100644 --- a/lib/controllers/frontend/solidus_braintree/checkouts_controller.rb +++ b/lib/controllers/frontend/solidus_braintree/checkouts_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module SolidusBraintree - class CheckoutsController < ::Spree::CheckoutController + class CheckoutsController < CheckoutsController PERMITTED_PAYMENT_PARAMS = [ :payment_method_id, { source_attributes: [ diff --git a/lib/controllers/frontend/solidus_braintree/transactions_controller.rb b/lib/controllers/frontend/solidus_braintree/transactions_controller.rb index 06204173..5303ba46 100644 --- a/lib/controllers/frontend/solidus_braintree/transactions_controller.rb +++ b/lib/controllers/frontend/solidus_braintree/transactions_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module SolidusBraintree - class TransactionsController < ::Spree::StoreController + class TransactionsController < StoreController class InvalidImportError < StandardError; end PERMITTED_BRAINTREE_TRANSACTION_PARAMS = [ From c3ddaa6c05d936370eac67d44b612c22560cdd9e Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 11:22:44 +0800 Subject: [PATCH 21/66] Move factories to spec/support --- spec/solidus_braintree_helper.rb | 1 + .../support/solidus_braintree}/factories.rb | 0 2 files changed, 1 insertion(+) rename {lib/solidus_braintree/testing_support => spec/support/solidus_braintree}/factories.rb (100%) diff --git a/spec/solidus_braintree_helper.rb b/spec/solidus_braintree_helper.rb index f40ed49c..86234c83 100644 --- a/spec/solidus_braintree_helper.rb +++ b/spec/solidus_braintree_helper.rb @@ -1,6 +1,7 @@ require 'solidus_starter_frontend_helper' require 'support/solidus_braintree/capybara' +require 'support/solidus_braintree/factories' require 'support/solidus_braintree/gateway_helpers' require 'support/solidus_braintree/order_walkthrough' require 'support/solidus_braintree/vcr' diff --git a/lib/solidus_braintree/testing_support/factories.rb b/spec/support/solidus_braintree/factories.rb similarity index 100% rename from lib/solidus_braintree/testing_support/factories.rb rename to spec/support/solidus_braintree/factories.rb From bfcc1499d0c194f36225bd4e0bf6605f2c1250e4 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 8 Feb 2023 11:43:07 +0800 Subject: [PATCH 22/66] Remove spree namespace from frontend paths --- .../frontend/solidus_braintree/transactions_controller.rb | 4 ++-- .../solidus_braintree/transactions_controller_spec.rb | 4 ++-- spec/system/frontend/braintree_credit_card_checkout_spec.rb | 2 +- spec/system/frontend/paypal_checkout_spec.rb | 2 +- spec/system/frontend/venmo_checkout_spec.rb | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/controllers/frontend/solidus_braintree/transactions_controller.rb b/lib/controllers/frontend/solidus_braintree/transactions_controller.rb index 5303ba46..c9c4d139 100644 --- a/lib/controllers/frontend/solidus_braintree/transactions_controller.rb +++ b/lib/controllers/frontend/solidus_braintree/transactions_controller.rb @@ -48,9 +48,9 @@ def import_error(import) def redirect_url(import) if import.order.complete? - spree.order_url(import.order) + main_app.order_url(import.order) else - spree.checkout_state_url(import.order.state) + main_app.checkout_state_url(import.order.state) end end diff --git a/spec/controllers/solidus_braintree/transactions_controller_spec.rb b/spec/controllers/solidus_braintree/transactions_controller_spec.rb index 5f8c1c78..98d7520d 100644 --- a/spec/controllers/solidus_braintree/transactions_controller_spec.rb +++ b/spec/controllers/solidus_braintree/transactions_controller_spec.rb @@ -130,7 +130,7 @@ context "when format is HTML" do context "when import! leaves the order in confirm" do it "redirects the user to the confirm page" do - expect(post_create).to redirect_to spree.checkout_state_path("confirm") + expect(post_create).to redirect_to checkout_state_path("confirm") end end @@ -138,7 +138,7 @@ before { allow(order).to receive(:complete?).and_return(true) } it "displays the order to the user" do - expect(post_create).to redirect_to spree.order_path(order) + expect(post_create).to redirect_to order_path(order) end end end diff --git a/spec/system/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb index 774058de..3ac37a32 100644 --- a/spec/system/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/system/frontend/braintree_credit_card_checkout_spec.rb @@ -41,7 +41,7 @@ allow_any_instance_of(Spree::Payment).to receive(:number).and_return("123ABC") allow_any_instance_of(SolidusBraintree::Source).to receive(:nonce).and_return("fake-valid-nonce") - visit spree.checkout_state_path(:delivery) + visit checkout_state_path(:delivery) click_button "Save and Continue" choose("Braintree") end diff --git a/spec/system/frontend/paypal_checkout_spec.rb b/spec/system/frontend/paypal_checkout_spec.rb index 49673dcd..1dbea802 100644 --- a/spec/system/frontend/paypal_checkout_spec.rb +++ b/spec/system/frontend/paypal_checkout_spec.rb @@ -149,7 +149,7 @@ def fill_in_address end def add_mug_to_cart - visit spree.root_path + visit root_path click_link mug.name click_button "add-to-cart-button" end diff --git a/spec/system/frontend/venmo_checkout_spec.rb b/spec/system/frontend/venmo_checkout_spec.rb index b856ff2c..1f43d60e 100644 --- a/spec/system/frontend/venmo_checkout_spec.rb +++ b/spec/system/frontend/venmo_checkout_spec.rb @@ -148,7 +148,7 @@ def go_to_payment_checkout_page(order_number: 'R300000001' ) allow_any_instance_of(Spree::Payment).to receive(:gateway_order_id).and_return(order_number) - visit spree.checkout_state_path(order.state) + visit checkout_state_path(order.state) next_checkout_step end From 1a1e6f92c9cee6f6907c44656152521061a1006c Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Feb 2023 10:28:07 +0800 Subject: [PATCH 23/66] Change Spree::CheckoutController to CheckoutsController --- .../solidus_braintree/checkout_controller_decorator.rb | 2 +- spec/system/frontend/braintree_credit_card_checkout_spec.rb | 6 +++--- spec/system/frontend/venmo_checkout_spec.rb | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb b/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb index 61a56032..3886d776 100644 --- a/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb +++ b/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb @@ -6,6 +6,6 @@ def self.prepended(base) base.helper ::SolidusBraintree::BraintreeCheckoutHelper end - ::Spree::CheckoutController.prepend(self) if SolidusSupport.frontend_available? + ::CheckoutsController.prepend(self) if SolidusSupport.frontend_available? end end diff --git a/spec/system/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb index 3ac37a32..4ddcf20e 100644 --- a/spec/system/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/system/frontend/braintree_credit_card_checkout_spec.rb @@ -35,9 +35,9 @@ order.number = "R9999999" order.recalculate - allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order) - allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user) - allow_any_instance_of(Spree::CheckoutController).to receive_messages(spree_current_user: user) + allow_any_instance_of(CheckoutsController).to receive_messages(current_order: order) + allow_any_instance_of(CheckoutsController).to receive_messages(try_spree_current_user: user) + allow_any_instance_of(CheckoutsController).to receive_messages(spree_current_user: user) allow_any_instance_of(Spree::Payment).to receive(:number).and_return("123ABC") allow_any_instance_of(SolidusBraintree::Source).to receive(:nonce).and_return("fake-valid-nonce") diff --git a/spec/system/frontend/venmo_checkout_spec.rb b/spec/system/frontend/venmo_checkout_spec.rb index 1f43d60e..c200e847 100644 --- a/spec/system/frontend/venmo_checkout_spec.rb +++ b/spec/system/frontend/venmo_checkout_spec.rb @@ -140,11 +140,11 @@ def go_to_payment_checkout_page(order_number: 'R300000001' ) order.update!(user: user, number: order_number) # constant order number for VCRs - allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order) + allow_any_instance_of(CheckoutsController).to receive_messages(current_order: order) first_user = Spree::User.first - allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: first_user) - allow_any_instance_of(Spree::CheckoutController).to receive_messages(spree_current_user: first_user) + allow_any_instance_of(CheckoutsController).to receive_messages(try_spree_current_user: first_user) + allow_any_instance_of(CheckoutsController).to receive_messages(spree_current_user: first_user) allow_any_instance_of(Spree::Payment).to receive(:gateway_order_id).and_return(order_number) From d071a81036ba3781b547e8be354e29fcc13f2117 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Feb 2023 10:29:38 +0800 Subject: [PATCH 24/66] Remove Solidus.frontend_available? checks No longer applicable since we're changing the extension to be installable only to SolidusStarterFrontend. --- .../checkout_controller_decorator.rb | 2 +- .../orders_controller_decorator.rb | 2 +- lib/solidus_braintree/engine.rb | 18 ++++++++---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb b/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb index 3886d776..0eba46ea 100644 --- a/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb +++ b/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb @@ -6,6 +6,6 @@ def self.prepended(base) base.helper ::SolidusBraintree::BraintreeCheckoutHelper end - ::CheckoutsController.prepend(self) if SolidusSupport.frontend_available? + ::CheckoutsController.prepend(self) end end diff --git a/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb b/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb index e0bb863c..79ceed6a 100644 --- a/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb +++ b/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb @@ -6,6 +6,6 @@ def self.prepended(base) base.helper ::SolidusBraintree::BraintreeCheckoutHelper end - ::Spree::OrdersController.prepend(self) if SolidusSupport.frontend_available? + ::Spree::OrdersController.prepend(self) end end diff --git a/lib/solidus_braintree/engine.rb b/lib/solidus_braintree/engine.rb index cf21ce44..a58cc87e 100644 --- a/lib/solidus_braintree/engine.rb +++ b/lib/solidus_braintree/engine.rb @@ -22,16 +22,14 @@ class Engine < Rails::Engine end end - if SolidusSupport.frontend_available? - config.assets.precompile += [ - 'spree/frontend/solidus_braintree/checkout.js', - 'solidus_braintree/frontend.js', - 'spree/frontend/apple_pay_button.js', - 'solidus_braintree_manifest.js' - ] - paths["app/controllers"] << "lib/controllers/frontend" - paths["app/views"] << "lib/views/frontend" - end + config.assets.precompile += [ + 'spree/frontend/solidus_braintree/checkout.js', + 'solidus_braintree/frontend.js', + 'spree/frontend/apple_pay_button.js', + 'solidus_braintree_manifest.js' + ] + paths["app/controllers"] << "lib/controllers/frontend" + paths["app/views"] << "lib/views/frontend" if SolidusSupport.backend_available? config.assets.precompile += ["spree/backend/solidus_braintree.js"] From d2c7fd5ba98093a0bbe1be0d9494f2fdb7fd5611 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Feb 2023 10:31:32 +0800 Subject: [PATCH 25/66] Change Spree::OrdersController to OrdersController --- .../solidus_braintree/orders_controller_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb b/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb index 79ceed6a..de75d27b 100644 --- a/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb +++ b/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb @@ -6,6 +6,6 @@ def self.prepended(base) base.helper ::SolidusBraintree::BraintreeCheckoutHelper end - ::Spree::OrdersController.prepend(self) + OrdersController.prepend(self) end end From 2a6227dc6278e6b4c9e4fa4d8eb086a9bc754823 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Feb 2023 10:40:12 +0800 Subject: [PATCH 26/66] Update "Place Order" calls in spec --- .../braintree_credit_card_checkout_spec.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/spec/system/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb index 4ddcf20e..fc430753 100644 --- a/spec/system/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/system/frontend/braintree_credit_card_checkout_spec.rb @@ -97,9 +97,12 @@ end it "checks out successfully" do - within("#order_details") do + within(".confirm-step") do expect(page).to have_content("CONFIRM") end + + check('accept_terms_and_conditions') + click_button("Place Order") expect(page).to have_content("Your order has been processed successfully") end @@ -110,10 +113,12 @@ it 'checks out successfully' do authenticate_3ds - within("#order_details") do + within(".confirm-step") do expect(page).to have_content("CONFIRM") end + check('accept_terms_and_conditions') + click_button("Place Order") expect(page).to have_content("Your order has been processed successfully") end @@ -170,9 +175,13 @@ fill_in("cvv", with: "123") end click_button("Save and Continue") - within("#order_details") do + + within(".confirm-step") do expect(page).to have_content("CONFIRM") end + + check('accept_terms_and_conditions') + click_button("Place Order") expect(page).to have_content("Your order has been processed successfully") end From c488c757d81f712e9c65c7df1cbe133d3957e31d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Feb 2023 10:41:15 +0800 Subject: [PATCH 27/66] Loosen selectors for Checkout submit element --- spec/system/frontend/braintree_credit_card_checkout_spec.rb | 4 ++-- spec/system/frontend/venmo_checkout_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/system/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb index fc430753..8c701cab 100644 --- a/spec/system/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/system/frontend/braintree_credit_card_checkout_spec.rb @@ -146,13 +146,13 @@ it "displays an alert with a meaningful error message" do expect(page).to have_text I18n.t("solidus_braintree.errors.empty_fields") - expect(page).to have_selector("input[type='submit']:enabled") + expect(page).to have_selector("[type='submit']:enabled") end # Same error should be produced when submitting an empty form again context "when user tries to resubmit an empty form", vcr: { cassette_name: "checkout/invalid_credit_card" } do it "displays an alert with a meaningful error message" do - expect(page).to have_selector("input[type='submit']:enabled") + expect(page).to have_selector("[type='submit']:enabled") click_button "Save and Continue" expect(page).to have_text I18n.t("solidus_braintree.errors.empty_fields") diff --git a/spec/system/frontend/venmo_checkout_spec.rb b/spec/system/frontend/venmo_checkout_spec.rb index c200e847..51efad1f 100644 --- a/spec/system/frontend/venmo_checkout_spec.rb +++ b/spec/system/frontend/venmo_checkout_spec.rb @@ -187,7 +187,7 @@ def disable_hosted_fields_inputs def disable_hosted_fields_form_listener # Once the submit button is enabled, the submit listener has been added - find("#checkout_form_payment input[type='submit']:not(:disabled)") + find("#checkout_form_payment [type='submit']:not(:disabled)") page.execute_script("$('#checkout_form_payment').off('submit');") end end From e131a475c3ad9fbda0073e49e48dd4e0bad4cd49 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Feb 2023 10:47:46 +0800 Subject: [PATCH 28/66] Show Braintree errors before main container --- .../javascripts/spree/frontend/solidus_braintree/constants.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js b/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js index eedb9ca0..0ebdb3ac 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js @@ -41,9 +41,9 @@ SolidusBraintree = { }, showError: function(error) { - var $contentContainer = $("#content"); + var $contentContainer = $("main"); var $flash = $("
" + error + "
"); - $contentContainer.prepend($flash); + $contentContainer.before($flash); $flash.show().delay(5000).fadeOut(500); }, From 256a468640f5121eac64661124ef37eed15b1f53 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 13 Feb 2023 09:38:32 +0800 Subject: [PATCH 29/66] Fix transactions controller spec --- .../solidus_braintree/transactions_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/solidus_braintree/transactions_controller_spec.rb b/spec/controllers/solidus_braintree/transactions_controller_spec.rb index 98d7520d..5f6f00e4 100644 --- a/spec/controllers/solidus_braintree/transactions_controller_spec.rb +++ b/spec/controllers/solidus_braintree/transactions_controller_spec.rb @@ -130,7 +130,7 @@ context "when format is HTML" do context "when import! leaves the order in confirm" do it "redirects the user to the confirm page" do - expect(post_create).to redirect_to checkout_state_path("confirm") + expect(post_create).to redirect_to '/checkout/confirm' end end @@ -138,7 +138,7 @@ before { allow(order).to receive(:complete?).and_return(true) } it "displays the order to the user" do - expect(post_create).to redirect_to order_path(order) + expect(post_create).to redirect_to "/orders/#{order.number}" end end end From 5ae7ffae32cb9269c397bda1b663df09cef6415d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Feb 2023 11:31:52 +0800 Subject: [PATCH 30/66] [SPECS FIXED] Fix: display PayPal button in cart page * Change OrdersControllerDecorator to CartsControllerDecorator. * Introduce "with prepended view fixtures" shared context. * Change PayPal checkout spec fixture to cart footer. --- ...rator.rb => carts_controller_decorator.rb} | 4 +- .../views/carts/_cart_footer.html.erb | 18 +++++++ .../fixtures/views/spree/orders/edit.html.erb | 50 ------------------- spec/support/solidus_braintree/views.rb | 1 - .../with_prepended_view_fixtures.rb | 19 +++++++ spec/system/frontend/paypal_checkout_spec.rb | 3 ++ 6 files changed, 42 insertions(+), 53 deletions(-) rename app/decorators/controllers/solidus_braintree/{orders_controller_decorator.rb => carts_controller_decorator.rb} (70%) create mode 100644 spec/fixtures/views/carts/_cart_footer.html.erb delete mode 100644 spec/fixtures/views/spree/orders/edit.html.erb delete mode 100644 spec/support/solidus_braintree/views.rb create mode 100644 spec/support/solidus_braintree/with_prepended_view_fixtures.rb diff --git a/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb b/app/decorators/controllers/solidus_braintree/carts_controller_decorator.rb similarity index 70% rename from app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb rename to app/decorators/controllers/solidus_braintree/carts_controller_decorator.rb index de75d27b..f3e2e78d 100644 --- a/app/decorators/controllers/solidus_braintree/orders_controller_decorator.rb +++ b/app/decorators/controllers/solidus_braintree/carts_controller_decorator.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true module SolidusBraintree - module OrdersControllerDecorator + module CartsControllerDecorator def self.prepended(base) base.helper ::SolidusBraintree::BraintreeCheckoutHelper end - OrdersController.prepend(self) + CartsController.prepend(self) end end diff --git a/spec/fixtures/views/carts/_cart_footer.html.erb b/spec/fixtures/views/carts/_cart_footer.html.erb new file mode 100644 index 00000000..8a68bf30 --- /dev/null +++ b/spec/fixtures/views/carts/_cart_footer.html.erb @@ -0,0 +1,18 @@ +<% order = order_form.object %> + +
+ + + + + <%= render "spree/shared/paypal_cart_button" %> +
diff --git a/spec/fixtures/views/spree/orders/edit.html.erb b/spec/fixtures/views/spree/orders/edit.html.erb deleted file mode 100644 index 3e21e636..00000000 --- a/spec/fixtures/views/spree/orders/edit.html.erb +++ /dev/null @@ -1,50 +0,0 @@ - - -<% @body_id = 'cart' %> -
-

<%= t('spree.shopping_cart') %>

- - <% if @order.line_items.empty? %> - -
-

<%= t('spree.your_cart_is_empty') %>

-

<%= link_to t('spree.continue_shopping'), products_path, class: 'button continue' %>

-
- - <% else %> - -
- <%= form_for @order, url: update_cart_path, html: {id: 'update-cart'} do |order_form| %> -
- -
- <%= render 'form', order_form: order_form %> -
- - - -
- <% end %> -
- -
- <%= form_tag empty_cart_path, method: :put do %> - - <% end %> -
- - <%= render "spree/shared/paypal_cart_button" %> - <% end %> -
diff --git a/spec/support/solidus_braintree/views.rb b/spec/support/solidus_braintree/views.rb deleted file mode 100644 index f3bdc558..00000000 --- a/spec/support/solidus_braintree/views.rb +++ /dev/null @@ -1 +0,0 @@ -ApplicationController.prepend_view_path "spec/fixtures/views" diff --git a/spec/support/solidus_braintree/with_prepended_view_fixtures.rb b/spec/support/solidus_braintree/with_prepended_view_fixtures.rb new file mode 100644 index 00000000..727d9079 --- /dev/null +++ b/spec/support/solidus_braintree/with_prepended_view_fixtures.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +RSpec.shared_context 'with prepended view fixtures' do + let(:view_fixtures_path) { 'spec/fixtures/views' } + + before do + ApplicationController.prepend_view_path view_fixtures_path + end + + after do + view_paths = ApplicationController.view_paths.to_a + + view_paths.delete_if do |view_path| + view_path.to_path.match?(/#{view_fixtures_path}$/) + end + + ApplicationController.view_paths = view_paths + end +end diff --git a/spec/system/frontend/paypal_checkout_spec.rb b/spec/system/frontend/paypal_checkout_spec.rb index 1dbea802..60cf09d5 100644 --- a/spec/system/frontend/paypal_checkout_spec.rb +++ b/spec/system/frontend/paypal_checkout_spec.rb @@ -1,6 +1,9 @@ require 'solidus_braintree_helper' +require 'support/solidus_braintree/with_prepended_view_fixtures' RSpec.describe "Checkout", type: :feature, js: true do + include_context 'with prepended view fixtures' + Capybara.default_max_wait_time = 60 # let!(:store) do From e2eecb93734d36b0756837ce680caf024f5de533 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 13 Feb 2023 10:21:11 +0800 Subject: [PATCH 31/66] Copy CircleCI config from SolidusPaypalCommercePlatform Copied from https://github.com/solidusio/solidus_paypal_commerce_platform/blob/a6f87f5d6a1621eda453db31ccdc8c3903ef48c4/.circleci/config.yml. --- .circleci/config.yml | 47 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 98a5c19b..b58334d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,6 @@ version: 2.1 orbs: - # Required for feature specs. browser-tools: circleci/browser-tools@1.1 # Always take the latest version of the orb, this allows us to @@ -10,21 +9,51 @@ orbs: # or goes EOL. solidusio_extensions: solidusio/extensions@volatile +commands: + test-with-starter-frontend: + steps: + - checkout + - browser-tools/install-chrome + - run: + name: Install libvips + command: | + sudo apt-get update + sudo apt-get install -yq libvips-dev + - solidusio_extensions/test-branch: + branch: master + command: | + export FRONTEND=starter + sudo gem update --system + gem install bundler rails + bin/dummy-app + bin/rspec + - solidusio_extensions/store-test-results + jobs: run-specs-with-postgres: - executor: solidusio_extensions/postgres + executor: + name: solidusio_extensions/postgres + ruby_version: '3.1' steps: - - browser-tools/install-browser-tools - - solidusio_extensions/run-tests + - test-with-starter-frontend + run-specs-with-mysql: - executor: solidusio_extensions/mysql + executor: + name: solidusio_extensions/mysql + ruby_version: '3.0' steps: - - browser-tools/install-browser-tools - - solidusio_extensions/run-tests + - test-with-starter-frontend + + run-specs-with-sqlite: + executor: + name: solidusio_extensions/sqlite + ruby_version: '2.7' + steps: + - test-with-starter-frontend + lint-code: executor: solidusio_extensions/sqlite-memory steps: - - browser-tools/install-browser-tools - solidusio_extensions/lint-code workflows: @@ -32,6 +61,7 @@ workflows: jobs: - run-specs-with-postgres - run-specs-with-mysql + - run-specs-with-sqlite - lint-code "Weekly run specs against master": @@ -45,3 +75,4 @@ workflows: jobs: - run-specs-with-postgres - run-specs-with-mysql + - run-specs-with-sqlite From 097ef642135d776e1118bef2ffeb1eb680d1847d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 09:55:21 +0800 Subject: [PATCH 32/66] Update required Ruby version to 2.7 --- .rubocop.yml | 1 + solidus_braintree.gemspec | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index b7be3896..e1e8029e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,6 +3,7 @@ require: AllCops: NewCops: disable + TargetRubyVersion: '2.7' Layout/FirstArgumentIndentation: EnforcedStyle: consistent diff --git a/solidus_braintree.gemspec b/solidus_braintree.gemspec index 9f00591e..5309a406 100644 --- a/solidus_braintree.gemspec +++ b/solidus_braintree.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_braintree' spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_braintree/blob/master/CHANGELOG.md' - spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 4') + spec.required_ruby_version = Gem::Requirement.new('>= 2.7', '< 4') # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. From c58a1c9c0541f0dc46b06cefb0f939f3d0d86d1d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 09:57:29 +0800 Subject: [PATCH 33/66] Wrap zipcode documentation --- spec/support/solidus_braintree/factories.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/support/solidus_braintree/factories.rb b/spec/support/solidus_braintree/factories.rb index 341cae6a..23993cf7 100644 --- a/spec/support/solidus_braintree/factories.rb +++ b/spec/support/solidus_braintree/factories.rb @@ -31,12 +31,12 @@ factory :solidus_braintree_address, parent: :address do trait :with_fixed_zipcode do - # The Solidus address factory randomizes the zipcode. - # The OrderWalkThrough we use in the credit card checkout spec uses this factory for the user addresses. - # For credit card payments we transmit the billing address to braintree, for paypal payments the shipping address. - # As we match the body in our VCR settings VCR can not match the request anymore and therefore cannot replay existing - # cassettes. - # + # The Solidus address factory randomizes the zipcode. The OrderWalkThrough + # we use in the credit card checkout spec uses this factory for the user + # addresses. For credit card payments we transmit the billing address to + # braintree, for paypal payments the shipping address. As we match the + # body in our VCR settings VCR can not match the request anymore and + # therefore cannot replay existing cassettes. zipcode { '21088-0255' } end From cfd5c6752b3d81b1ec16aaaedef3f3ae28a9dd06 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 09:59:19 +0800 Subject: [PATCH 34/66] Update specs excluded from MultipleMemoizedHelpers Postponing since we want to minimize the changes in this branch. --- .rubocop.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index e1e8029e..4b59cda6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -73,7 +73,8 @@ RSpec/MultipleMemoizedHelpers: - spec/models/solidus_braintree/response_spec.rb - spec/models/solidus_braintree/gateway_spec.rb - spec/controllers/solidus_braintree/client_tokens_controller_spec.rb - - spec/features/frontend/braintree_credit_card_checkout_spec.rb + - spec/system/frontend/braintree_credit_card_checkout_spec.rb + - spec/system/frontend/paypal_checkout_spec.rb Rails/ApplicationRecord: Exclude: From b9937b2e02362ce765c5d0d4b1557f96a37c8567 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 10:18:11 +0800 Subject: [PATCH 35/66] Declare excluded directories from RuboCop Copied from https://github.com/solidusio/solidus_paypal_commerce_platform/blob/a6f87f5d6a1621eda453db31ccdc8c3903ef48c4/.rubocop.yml. --- .rubocop.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 4b59cda6..8bc80d2e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,11 @@ require: AllCops: NewCops: disable TargetRubyVersion: '2.7' + Exclude: + - sandbox/**/* + - dummy-app/**/* + - spec/dummy/**/* + - vendor/bundle/**/* Layout/FirstArgumentIndentation: EnforcedStyle: consistent From 675c2739c10d3a6bc96e3b54683f456b1cfcbb4d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 10:48:50 +0800 Subject: [PATCH 36/66] [Passes RuboCop] Specify backend spec as feature spec --- spec/system/backend/configuration_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/backend/configuration_spec.rb b/spec/system/backend/configuration_spec.rb index d68a0bb0..2f461ab9 100644 --- a/spec/system/backend/configuration_spec.rb +++ b/spec/system/backend/configuration_spec.rb @@ -1,6 +1,6 @@ require 'solidus_braintree_helper' -RSpec.describe "viewing the configuration interface" do +RSpec.describe "viewing the configuration interface", type: :feature do stub_authorization! # Regression to ensure this page still renders on old versions of solidus From e5b8cd75ccb65d527312fd3fc12fd60154f897de Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 11:05:14 +0800 Subject: [PATCH 37/66] Copy sandbox script from SolidusPaypalCommercePlatform Copied from https://github.com/solidusio/solidus_paypal_commerce_platform/blob/a6f87f5d6a1621eda453db31ccdc8c3903ef48c4/bin/sandbox --- bin/sandbox | 82 +++++++++++++---------------------------------------- 1 file changed, 20 insertions(+), 62 deletions(-) diff --git a/bin/sandbox b/bin/sandbox index 222af4fe..037d7836 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -1,10 +1,6 @@ #!/usr/bin/env bash set -e -if [ -n "$DEBUG" ] -then - set -x -fi case "$DB" in postgres|postgresql) @@ -13,51 +9,37 @@ postgres|postgresql) mysql) RAILSDB="mysql" ;; -sqlite3|sqlite) - RAILSDB="sqlite3" - ;; -'') - echo "~~> Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter" +sqlite|'') RAILSDB="sqlite3" ;; *) - echo "Invalid value specified for the Solidus sandbox: DB=\"$DB\"." - echo "Please use 'postgres', 'mysql', or 'sqlite' instead." + echo "Invalid DB specified: $DB" exit 1 ;; esac -echo "~~> Using $RAILSDB as the database engine" - -if [ -z "$SOLIDUS_BRANCH" ] -then - echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch" - SOLIDUS_BRANCH="master" -fi -echo "~~> Using branch $SOLIDUS_BRANCH of solidus" -if [ -z "$SOLIDUS_FRONTEND" ] +if [ ! -z $SOLIDUS_BRANCH ] then - echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend" - SOLIDUS_FRONTEND="solidus_frontend" + BRANCH=$SOLIDUS_BRANCH +else + BRANCH="master" fi -echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend" extension_name="solidus_braintree" # Stay away from the bundler env of the containing extension. function unbundled { - ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@ + ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@" } rm -rf ./sandbox -unbundled bundle exec rails new sandbox --database="$RAILSDB" \ - --skip-bundle \ +rails new sandbox \ + --database="$RAILSDB" \ --skip-git \ --skip-keeps \ --skip-rc \ - --skip-spring \ - --skip-test \ - --skip-javascript + --skip-bootsnap \ + --skip-test if [ ! -d "sandbox" ]; then echo 'sandbox rails application failed' @@ -65,39 +47,15 @@ if [ ! -d "sandbox" ]; then fi cd ./sandbox -cat <> Gemfile -gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH' -gem 'rails-i18n' -gem 'solidus_i18n' - -# This Braintree extension contains a user decorator, so the user class must be loaded first. -gem "solidus_auth_devise", "~> 2.5" -gem '$extension_name', path: '..' - -group :test, :development do - platforms :mri do - gem 'pry-byebug' - end -end -RUBY - -unbundled bundle install --gemfile Gemfile - +unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a' unbundled bundle exec rake db:drop db:create - -# Still request "devise". Solidus will skip installing it again but will include its seeds. -unbundled bundle exec rails generate solidus:install \ - --auto-accept \ - --user_class=Spree::User \ - --enforce_available_locales=true \ - --authentication="devise" \ - --payment-method=none \ - --frontend=${SOLIDUS_FRONTEND} \ - $@ - -unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations -unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations +unbundled bundle exec rails generate solidus:install --payment-method=none --auto-accept "$@" +unbundled bundle add ${extension_name} --path '../' +unbundled bundle exec rails generate ${extension_name}:install --frontend=starter --migrate=true echo -echo "🚀 Sandbox app successfully created for $extension_name!" -echo "🧪 This app is intended for test purposes." +echo "🚀 Sandbox app successfully created for ${extension_name}!" +echo "🚀 Using $RAILSDB and Solidus $BRANCH" +echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter" +echo "🚀 Use 'export SOLIDUS_BRANCH=' to control the Solidus version" +echo "🚀 This app is intended for test purposes." From 827ace2e87be75c2f08bf1cda128ac3116f40f43 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Tue, 21 Feb 2023 16:28:50 +0800 Subject: [PATCH 38/66] Remove CVV link https://github.com/solidusio/solidus_braintree/pull/102#discussion_r1111663039 --- app/views/spree/shared/_braintree_hosted_fields.html.erb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/spree/shared/_braintree_hosted_fields.html.erb b/app/views/spree/shared/_braintree_hosted_fields.html.erb index 78058086..8640b0f7 100644 --- a/app/views/spree/shared/_braintree_hosted_fields.html.erb +++ b/app/views/spree/shared/_braintree_hosted_fields.html.erb @@ -22,10 +22,6 @@
<%= label_tag "card_code#{payment_method.id}", Spree::CreditCard.human_attribute_name(:card_code), class: "required" %>
- - - (<%= I18n.t("spree.what_is_this") %>) -
From 1c4ccb78824ef19579cfb9728fea6fafdc33e0b9 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 13:02:35 +0800 Subject: [PATCH 39/66] Remove unnecessary paths from engine's precompile list * apple_pay_button.js is already required by frontend.js * frontend.js is already required by solidus_braintree.js --- lib/solidus_braintree/engine.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/solidus_braintree/engine.rb b/lib/solidus_braintree/engine.rb index a58cc87e..22a1d54e 100644 --- a/lib/solidus_braintree/engine.rb +++ b/lib/solidus_braintree/engine.rb @@ -24,8 +24,6 @@ class Engine < Rails::Engine config.assets.precompile += [ 'spree/frontend/solidus_braintree/checkout.js', - 'solidus_braintree/frontend.js', - 'spree/frontend/apple_pay_button.js', 'solidus_braintree_manifest.js' ] paths["app/controllers"] << "lib/controllers/frontend" From 1746d41d6dda0cd4783b714077177430344bec60 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 15 Feb 2023 13:10:16 +0800 Subject: [PATCH 40/66] Update README that extension is to be used with StarterFrontend --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7534be44..747cd42d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ `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 supports Apple Pay, PayPal, and credit card transactions. -🚧 This extension is currently only compatible with the legacy `solidus_frontend` 🚧 +🚧 This extension is currently only compatible with the `solidus_starter_frontend` 🚧 ## Installation @@ -119,7 +119,7 @@ Your payment method can accept payments in three ways: through Paypal, through A end ``` -4. If your site uses an unmodified `solidus_frontend`, it should now be ready to take payments. See below for more information on configuring Paypal and ApplePay. +4. If your site uses an unmodified Solidus Starter Frontend, it should now be ready to take payments. See below for more information on configuring Paypal and ApplePay. 5. Typical Solidus sites will have customized frontend code, and may require some additional work. Use `lib/views/frontend/spree/checkout/payment/_braintree.html.erb` and `app/assets/javascripts/solidus_braintree/checkout.js` as models. From 48429a396add2901972a740623971063c2664adb Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Fri, 17 Feb 2023 11:10:45 +0800 Subject: [PATCH 41/66] Inject SolidusBraintree dependencies into controllers Instead of monkeypatching the controllers, which the user already owns. https://github.com/solidusio/solidus_braintree/pull/102#discussion_r1108019774 --- .../solidus_braintree/carts_controller_decorator.rb | 11 ----------- .../checkout_controller_decorator.rb | 11 ----------- .../solidus_braintree/install/install_generator.rb | 12 ++++++++++++ 3 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 app/decorators/controllers/solidus_braintree/carts_controller_decorator.rb delete mode 100644 app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb diff --git a/app/decorators/controllers/solidus_braintree/carts_controller_decorator.rb b/app/decorators/controllers/solidus_braintree/carts_controller_decorator.rb deleted file mode 100644 index f3e2e78d..00000000 --- a/app/decorators/controllers/solidus_braintree/carts_controller_decorator.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module SolidusBraintree - module CartsControllerDecorator - def self.prepended(base) - base.helper ::SolidusBraintree::BraintreeCheckoutHelper - end - - CartsController.prepend(self) - end -end diff --git a/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb b/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb deleted file mode 100644 index 0eba46ea..00000000 --- a/app/decorators/controllers/solidus_braintree/checkout_controller_decorator.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module SolidusBraintree - module CheckoutControllerDecorator - def self.prepended(base) - base.helper ::SolidusBraintree::BraintreeCheckoutHelper - end - - ::CheckoutsController.prepend(self) - end -end diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 8ff33dfd..8cd5729c 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -72,6 +72,18 @@ def setup_stylesheets " *= require spree/backend/solidus_braintree\n", before: %r{\*/}, verbose: true end + def inject_checkout_helper_to_frontend_controllers + inject_into_class 'app/controllers/checkouts_controller.rb', + 'CheckoutsController', + " helper SolidusBraintree::BraintreeCheckoutHelper\n\n", + verbose: true + + inject_into_class 'app/controllers/carts_controller.rb', + 'CartsController', + " helper SolidusBraintree::BraintreeCheckoutHelper\n\n", + verbose: true + end + def add_migrations rake 'railties:install:migrations FROM=solidus_braintree' end From 08d2a32b1179f44f869693e40189bc7a86bd7151 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Mon, 20 Feb 2023 13:53:50 +0800 Subject: [PATCH 42/66] Wrap address in SolidusBraintree::Address --- app/views/spree/shared/_apple_pay_button.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/shared/_apple_pay_button.html.erb b/app/views/spree/shared/_apple_pay_button.html.erb index a46d8243..6220838e 100644 --- a/app/views/spree/shared/_apple_pay_button.html.erb +++ b/app/views/spree/shared/_apple_pay_button.html.erb @@ -1,4 +1,4 @@ -<% address = current_order.ship_address %> +<% address = SolidusBraintree::Address.new(current_order.ship_address) %> From cb628af6658901d7a61ee7240a113a8d51aa8e97 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 22 Feb 2023 10:51:20 +0800 Subject: [PATCH 43/66] Remove radio button from existing Braintree payment partial Also simplify markup of partial. Payment step UI was reorganized upstream at https://github.com/solidusio/solidus_starter_frontend/pull/321. --- .../checkouts/existing_payment/_braintree.html.erb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/app/views/checkouts/existing_payment/_braintree.html.erb b/app/views/checkouts/existing_payment/_braintree.html.erb index f9de0114..b5985c4a 100644 --- a/app/views/checkouts/existing_payment/_braintree.html.erb +++ b/app/views/checkouts/existing_payment/_braintree.html.erb @@ -1,10 +1,2 @@ - - - <%= radio_button_tag "order[wallet_payment_source_id]", - wallet_payment_source.id, - default, - class: "existing-cc-radio" %> - - <%= wallet_payment_source.payment_source.friendly_payment_type %> - <%= wallet_payment_source.payment_source.display_number %> - +<%= wallet_payment_source.payment_source.friendly_payment_type %> +<%= wallet_payment_source.payment_source.display_number %> From ac0e6d4301ef0507a3278e08642fb4cac92ee702 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 22 Feb 2023 10:53:13 +0800 Subject: [PATCH 44/66] Tokenize hosted fieldset Braintree form only if fieldset is enabled The fieldset is now always visible due to the payment step UI reorganization in https://github.com/solidusio/solidus_starter_frontend/pull/321. --- .../javascripts/spree/frontend/solidus_braintree/checkout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js b/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js index 0099a7b4..a879656e 100644 --- a/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js +++ b/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js @@ -40,7 +40,7 @@ $(function() { $paymentForm.on("submit",function(event) { var $field = $(hostedField); - if ($field.is(":visible") && !$field.data("submitting")) { + if ($field.is(":visible") && $field.is(":enabled") && !$field.data("submitting")) { var $nonce = $("#payment_method_nonce", $field); if ($nonce.length > 0 && $nonce.val() === "") { From b8f5bf1a6fcb9dfb2d71d496e60913867331a8a6 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 22 Feb 2023 11:28:50 +0800 Subject: [PATCH 45/66] Fix payment method container selector in spec Payment method container was changed in https://github.com/solidusio/solidus_starter_frontend/pull/321. --- spec/system/frontend/braintree_credit_card_checkout_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/frontend/braintree_credit_card_checkout_spec.rb b/spec/system/frontend/braintree_credit_card_checkout_spec.rb index 8c701cab..f8b81c3f 100644 --- a/spec/system/frontend/braintree_credit_card_checkout_spec.rb +++ b/spec/system/frontend/braintree_credit_card_checkout_spec.rb @@ -56,7 +56,7 @@ include_context "with frontend checkout setup" it "selectors display correctly" do - expect(page).to have_selector("#payment_method_#{braintree.id}", visible: :visible) + expect(page).to have_selector("fieldset[name='payment-method-#{braintree.id}']", visible: :visible) expect(page).to have_selector("iframe#braintree-hosted-field-number") expect(page).to have_selector("iframe[type='number']") end From 96a259c8f990d9618281b75678c6a73dd6fe2fd1 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 22 Feb 2023 12:03:46 +0800 Subject: [PATCH 46/66] Do not allow buttons in disabled payment-step to be clickable This is a workaround. Note that it's still possible to trigger the PayPal button iframe by tabbing to it and hitting enter. The hack works for the Venmo and PayPal buttons. The Apple Pay Button is also not yet tested as of this commit. It will be tested in https://github.com/solidusio/solidus_braintree/issues/105. --- .../stylesheets/spree/frontend/solidus_braintree.scss | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/assets/stylesheets/spree/frontend/solidus_braintree.scss b/app/assets/stylesheets/spree/frontend/solidus_braintree.scss index d69bb4e3..f1c30029 100644 --- a/app/assets/stylesheets/spree/frontend/solidus_braintree.scss +++ b/app/assets/stylesheets/spree/frontend/solidus_braintree.scss @@ -49,3 +49,14 @@ the installer will append this file to the app vendored assets here: 'vendor/ass .venmo-button.visible { visibility: visible; } + +/* +WORKAROUND: Do not allow buttons in disabled payment-step to be clickable. Note +that it's still possible to trigger the PayPal button iframe by tabbing to it +and hitting enter. +*/ +fieldset.payment-step__details:disabled { + #apple-pay-button, #paypal-button iframe, #venmo-button { + pointer-events: none; + } +} From ef8bb9128c47b9f3ba0ac22dd67bc88cb9533138 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 23 Feb 2023 10:45:53 +0800 Subject: [PATCH 47/66] Add Response to log entry permitted classes Fixes https://github.com/solidusio/solidus_braintree/issues/108. `SolidusBraintree::Response` is a direct subclass of `ActiveMerchant::Billing::Response`, which is a core permitted class of `Spree:LogEntry`([1][1]). Furthermore, `SolidusBraintree::Response` doesn't have any additional attributes. Thus, it should be safe to log. As recommended by the Spree::LogEntry::DisallowedClass error message ([2][2]), we're adding SolidusBraintree::Response to log_entry_permitted_classes through an initializer. [1]: https://github.com/solidusio/solidus/blob/0c52edfbb0c30ad16b3cf11a3a30ce42fb0dbe70/core/app/models/spree/log_entry.rb#L12 [2]: https://github.com/solidusio/solidus/blob/0c52edfbb0c30ad16b3cf11a3a30ce42fb0dbe70/core/app/models/spree/log_entry.rb#L33 --- lib/solidus_braintree/engine.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/solidus_braintree/engine.rb b/lib/solidus_braintree/engine.rb index 22a1d54e..18db13a4 100644 --- a/lib/solidus_braintree/engine.rb +++ b/lib/solidus_braintree/engine.rb @@ -22,6 +22,12 @@ class Engine < Rails::Engine end end + initializer 'add_solidus_braintree_response_to_log_entry_permitted_classes' do + Spree.config do |config| + config.log_entry_permitted_classes << 'SolidusBraintree::Response' + end + end + config.assets.precompile += [ 'spree/frontend/solidus_braintree/checkout.js', 'solidus_braintree_manifest.js' From 87bf0a09f44f5357fe827938a31b96e0d1e65c7c Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Fri, 24 Feb 2023 10:15:45 +0800 Subject: [PATCH 48/66] Deep stringify the keys of the result params Fixes https://github.com/solidusio/solidus_braintree/issues/110. Summary -------- A error Braintree response would raise the following error: ``` Spree::LogEntry::DisallowedClass: Tried to dump unspecified class: Symbol You can specify custom classes to be loaded in config/initializers/spree.rb. E.g: Spree.config do |config| config.log_entry_permitted_classes = ['MyClass'] end ``` Solidus Version: -------- 3.4.0.dev Cause -------- When `SolidusBraintree::Response.build(result)` accepts an error result, the `result.params` it passes to the new response has symbol keys. Here's a sample of the `result.params`: ``` {:transaction=> {:amount=>"20.00", :order_id=>"R300000001", :channel=>"Solidus", :options=>{:store_in_vault_on_success=>"true"}, :payment_method_token=>"0ev7m4dt", :customer_id=>"180763858", :type=>"sale"}} ``` Demonstration -------- See https://github.com/solidusio/solidus_braintree/tree/gsmendoza/110-log-entry-disallowed-class-demo for a demonstration of the error and the my attempts to fix it. Start from the "Try enabling venmo specs" commit. Additional context -------- Related to https://github.com/solidusio/solidus_braintree/issues/108. There is also a PR in Solidus that will temporarily allow bad payloads to be saved in payment log entries. See https://github.com/solidusio/solidus/pull/4953 --- app/models/solidus_braintree/response.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/solidus_braintree/response.rb b/app/models/solidus_braintree/response.rb index f9b636da..55c18e0a 100644 --- a/app/models/solidus_braintree/response.rb +++ b/app/models/solidus_braintree/response.rb @@ -29,7 +29,7 @@ def build_failure(result) # For error responses we want to have the CVV code cvv_result: transaction&.cvv_response_code ) - new(false, error_message(result), result.params, options) + new(false, error_message(result), result.params.deep_stringify_keys, options) end def response_options(transaction) From c4e57d20a290f1681a3a5f52bca8e1c72c93be85 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 23 Feb 2023 11:29:51 +0800 Subject: [PATCH 49/66] Reorganize install generator based on PaypalCommercePlatform Copied from https://github.com/solidusio/solidus_paypal_commerce_platform/blob/a19184f26d8ff35cf467d233172763aa03e9fe8b/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb. --- .../install/install_generator.rb | 165 ++++++++++-------- .../initializers/solidus_braintree.rb} | 0 2 files changed, 93 insertions(+), 72 deletions(-) rename lib/generators/solidus_braintree/install/templates/{initializer.rb => config/initializers/solidus_braintree.rb} (100%) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 8cd5729c..069f645e 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -8,12 +8,23 @@ class InstallGenerator < Rails::Generators::AppBase argument :app_path, type: :string, default: Rails.root class_option :migrate, type: :boolean, default: false - source_root File.expand_path('templates', __dir__) + class_option :backend, type: :boolean, default: true + class_option :frontend, type: :string, default: 'starter' # This is only used to run all-specs during development and CI, regular installation limits # installed specs to frontend, which are the ones related to code copied to the target application. class_option :specs, type: :string, enum: %w[all frontend], default: 'frontend', hide: true + source_root File.expand_path('templates', __dir__) + + def normalize_components_options + @components = { + backend: options[:backend], + starter_frontend: options[:frontend] == 'starter', + classic_frontend: options[:frontend] == 'classic', + } + end + def add_test_gems gem_group :test do ['vcr', 'webmock'].each do |gem_name| @@ -24,7 +35,7 @@ def add_test_gems bundle_command 'install' end - def setup_initializer + def setup_initializers legacy_initializer_pathname = Pathname.new(destination_root).join('config/initializers/solidus_paypal_braintree.rb') @@ -35,57 +46,13 @@ def setup_initializer "SolidusPaypalBraintree.configure do |config|\n", "SolidusBraintree.configure do |config|\n" else - template 'initializer.rb', 'config/initializers/solidus_braintree.rb' + directory 'config/initializers', 'config/initializers' end end - def setup_javascripts - inject_into_file 'vendor/assets/javascripts/spree/frontend/all.js', - "//= require jquery3\n", - before: '//= require rails-ujs', - verbose: true - - gsub_file 'vendor/assets/javascripts/spree/frontend/all.js', - "//= require spree/frontend/solidus_paypal_braintree\n", '' - - append_file 'app/assets/javascripts/solidus_starter_frontend.js', - "//= require spree/frontend/solidus_braintree\n" - - gsub_file 'vendor/assets/javascripts/spree/backend/all.js', - "//= require spree/backend/solidus_paypal_braintree\n", '' - - append_file 'vendor/assets/javascripts/spree/backend/all.js', - "//= require spree/backend/solidus_braintree\n" - end - - def setup_stylesheets - gsub_file 'vendor/assets/stylesheets/spree/frontend/all.css', - " *= require spree/frontend/solidus_paypal_braintree\n", '' - - inject_into_file 'app/assets/stylesheets/solidus_starter_frontend.css', - " *= require spree/frontend/solidus_braintree\n", before: %r{\*/}, verbose: true - - gsub_file 'vendor/assets/stylesheets/spree/backend/all.css', - " *= require spree/backend/solidus_paypal_braintree\n", '' - - inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', - " *= require spree/backend/solidus_braintree\n", before: %r{\*/}, verbose: true - end - - def inject_checkout_helper_to_frontend_controllers - inject_into_class 'app/controllers/checkouts_controller.rb', - 'CheckoutsController', - " helper SolidusBraintree::BraintreeCheckoutHelper\n\n", - verbose: true - - inject_into_class 'app/controllers/carts_controller.rb', - 'CartsController', - " helper SolidusBraintree::BraintreeCheckoutHelper\n\n", - verbose: true - end - - def add_migrations + def run_migrations rake 'railties:install:migrations FROM=solidus_braintree' + run 'bin/rails db:migrate' if options[:migrate] end def mount_engine @@ -95,40 +62,94 @@ def mount_engine route "mount SolidusBraintree::Engine, at: '/solidus_braintree'" end - def run_migrations - run_migrations = options[:migrate] || - ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) + def install_solidus_backend_support + support_code_for(:backend) do + gsub_file 'vendor/assets/javascripts/spree/backend/all.js', + "//= require spree/backend/solidus_paypal_braintree\n", '' - if run_migrations - rake 'db:migrate' - else - puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output + append_file 'vendor/assets/javascripts/spree/backend/all.js', + "//= require spree/backend/solidus_braintree\n" + + gsub_file 'vendor/assets/stylesheets/spree/backend/all.css', + " *= require spree/backend/solidus_paypal_braintree\n", '' + + inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', + " *= require spree/backend/solidus_braintree\n", before: %r{\*/}, verbose: true end end - def install_specs - spec_paths = - case options[:specs] - when 'all' then %w[spec] - when 'frontend' - %w[ - spec/solidus_braintree_helper.rb - spec/system/frontend - spec/support - ] + def install_solidus_starter_frontend_support + support_code_for(:starter_frontend) do + inject_into_file 'vendor/assets/javascripts/spree/frontend/all.js', + "//= require jquery3\n", + before: '//= require rails-ujs', + verbose: true + + gsub_file 'vendor/assets/javascripts/spree/frontend/all.js', + "//= require spree/frontend/solidus_paypal_braintree\n", '' + + append_file 'app/assets/javascripts/solidus_starter_frontend.js', + "//= require spree/frontend/solidus_braintree\n" + + gsub_file 'vendor/assets/stylesheets/spree/frontend/all.css', + " *= require spree/frontend/solidus_paypal_braintree\n", '' + + inject_into_file 'app/assets/stylesheets/solidus_starter_frontend.css', + " *= require spree/frontend/solidus_braintree\n", before: %r{\*/}, verbose: true + + inject_into_class 'app/controllers/checkouts_controller.rb', + 'CheckoutsController', + " helper SolidusBraintree::BraintreeCheckoutHelper\n\n", + verbose: true + + inject_into_class 'app/controllers/carts_controller.rb', + 'CartsController', + " helper SolidusBraintree::BraintreeCheckoutHelper\n\n", + verbose: true + + spec_paths = + case options[:specs] + when 'all' then %w[spec] + when 'frontend' + %w[ + spec/solidus_braintree_helper.rb + spec/system/frontend + spec/support + ] + end + + spec_paths.each do |path| + if engine.root.join(path).directory? + directory engine.root.join(path), path + else + template engine.root.join(path), path + end end + end + end - spec_paths.each do |path| - if engine.root.join(path).directory? - directory engine.root.join(path), path - else - template engine.root.join(path), path - end + def alert_no_classic_frontend_support + support_code_for(:classic_frontend) do + message = <<~TEXT + For solidus_frontend compatibility, please use the deprecated version 0.x. + The new version of this extension only supports Solidus Starter Frontend. + No frontend code has been copied to your application. + TEXT + say_status :error, set_color(message.tr("\n", ' '), :red), :red end end private + def support_code_for(component_name, &block) + if @components[component_name] + say_status :install, "[#{engine.engine_name}] solidus_#{component_name}", :blue + shell.indent(&block) + else + say_status :skip, "[#{engine.engine_name}] solidus_#{component_name}", :blue + end + end + def engine SolidusBraintree::Engine end diff --git a/lib/generators/solidus_braintree/install/templates/initializer.rb b/lib/generators/solidus_braintree/install/templates/config/initializers/solidus_braintree.rb similarity index 100% rename from lib/generators/solidus_braintree/install/templates/initializer.rb rename to lib/generators/solidus_braintree/install/templates/config/initializers/solidus_braintree.rb From 8f3ba6bc6e023dc551683450ffa9300ecfd7433a Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 23 Feb 2023 15:04:27 +0800 Subject: [PATCH 50/66] Move frontend code to install generator templates Remove images link in SolidusBraintree manifest. No longer needed since the images will be copied to the user's app. --- app/assets/config/solidus_braintree_manifest.js | 1 - lib/generators/solidus_braintree/install/install_generator.rb | 2 ++ .../solidus_braintree/venmo/venmo_active_blue_button_280x48.svg | 0 .../solidus_braintree/venmo/venmo_active_blue_button_320x48.svg | 0 .../solidus_braintree/venmo/venmo_active_blue_button_375x48.svg | 0 .../venmo/venmo_active_white_button_280x48.svg | 0 .../venmo/venmo_active_white_button_320x48.svg | 0 .../venmo/venmo_active_white_button_375x48.svg | 0 .../solidus_braintree/venmo/venmo_blue_acceptance_mark.svg | 0 .../images/solidus_braintree/venmo/venmo_blue_button_280x48.svg | 0 .../images/solidus_braintree/venmo/venmo_blue_button_320x48.svg | 0 .../images/solidus_braintree/venmo/venmo_blue_button_375x48.svg | 0 .../assets/images/solidus_braintree/venmo/venmo_blue_logo.svg | 0 .../solidus_braintree/venmo/venmo_white_acceptance_mark.svg | 0 .../solidus_braintree/venmo/venmo_white_button_280x48.svg | 0 .../solidus_braintree/venmo/venmo_white_button_320x48.svg | 0 .../solidus_braintree/venmo/venmo_white_button_375x48.svg | 0 .../assets/images/solidus_braintree/venmo/venmo_white_logo.svg | 0 .../app}/assets/javascripts/spree/frontend/paypal_button.js | 0 .../app}/assets/javascripts/spree/frontend/solidus_braintree.js | 0 .../assets/javascripts/spree/frontend/solidus_braintree/ajax.js | 0 .../spree/frontend/solidus_braintree/apple_pay_button.js | 0 .../javascripts/spree/frontend/solidus_braintree/checkout.js | 0 .../javascripts/spree/frontend/solidus_braintree/client.js | 0 .../javascripts/spree/frontend/solidus_braintree/constants.js | 0 .../javascripts/spree/frontend/solidus_braintree/frontend.js | 0 .../javascripts/spree/frontend/solidus_braintree/hosted_form.js | 0 .../spree/frontend/solidus_braintree/paypal_button.js | 0 .../spree/frontend/solidus_braintree/paypal_messaging.js | 0 .../javascripts/spree/frontend/solidus_braintree/promise.js | 0 .../spree/frontend/solidus_braintree/venmo_button.js | 0 .../assets/stylesheets/spree/frontend/solidus_braintree.scss | 0 .../app/controllers}/solidus_braintree/checkouts_controller.rb | 0 .../controllers}/solidus_braintree/transactions_controller.rb | 0 .../app}/helpers/solidus_braintree/braintree_checkout_helper.rb | 0 .../app}/views/checkouts/existing_payment/_braintree.html.erb | 0 .../templates/app}/views/checkouts/payment/_braintree.html.erb | 0 .../install/templates/app/views}/payments/_payment.html.erb | 0 .../app}/views/spree/shared/_apple_pay_button.html.erb | 0 .../app}/views/spree/shared/_braintree_errors.html.erb | 0 .../app}/views/spree/shared/_braintree_head_scripts.html.erb | 0 .../app}/views/spree/shared/_braintree_hosted_fields.html.erb | 0 .../app}/views/spree/shared/_paypal_cart_button.html.erb | 0 .../app/views}/spree/shared/_paypal_checkout_button.html.erb | 0 .../app}/views/spree/shared/_paypal_messaging.html.erb | 0 .../templates/app}/views/spree/shared/_venmo_button.html.erb | 0 46 files changed, 2 insertions(+), 1 deletion(-) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_active_blue_button_280x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_active_blue_button_320x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_active_blue_button_375x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_active_white_button_280x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_active_white_button_320x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_active_white_button_375x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_blue_acceptance_mark.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_blue_button_280x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_blue_button_320x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_blue_button_375x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_blue_logo.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_white_acceptance_mark.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_white_button_280x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_white_button_320x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_white_button_375x48.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/images/solidus_braintree/venmo/venmo_white_logo.svg (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/paypal_button.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/ajax.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/checkout.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/client.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/constants.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/frontend.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/promise.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/assets/stylesheets/spree/frontend/solidus_braintree.scss (100%) rename lib/{controllers/frontend => generators/solidus_braintree/install/templates/app/controllers}/solidus_braintree/checkouts_controller.rb (100%) rename lib/{controllers/frontend => generators/solidus_braintree/install/templates/app/controllers}/solidus_braintree/transactions_controller.rb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/helpers/solidus_braintree/braintree_checkout_helper.rb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/checkouts/existing_payment/_braintree.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/checkouts/payment/_braintree.html.erb (100%) rename lib/{views/frontend/solidus_braintree => generators/solidus_braintree/install/templates/app/views}/payments/_payment.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/spree/shared/_apple_pay_button.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/spree/shared/_braintree_errors.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/spree/shared/_braintree_head_scripts.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/spree/shared/_braintree_hosted_fields.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/spree/shared/_paypal_cart_button.html.erb (100%) rename lib/{views/frontend => generators/solidus_braintree/install/templates/app/views}/spree/shared/_paypal_checkout_button.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/spree/shared/_paypal_messaging.html.erb (100%) rename {app => lib/generators/solidus_braintree/install/templates/app}/views/spree/shared/_venmo_button.html.erb (100%) diff --git a/app/assets/config/solidus_braintree_manifest.js b/app/assets/config/solidus_braintree_manifest.js index ac907b36..e69de29b 100644 --- a/app/assets/config/solidus_braintree_manifest.js +++ b/app/assets/config/solidus_braintree_manifest.js @@ -1 +0,0 @@ -//= link_tree ../images diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 069f645e..10247b9d 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -80,6 +80,8 @@ def install_solidus_backend_support def install_solidus_starter_frontend_support support_code_for(:starter_frontend) do + directory 'app', 'app' + inject_into_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require jquery3\n", before: '//= require rails-ujs', diff --git a/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_280x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_280x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_280x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_280x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_320x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_320x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_320x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_320x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_375x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_375x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_375x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_blue_button_375x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_280x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_280x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_active_white_button_280x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_280x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_320x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_320x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_active_white_button_320x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_320x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_375x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_375x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_active_white_button_375x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_active_white_button_375x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_blue_acceptance_mark.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_acceptance_mark.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_blue_acceptance_mark.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_acceptance_mark.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_blue_button_280x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_button_280x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_blue_button_280x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_button_280x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_blue_button_320x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_button_320x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_blue_button_320x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_button_320x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_blue_button_375x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_button_375x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_blue_button_375x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_button_375x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_blue_logo.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_logo.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_blue_logo.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_blue_logo.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_white_acceptance_mark.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_acceptance_mark.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_white_acceptance_mark.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_acceptance_mark.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_white_button_280x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_button_280x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_white_button_280x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_button_280x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_white_button_320x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_button_320x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_white_button_320x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_button_320x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_white_button_375x48.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_button_375x48.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_white_button_375x48.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_button_375x48.svg diff --git a/app/assets/images/solidus_braintree/venmo/venmo_white_logo.svg b/lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_logo.svg similarity index 100% rename from app/assets/images/solidus_braintree/venmo/venmo_white_logo.svg rename to lib/generators/solidus_braintree/install/templates/app/assets/images/solidus_braintree/venmo/venmo_white_logo.svg diff --git a/app/assets/javascripts/spree/frontend/paypal_button.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/paypal_button.js similarity index 100% rename from app/assets/javascripts/spree/frontend/paypal_button.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/paypal_button.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/apple_pay_button.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/client.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/client.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/client.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/client.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/constants.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/constants.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/frontend.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_button.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/paypal_messaging.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/promise.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/promise.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/promise.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/promise.js diff --git a/app/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js similarity index 100% rename from app/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js rename to lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/venmo_button.js diff --git a/app/assets/stylesheets/spree/frontend/solidus_braintree.scss b/lib/generators/solidus_braintree/install/templates/app/assets/stylesheets/spree/frontend/solidus_braintree.scss similarity index 100% rename from app/assets/stylesheets/spree/frontend/solidus_braintree.scss rename to lib/generators/solidus_braintree/install/templates/app/assets/stylesheets/spree/frontend/solidus_braintree.scss diff --git a/lib/controllers/frontend/solidus_braintree/checkouts_controller.rb b/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb similarity index 100% rename from lib/controllers/frontend/solidus_braintree/checkouts_controller.rb rename to lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb diff --git a/lib/controllers/frontend/solidus_braintree/transactions_controller.rb b/lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/transactions_controller.rb similarity index 100% rename from lib/controllers/frontend/solidus_braintree/transactions_controller.rb rename to lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/transactions_controller.rb diff --git a/app/helpers/solidus_braintree/braintree_checkout_helper.rb b/lib/generators/solidus_braintree/install/templates/app/helpers/solidus_braintree/braintree_checkout_helper.rb similarity index 100% rename from app/helpers/solidus_braintree/braintree_checkout_helper.rb rename to lib/generators/solidus_braintree/install/templates/app/helpers/solidus_braintree/braintree_checkout_helper.rb diff --git a/app/views/checkouts/existing_payment/_braintree.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/checkouts/existing_payment/_braintree.html.erb similarity index 100% rename from app/views/checkouts/existing_payment/_braintree.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/checkouts/existing_payment/_braintree.html.erb diff --git a/app/views/checkouts/payment/_braintree.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/checkouts/payment/_braintree.html.erb similarity index 100% rename from app/views/checkouts/payment/_braintree.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/checkouts/payment/_braintree.html.erb diff --git a/lib/views/frontend/solidus_braintree/payments/_payment.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/payments/_payment.html.erb similarity index 100% rename from lib/views/frontend/solidus_braintree/payments/_payment.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/payments/_payment.html.erb diff --git a/app/views/spree/shared/_apple_pay_button.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_apple_pay_button.html.erb similarity index 100% rename from app/views/spree/shared/_apple_pay_button.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_apple_pay_button.html.erb diff --git a/app/views/spree/shared/_braintree_errors.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_errors.html.erb similarity index 100% rename from app/views/spree/shared/_braintree_errors.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_errors.html.erb diff --git a/app/views/spree/shared/_braintree_head_scripts.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_head_scripts.html.erb similarity index 100% rename from app/views/spree/shared/_braintree_head_scripts.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_head_scripts.html.erb diff --git a/app/views/spree/shared/_braintree_hosted_fields.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_hosted_fields.html.erb similarity index 100% rename from app/views/spree/shared/_braintree_hosted_fields.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_hosted_fields.html.erb diff --git a/app/views/spree/shared/_paypal_cart_button.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_paypal_cart_button.html.erb similarity index 100% rename from app/views/spree/shared/_paypal_cart_button.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_paypal_cart_button.html.erb diff --git a/lib/views/frontend/spree/shared/_paypal_checkout_button.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_paypal_checkout_button.html.erb similarity index 100% rename from lib/views/frontend/spree/shared/_paypal_checkout_button.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_paypal_checkout_button.html.erb diff --git a/app/views/spree/shared/_paypal_messaging.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_paypal_messaging.html.erb similarity index 100% rename from app/views/spree/shared/_paypal_messaging.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_paypal_messaging.html.erb diff --git a/app/views/spree/shared/_venmo_button.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_venmo_button.html.erb similarity index 100% rename from app/views/spree/shared/_venmo_button.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_venmo_button.html.erb From 3e22ef7e017f046ad8576ea1f75cb0a15654284f Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Fri, 24 Feb 2023 13:30:48 +0800 Subject: [PATCH 51/66] Fix: payment partial wasn't being injected to payment info * Update InstallGenerator to install the partial. * Remove add_paypal_funding_source_to_payment override. * Rename payment partial to braintree_payment_details. * Remove breaks from partial. --- .../payment/add_paypal_funding_source_to_payment.rb | 9 --------- .../solidus_braintree/install/install_generator.rb | 5 +++++ ...ment.html.erb => _braintree_payment_details.html.erb} | 3 --- 3 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 app/overrides/spree/payments/payment/add_paypal_funding_source_to_payment.rb rename lib/generators/solidus_braintree/install/templates/app/views/payments/{_payment.html.erb => _braintree_payment_details.html.erb} (93%) diff --git a/app/overrides/spree/payments/payment/add_paypal_funding_source_to_payment.rb b/app/overrides/spree/payments/payment/add_paypal_funding_source_to_payment.rb deleted file mode 100644 index 08a58cf7..00000000 --- a/app/overrides/spree/payments/payment/add_paypal_funding_source_to_payment.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -Deface::Override.new( - name: "payments/payment/add_paypal_funding_source_to_payment", - virtual_path: "spree/payments/_payment", - original: "0b5b5ae53626059cb3a202ef95d10827dd399925", - insert_after: "erb[loud]:contains('content_tag(:span, payment.payment_method.name)')", - partial: "solidus_braintree/payments/payment" -) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 10247b9d..d5a88902 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -109,6 +109,11 @@ def install_solidus_starter_frontend_support " helper SolidusBraintree::BraintreeCheckoutHelper\n\n", verbose: true + inject_into_file 'app/views/orders/_payment_info.html.erb', + "
  • <%= render 'payments/braintree_payment_details', payment: payment %>
  • \n", + after: "
  • <%= payment.payment_method.name %>
  • \n", + verbose: true + spec_paths = case options[:specs] when 'all' then %w[spec] diff --git a/lib/generators/solidus_braintree/install/templates/app/views/payments/_payment.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/payments/_braintree_payment_details.html.erb similarity index 93% rename from lib/generators/solidus_braintree/install/templates/app/views/payments/_payment.html.erb rename to lib/generators/solidus_braintree/install/templates/app/views/payments/_braintree_payment_details.html.erb index 095986c6..4e518dd2 100644 --- a/lib/generators/solidus_braintree/install/templates/app/views/payments/_payment.html.erb +++ b/lib/generators/solidus_braintree/install/templates/app/views/payments/_braintree_payment_details.html.erb @@ -1,12 +1,9 @@ -
    <%= payment.source.try(:display_payment_type) %> <% if payment.source.try(:paypal?) %> <% if payment.source.respond_to?(:paypal_funding_source) && payment.source.paypal_funding_source.present? %> -
    <%= t('spree.paypal_funding', funding: payment.source.display_paypal_funding_source) %> <% end %> <% elsif payment.source.try(:venmo?) %> -
    <%= payment.source.source_description %> <% end %> From 9efff63ac42088e51a61cf75e2f8fc506f67b87d Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Fri, 24 Feb 2023 15:19:31 +0800 Subject: [PATCH 52/66] Install spec/fixtures when installing extension on an app --- lib/generators/solidus_braintree/install/install_generator.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index d5a88902..8ff3782e 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -122,6 +122,7 @@ def install_solidus_starter_frontend_support spec/solidus_braintree_helper.rb spec/system/frontend spec/support + spec/fixtures ] end From da6394807daad2d798083e2f446793c40ebfa1fc Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Fri, 24 Feb 2023 15:50:47 +0800 Subject: [PATCH 53/66] Update Upgrade instructions --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 747cd42d..08ff5273 100644 --- a/README.md +++ b/README.md @@ -30,15 +30,32 @@ Take note that for now we are keeping the `solidus_paypal_braintree` prefix for ## Upgrading from SolidusPaypalBraintree 1.2.0 to SolidusBraintree 2.0.0 -With the gem renamed to SolidusBraintree, you'll need to: +The gem has undergone two major changes: 1) it's been renamed to SolidusBraintree, and 2) its frontend is now SolidusStarterFrontend. With those changes in mind, you'll need to: -1. Change the gem in your Gemfile from `gem 'solidus_paypal_braintree'` to `gem 'solidus_braintree', '~> 2.0.0'`. If you have your own references to `SolidusPaypalBraintree` in your app, you may need to require the `solidus_paypal_braintree` alias in your Gemfile, i.e. +1. Change the gem in your Gemfile from `gem 'solidus_paypal_braintree'` to `gem 'solidus_braintree', '~> 2.0.0'`. You'll likely have references to `SolidusPaypalBraintree` in your app, so you may also need to require the `solidus_paypal_braintree` alias in your Gemfile, i.e. ```ruby gem 'solidus_braintree', '~> 2.0.0'`, require: 'solidus_paypal_braintree' ``` -2. Run `bin/rails g solidus_braintree:install`. This will update some references to SolidusPaypalBraintree in your app. It will also add a data migration to update your database. +2. Break down the solidus gem, remove the `solidus_frontend` gem, and update the gems to 3.4.0. Thus, in your `Gemfile`, replace + + ```ruby + gem 'solidus' + ``` + + with + + ```ruby + gem 'solidus_core', '~> 3.4.0' + gem 'solidus_backend', '~> 3.4.0' + gem 'solidus_api', '~> 3.4.0' + gem 'solidus_sample', '~> 3.4.0' + ``` + +3. Install SolidusStarterFrontend by running `bin/rails app:template LOCATION=https://github.com/solidusio/solidus_starter_frontend/raw/v3.4/template.rb`. If you have any overridden `solidus_frontend` views, you'll need to manually update them to fit the new frontend. + +4. Run `bin/rails g solidus_braintree:install`. This will update some references to SolidusPaypalBraintree in your app. It will also add a data migration to update your database. Additionally, you can rename any other references to SolidusPaypalBraintree in your app to SolidusBraintree. This will fix any deprecation warnings that come with SolidusBraintree 2.0.0. From cb82bfe0ccbd098893cefb4a182560c82007bb64 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Tue, 28 Feb 2023 10:15:01 +0800 Subject: [PATCH 54/66] Fix RuboCop offenses in CI Offenses: app/models/solidus_braintree/transaction.rb:20:21: C: [Correctable] Style/InverseMethods: Use invalid? instead of inverting valid?. if address && !address.valid? ^^^^^^^^^^^^^^^ app/models/solidus_braintree/transaction_import.rb:12:57: C: [Correctable] Style/InverseMethods: Use invalid? instead of inverting valid?. errors.add("Address", "is invalid") if address && !address.valid? ^^^^^^^^^^^^^^^ app/models/solidus_braintree/transaction_import.rb:14:10: C: [Correctable] Style/InverseMethods: Use invalid? instead of inverting valid?. if !transaction.valid? ^^^^^^^^^^^^^^^^^^^ --- app/models/solidus_braintree/transaction.rb | 2 +- app/models/solidus_braintree/transaction_import.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/solidus_braintree/transaction.rb b/app/models/solidus_braintree/transaction.rb index 9c6ccf45..c06500cd 100644 --- a/app/models/solidus_braintree/transaction.rb +++ b/app/models/solidus_braintree/transaction.rb @@ -17,7 +17,7 @@ class Transaction unless payment_method.is_a? SolidusBraintree::Gateway errors.add(:payment_method, 'Must be braintree') end - if address && !address.valid? + if address && address.invalid? address.errors.each do |error| errors.add(:address, error.full_message) end diff --git a/app/models/solidus_braintree/transaction_import.rb b/app/models/solidus_braintree/transaction_import.rb index 838f609e..042982ac 100644 --- a/app/models/solidus_braintree/transaction_import.rb +++ b/app/models/solidus_braintree/transaction_import.rb @@ -9,9 +9,9 @@ class InvalidImportError < StandardError; end include ActiveModel::Model validate do - errors.add("Address", "is invalid") if address && !address.valid? + errors.add("Address", "is invalid") if address && address.invalid? - if !transaction.valid? + if transaction.invalid? transaction.errors.each do |error| errors.add(error.attribute, error.message) end From 838c0251c4def46c5b50cca587bbc0a0bef8fee6 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Tue, 28 Feb 2023 10:55:20 +0800 Subject: [PATCH 55/66] Automatically fix RuboCop offenses Offenses: app/models/solidus_braintree/transaction.rb:20:10: C: [Correctable] Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method. if address && address.invalid? ^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/models/solidus_braintree/transaction_import.rb:12:46: C: [Correctable] Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method. errors.add("Address", "is invalid") if address && address.invalid? ^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- app/models/solidus_braintree/transaction.rb | 2 +- app/models/solidus_braintree/transaction_import.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/solidus_braintree/transaction.rb b/app/models/solidus_braintree/transaction.rb index c06500cd..ddc2f19f 100644 --- a/app/models/solidus_braintree/transaction.rb +++ b/app/models/solidus_braintree/transaction.rb @@ -17,7 +17,7 @@ class Transaction unless payment_method.is_a? SolidusBraintree::Gateway errors.add(:payment_method, 'Must be braintree') end - if address && address.invalid? + if address&.invalid? address.errors.each do |error| errors.add(:address, error.full_message) end diff --git a/app/models/solidus_braintree/transaction_import.rb b/app/models/solidus_braintree/transaction_import.rb index 042982ac..fa17e79c 100644 --- a/app/models/solidus_braintree/transaction_import.rb +++ b/app/models/solidus_braintree/transaction_import.rb @@ -9,7 +9,7 @@ class InvalidImportError < StandardError; end include ActiveModel::Model validate do - errors.add("Address", "is invalid") if address && address.invalid? + errors.add("Address", "is invalid") if address&.invalid? if transaction.invalid? transaction.errors.each do |error| From 38118ef63237636dfac7bbd972314772d7fa1597 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Wed, 1 Mar 2023 10:18:15 +0800 Subject: [PATCH 56/66] Update Solidus dependency to >= 3.4.0.dev and < 4 Closes https://github.com/solidusio/solidus_braintree/issues/113. --- solidus_braintree.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solidus_braintree.gemspec b/solidus_braintree.gemspec index 5309a406..de907f46 100644 --- a/solidus_braintree.gemspec +++ b/solidus_braintree.gemspec @@ -31,8 +31,8 @@ Gem::Specification.new do |spec| spec.add_dependency 'activemerchant', '~> 1.48' spec.add_dependency 'braintree', '~> 3.4' - spec.add_dependency 'solidus_api', ['>= 2.4.0', '< 4'] - spec.add_dependency 'solidus_core', ['>= 2.4.0', '< 4'] + spec.add_dependency 'solidus_api', ['>= 3.4.0.dev', '< 4'] + spec.add_dependency 'solidus_core', ['>= 3.4.0.dev', '< 4'] spec.add_dependency 'solidus_support', ['>= 0.8.1', '< 1'] spec.add_development_dependency 'rails-controller-testing' From b18e32d7dae9fa71ebdaa92595df25d9804e4ebe Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 2 Mar 2023 16:43:23 +0800 Subject: [PATCH 57/66] Migrate database by default We need to migrate the database by default so that once we add Braintree to the Solidus installer, running `solidus:install` would automatically run the SolidusBraintree migrations. See https://github.com/solidusio/solidus/issues/4749. This should be safe since migrate is also enabled by default in SolidusPaypalCommercePlatform. See https://github.com/solidusio/solidus_paypal_commerce_platform/blob/a6f87f5d6a1621eda453db31ccdc8c3903ef48c4/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb#L6. --- lib/generators/solidus_braintree/install/install_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 8ff3782e..6cc02fe6 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -7,7 +7,7 @@ module Generators class InstallGenerator < Rails::Generators::AppBase argument :app_path, type: :string, default: Rails.root - class_option :migrate, type: :boolean, default: false + class_option :migrate, type: :boolean, default: true class_option :backend, type: :boolean, default: true class_option :frontend, type: :string, default: 'starter' From 3817011ef6c12576429202b00083ea7d0e7190c7 Mon Sep 17 00:00:00 2001 From: Simon Meyborg Date: Tue, 14 Feb 2023 16:19:57 +0100 Subject: [PATCH 58/66] Add device-data-collection Closes https://github.com/solidusio/solidus_braintree/issues/115. This commit adds device data collection. See: https://developer.paypal.com/braintree/docs/guides/premium-fraud-management-tools/device-data-collection --- app/models/solidus_braintree/gateway.rb | 4 +++ ...10_add_device_data_to_braintree_sources.rb | 5 +++ .../frontend/solidus_braintree/checkout.js | 4 ++- .../frontend/solidus_braintree/hosted_form.js | 1 + .../shared/_braintree_hosted_fields.html.erb | 1 + lib/solidus_braintree/engine.rb | 5 ++- spec/models/solidus_braintree/gateway_spec.rb | 34 ++++++++++++++++++- 7 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20230210104310_add_device_data_to_braintree_sources.rb diff --git a/app/models/solidus_braintree/gateway.rb b/app/models/solidus_braintree/gateway.rb index 723037e9..6704672b 100644 --- a/app/models/solidus_braintree/gateway.rb +++ b/app/models/solidus_braintree/gateway.rb @@ -364,6 +364,10 @@ def transaction_options(source, options, submit_for_settlement: false) params[:payment_method_nonce] = source.nonce end + if source&.device_data + params[:device_data] = source.device_data + end + if source.paypal? params[:shipping] = braintree_shipping_address(options) end diff --git a/db/migrate/20230210104310_add_device_data_to_braintree_sources.rb b/db/migrate/20230210104310_add_device_data_to_braintree_sources.rb new file mode 100644 index 00000000..8a5195ae --- /dev/null +++ b/db/migrate/20230210104310_add_device_data_to_braintree_sources.rb @@ -0,0 +1,5 @@ +class AddDeviceDataToBraintreeSources < ActiveRecord::Migration[5.1] + def change + add_column :solidus_paypal_braintree_sources, :device_data, :string + end +end diff --git a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js index a879656e..3c24494e 100644 --- a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js +++ b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js @@ -42,7 +42,7 @@ $(function() { if ($field.is(":visible") && $field.is(":enabled") && !$field.data("submitting")) { var $nonce = $("#payment_method_nonce", $field); - + var $deviceData = $("#device_data", $field); if ($nonce.length > 0 && $nonce.val() === "") { var client = braintreeForm._merchantConfigurationOptions._solidusClient; @@ -56,6 +56,8 @@ $(function() { } $nonce.val(payload.nonce); + + $deviceData.val(client._dataCollectorInstance.deviceData); if (!client.useThreeDSecure) { $paymentForm.submit(); diff --git a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js index 4329e03d..b517e40c 100644 --- a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js +++ b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js @@ -7,6 +7,7 @@ SolidusBraintree.HostedForm.prototype.initialize = function() { this.client = SolidusBraintree.createClient({ paymentMethodId: this.paymentMethodId, useThreeDSecure: (typeof(window.threeDSecureOptions) !== 'undefined'), + useDataCollector: true, }); return this.client.initialize(). diff --git a/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_hosted_fields.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_hosted_fields.html.erb index 8640b0f7..cb3a4077 100644 --- a/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_hosted_fields.html.erb +++ b/lib/generators/solidus_braintree/install/templates/app/views/spree/shared/_braintree_hosted_fields.html.erb @@ -27,6 +27,7 @@
    + diff --git a/lib/solidus_braintree/engine.rb b/lib/solidus_braintree/engine.rb index 18db13a4..9f905f18 100644 --- a/lib/solidus_braintree/engine.rb +++ b/lib/solidus_braintree/engine.rb @@ -18,7 +18,10 @@ class Engine < Rails::Engine config.to_prepare do app.config.spree.payment_methods << SolidusBraintree::Gateway SolidusBraintree::Gateway.allowed_admin_form_preference_types.push(:preference_select).uniq! - ::Spree::PermittedAttributes.source_attributes.concat([:nonce, :payment_type, :paypal_funding_source]).uniq! + + ::Spree::PermittedAttributes.source_attributes.concat( + [:nonce, :payment_type, :paypal_funding_source, :device_data] + ).uniq! end end diff --git a/spec/models/solidus_braintree/gateway_spec.rb b/spec/models/solidus_braintree/gateway_spec.rb index f72eaf53..9093fe7c 100644 --- a/spec/models/solidus_braintree/gateway_spec.rb +++ b/spec/models/solidus_braintree/gateway_spec.rb @@ -16,7 +16,8 @@ nonce: 'fake-valid-nonce', user: user, payment_type: payment_type, - payment_method: gateway + payment_method: gateway, + device_data: 'fake-device-data' ) end @@ -220,6 +221,37 @@ expect(authorize.message).to eq 'authorized' expect(authorize.authorization).to be_present end + + context 'with available device data' do + it 'passes the device data as a parameter in the request' do + expect_any_instance_of(Braintree::TransactionGateway). + to receive(:sale). + with(hash_including({ device_data: "fake-device-data" })).and_call_original + authorize + end + end + + context 'without device_data' do + let(:source) do + SolidusBraintree::Source.create!( + nonce: 'fake-valid-nonce', + user: user, + payment_type: payment_type, + payment_method: gateway + ) + end + + before do + allow_any_instance_of(Braintree::TransactionGateway).to receive(:sale).and_call_original + end + + it 'does not pass any device data in the request' do + expect_any_instance_of(Braintree::TransactionGateway) + .not_to receive(:sale).with(hash_including({ device_data: "" })) + + authorize + end + end end context 'with different merchant account for currency', vcr: { From 275e4ad2959f219ff5c2bc786618af7e4d5f49b2 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Fri, 3 Mar 2023 10:52:06 +0800 Subject: [PATCH 59/66] Fix: deprecated version in warning should be 1.x instead of 0.x --- lib/generators/solidus_braintree/install/install_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index 6cc02fe6..c822693a 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -139,7 +139,7 @@ def install_solidus_starter_frontend_support def alert_no_classic_frontend_support support_code_for(:classic_frontend) do message = <<~TEXT - For solidus_frontend compatibility, please use the deprecated version 0.x. + For solidus_frontend compatibility, please use the deprecated version 1.x. The new version of this extension only supports Solidus Starter Frontend. No frontend code has been copied to your application. TEXT From 832db7c0b08ba7defa2c1967e929b9ceb2ab3310 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Tue, 14 Mar 2023 09:46:25 +0800 Subject: [PATCH 60/66] Fix: user should still be able to disable data collection in a SolidusBraintree hosted form Closes https://github.com/solidusio/solidus_braintree/issues/126. --- app/models/solidus_braintree/source.rb | 5 +++++ .../spree/frontend/solidus_braintree/checkout.js | 7 +++++-- .../frontend/solidus_braintree/hosted_form.js | 5 +++-- .../views/checkouts/payment/_braintree.html.erb | 2 +- spec/models/solidus_braintree/source_spec.rb | 15 +++++++++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/models/solidus_braintree/source.rb b/app/models/solidus_braintree/source.rb index 564a5677..0f93f371 100644 --- a/app/models/solidus_braintree/source.rb +++ b/app/models/solidus_braintree/source.rb @@ -25,6 +25,7 @@ class Source < ::Spree::PaymentSource validates :payment_type, inclusion: [PAYPAL, APPLE_PAY, VENMO, CREDIT_CARD] + before_validation :clear_device_data_if_blank before_save :clear_paypal_funding_source, unless: :paypal? scope(:with_payment_profile, -> { joins(:customer) }) @@ -128,6 +129,10 @@ def braintree_client @braintree_client ||= payment_method.try(:braintree) end + def clear_device_data_if_blank + self.device_data = nil if device_data.blank? + end + def clear_paypal_funding_source self.paypal_funding_source = nil end diff --git a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js index 3c24494e..3b8c9cbd 100644 --- a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js +++ b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/checkout.js @@ -57,7 +57,9 @@ $(function() { $nonce.val(payload.nonce); - $deviceData.val(client._dataCollectorInstance.deviceData); + if (client._dataCollectorInstance) { + $deviceData.val(client._dataCollectorInstance.deviceData); + } if (!client.useThreeDSecure) { $paymentForm.submit(); @@ -95,8 +97,9 @@ $(function() { var fieldPromises = $hostedFields.map(function(index, field) { var $this = $(this); var id = $this.data("id"); + var useDataCollector = $this.data("use-data-collector"); - var braintreeForm = new SolidusBraintree.createHostedForm(id); + var braintreeForm = new SolidusBraintree.createHostedForm(id, useDataCollector); var formInitializationSuccess = function(formObject) { addFormHook(formObject, field); diff --git a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js index b517e40c..9e6218cc 100644 --- a/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js +++ b/lib/generators/solidus_braintree/install/templates/app/assets/javascripts/spree/frontend/solidus_braintree/hosted_form.js @@ -1,5 +1,6 @@ -SolidusBraintree.HostedForm = function(paymentMethodId) { +SolidusBraintree.HostedForm = function(paymentMethodId, useDataCollector) { this.paymentMethodId = paymentMethodId; + this.useDataCollector = useDataCollector; this.client = null; }; @@ -7,7 +8,7 @@ SolidusBraintree.HostedForm.prototype.initialize = function() { this.client = SolidusBraintree.createClient({ paymentMethodId: this.paymentMethodId, useThreeDSecure: (typeof(window.threeDSecureOptions) !== 'undefined'), - useDataCollector: true, + useDataCollector: this.useDataCollector, }); return this.client.initialize(). diff --git a/lib/generators/solidus_braintree/install/templates/app/views/checkouts/payment/_braintree.html.erb b/lib/generators/solidus_braintree/install/templates/app/views/checkouts/payment/_braintree.html.erb index 093b7ffd..5c597d07 100644 --- a/lib/generators/solidus_braintree/install/templates/app/views/checkouts/payment/_braintree.html.erb +++ b/lib/generators/solidus_braintree/install/templates/app/views/checkouts/payment/_braintree.html.erb @@ -7,7 +7,7 @@ <% end %> <% if current_store.braintree_configuration.credit_card? %> -
    +
    <%= render "spree/shared/braintree_hosted_fields", payment_method: payment_method %>
    <% end %> diff --git a/spec/models/solidus_braintree/source_spec.rb b/spec/models/solidus_braintree/source_spec.rb index 093bcdae..cfe31f72 100644 --- a/spec/models/solidus_braintree/source_spec.rb +++ b/spec/models/solidus_braintree/source_spec.rb @@ -537,4 +537,19 @@ it { is_expected.to be_falsy } end end + + describe "#device_data" do + let(:payment_source) { build(:solidus_braintree_source) } + + context "when blank on validation" do + before do + payment_source.device_data = "" + payment_source.valid? + end + + it "is set to nil" do + expect(payment_source.device_data).to be_nil + end + end + end end From e4ef8c108008455be349b0c8dedd15c3704c98ca Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Mar 2023 10:38:37 +0800 Subject: [PATCH 61/66] Move upgrading documentation to wiki --- README.md | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 08ff5273..b8959ece 100644 --- a/README.md +++ b/README.md @@ -22,46 +22,9 @@ bundle bundle exec rails g solidus_braintree:install ``` -## Naming is hard: from SolidusBraintree to SolidusPaypalBraintree and then back to SolidusBraintree +## Upgrading (including migration from SolidusPaypalBraintree) -This gem is the result of merging two gems: the original SolidusBraintree gem, which was deprecated in 2020, and the SolidusPaypalBraintree gem, which was written from scratch to replace it. The updated codebase is based solely on the SolidusPaypalBraintree code. However, we've renamed the gem back to SolidusBraintree to make it clear that it's backed by Braintree. The name also differentiates it from the official Solidus PayPal extension, SolidusPaypalCommercePlatform. - -Take note that for now we are keeping the `solidus_paypal_braintree` prefix for SolidusBraintree database tables. Renaming tables can be a potentially risky operation, and we wanted to reduce the friction in updating to v2.0.0. For details, please see https://github.com/solidusio/solidus_braintree/issues/101. - -## Upgrading from SolidusPaypalBraintree 1.2.0 to SolidusBraintree 2.0.0 - -The gem has undergone two major changes: 1) it's been renamed to SolidusBraintree, and 2) its frontend is now SolidusStarterFrontend. With those changes in mind, you'll need to: - -1. Change the gem in your Gemfile from `gem 'solidus_paypal_braintree'` to `gem 'solidus_braintree', '~> 2.0.0'`. You'll likely have references to `SolidusPaypalBraintree` in your app, so you may also need to require the `solidus_paypal_braintree` alias in your Gemfile, i.e. - - ```ruby - gem 'solidus_braintree', '~> 2.0.0'`, require: 'solidus_paypal_braintree' - ``` - -2. Break down the solidus gem, remove the `solidus_frontend` gem, and update the gems to 3.4.0. Thus, in your `Gemfile`, replace - - ```ruby - gem 'solidus' - ``` - - with - - ```ruby - gem 'solidus_core', '~> 3.4.0' - gem 'solidus_backend', '~> 3.4.0' - gem 'solidus_api', '~> 3.4.0' - gem 'solidus_sample', '~> 3.4.0' - ``` - -3. Install SolidusStarterFrontend by running `bin/rails app:template LOCATION=https://github.com/solidusio/solidus_starter_frontend/raw/v3.4/template.rb`. If you have any overridden `solidus_frontend` views, you'll need to manually update them to fit the new frontend. - -4. Run `bin/rails g solidus_braintree:install`. This will update some references to SolidusPaypalBraintree in your app. It will also add a data migration to update your database. - -Additionally, you can rename any other references to SolidusPaypalBraintree in your app to SolidusBraintree. This will fix any deprecation warnings that come with SolidusBraintree 2.0.0. - -## Here be dragons: upgrading from SolidusBraintree 1.2.0 - -Considering that SolidusBraintree 2.0.0 is based on the SolidusPaypalBraintree codebase, please be warned that migrating directly from SolidusBraintree 1.2.0 to 2.0.0 would lead to breaking changes. Since SolidusBraintree 1.x was already [deprecated](https://github.com/solidusio/solidus_braintree/tree/v1.x#deprecation-notice-warning-construction), we don't provide at the moment a ready-made solution for migrating from SolidusBraintree 1.2.0 to 2.0.0. +See https://github.com/solidusio/solidus_braintree/wiki/Upgrading. ## Basic Setup From 153ec6c5ee36e4b0df31fa4bb5edd888cd3623ec Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Mar 2023 11:08:34 +0800 Subject: [PATCH 62/66] Add section for Credit Cards payment method type --- README.md | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index b8959ece..9834faf5 100644 --- a/README.md +++ b/README.md @@ -301,27 +301,7 @@ information, which we've included by default. You're able to turn off the PayPal data collector on the payment method preferences if you desire. If you use static preferences, add `use_data_collector: false` to your initializer. -## Optional configuration - -### Accepting multiple currencies -The payment method also provides an optional preference `merchant_currency_map`. -This preference allows users to provide different Merchant Account Ids for -different currencies. If you only plan to accept payment in one currency, the -defaut Merchant Account Id will be used and you can omit this option. -An example of setting this preference can be found -[here](https://github.com/solidusio/solidus_braintree/blob/bf5fe0e154d38f7c498f1c54450bb4de7608ff04/spec/support/gateway_helpers.rb#L11-L13). - -In addition to this, you can also specify different PayPal accounts for each -currency by using the `paypal_payee_email_map` preference. If you only want -to use one PayPal account for all currencies, then you can ignore this option. -You can find an example of setting this preference [here](https://github.com/solidusio/solidus_braintree/blob/bf5fe0e154d38f7c498f1c54450bb4de7608ff04/spec/support/gateway_helpers.rb#L14-L16). - -### Default store configuration -The migrations for this gem will add a default configuration to all stores that -has each payment type disabled. It also adds a `before_create` callback to -`Spree::Store` that builds a default configuration. You can customize the -default configuration that gets created by overriding the private -`build_default_configuration` method on `Spree::Store`. +## Credit cards ### Hosted Fields Styling You can style the Braintree credit card fields by using the `credit_card_fields_style` preference on the payment method. The `credit_card_fields_style` will be passed to the `style` key when initializing the credit card fields. You can find more information about styling hosted fields can be found [here.](https://developers.braintreepayments.com/guides/hosted-fields/styling/javascript/v3) @@ -344,6 +324,28 @@ Once enabled, you can use the following card numbers to test 3DS 2 on your client side in sandbox: https://developers.braintreepayments.com/guides/3d-secure/migration/javascript/v3#client-side-sandbox-testing. +## Optional configuration + +### Accepting multiple currencies +The payment method also provides an optional preference `merchant_currency_map`. +This preference allows users to provide different Merchant Account Ids for +different currencies. If you only plan to accept payment in one currency, the +defaut Merchant Account Id will be used and you can omit this option. +An example of setting this preference can be found +[here](https://github.com/solidusio/solidus_braintree/blob/bf5fe0e154d38f7c498f1c54450bb4de7608ff04/spec/support/gateway_helpers.rb#L11-L13). + +In addition to this, you can also specify different PayPal accounts for each +currency by using the `paypal_payee_email_map` preference. If you only want +to use one PayPal account for all currencies, then you can ignore this option. +You can find an example of setting this preference [here](https://github.com/solidusio/solidus_braintree/blob/bf5fe0e154d38f7c498f1c54450bb4de7608ff04/spec/support/gateway_helpers.rb#L14-L16). + +### Default store configuration +The migrations for this gem will add a default configuration to all stores that +has each payment type disabled. It also adds a `before_create` callback to +`Spree::Store` that builds a default configuration. You can customize the +default configuration that gets created by overriding the private +`build_default_configuration` method on `Spree::Store`. + ## Testing To run the specs it is required to set the Braintree test account data in these environment variables: From bc5811ac6342826705daf6de4ffeb93143b65200 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 9 Mar 2023 10:14:13 +0800 Subject: [PATCH 63/66] Add links to the Braintree overview pages of the supported payment method types --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9834faf5..fb2807ae 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,12 @@ [![CircleCI](https://circleci.com/gh/solidusio/solidus_braintree.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_braintree) [![codecov](https://codecov.io/gh/solidusio/solidus_braintree/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_braintree) -`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 supports Apple Pay, PayPal, and credit card transactions. +`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: + +* [Apple Pay](https://developer.paypal.com/braintree/docs/guides/apple-pay/overview) +* [Venmo](https://developer.paypal.com/braintree/docs/guides/venmo/overview) +* [PayPal Checkout](https://developer.paypal.com/braintree/docs/guides/paypal/overview/javascript/v3) +* [Credit Cards](https://developer.paypal.com/braintree/docs/guides/credit-cards/overview) via [Hosted Forms](https://developer.paypal.com/braintree/docs/guides/hosted-fields/overview) 🚧 This extension is currently only compatible with the `solidus_starter_frontend` 🚧 From 00b95a562a6da3a0b939e2cc097977f2fb7a3058 Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Tue, 14 Mar 2023 10:00:06 +0800 Subject: [PATCH 64/66] Replace solidus_starter_frontend compatibility warning with compatibility section --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb2807ae..83f18265 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,6 @@ * [PayPal Checkout](https://developer.paypal.com/braintree/docs/guides/paypal/overview/javascript/v3) * [Credit Cards](https://developer.paypal.com/braintree/docs/guides/credit-cards/overview) via [Hosted Forms](https://developer.paypal.com/braintree/docs/guides/hosted-fields/overview) -🚧 This extension is currently only compatible with the `solidus_starter_frontend` 🚧 - ## Installation Add solidus_braintree to your Gemfile: @@ -31,6 +29,20 @@ bundle exec rails g solidus_braintree:install See https://github.com/solidusio/solidus_braintree/wiki/Upgrading. +## Compatibility + +Here are the versions of SolidusBraintree and their compatible Solidus and frontend versions: + +| Version | Maintenance Status | Frontend | Branch | +|----------------------|-----------------------------|------------------------|----------| +| SolidusBraintree 3.0 | New features | SolidusStarterFrontend | [master] | +| SolidusBraintree 2.0 | Security patches, bug fixes | SolidusFrontend | [v2.x] | +| SolidusBraintree 1.2 | Deprecated | SolidusFrontend | [v1.x] | + +[v1.x]: https://github.com/solidusio/solidus_braintree/tree/v1.x +[v2.x]: https://github.com/solidusio/solidus_braintree/tree/v2.x +[master]: https://github.com/solidusio/solidus_braintree/tree/master + ## Basic Setup ### Retrieve Braintree account details From 0710a635cb44783e70b20740d5af538945e332ae Mon Sep 17 00:00:00 2001 From: George Mendoza Date: Thu, 16 Mar 2023 15:57:33 +0800 Subject: [PATCH 65/66] Fix: last version supporting SolidusFrontend should be 2.x Closes https://github.com/solidusio/solidus_braintree/issues/136. --- lib/generators/solidus_braintree/install/install_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/solidus_braintree/install/install_generator.rb b/lib/generators/solidus_braintree/install/install_generator.rb index c822693a..5893457d 100644 --- a/lib/generators/solidus_braintree/install/install_generator.rb +++ b/lib/generators/solidus_braintree/install/install_generator.rb @@ -139,7 +139,7 @@ def install_solidus_starter_frontend_support def alert_no_classic_frontend_support support_code_for(:classic_frontend) do message = <<~TEXT - For solidus_frontend compatibility, please use the deprecated version 1.x. + For solidus_frontend compatibility, please use version 2.x. The new version of this extension only supports Solidus Starter Frontend. No frontend code has been copied to your application. TEXT From 44018eaea19a75cb3b252cac22407721772c6446 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Wed, 29 Mar 2023 10:05:12 +0200 Subject: [PATCH 66/66] Release v3.0.0 --- CHANGELOG.md | 438 ++++++++++--------------------- lib/solidus_braintree/version.rb | 2 +- 2 files changed, 140 insertions(+), 300 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0561ba8..3c8b503e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,358 +1,198 @@ # Changelog -## [v1.2.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.2.0) (2022-12-12) +## [v3.0.0](https://github.com/solidusio/solidus_braintree/tree/v3.0.0) (2023-03-29) -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v1.1.2...v1.2.0) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v2.0.0...v3.0.0) -**Fixed bugs:** +**Implemented enhancements:** -- Sandbox script is not able to install bundle due to empty $BRANCH value [\#337](https://github.com/solidusio/solidus_paypal_braintree/issues/337) -- Do not safeguard including of Spree::Preferences::Persistable [\#316](https://github.com/solidusio/solidus_paypal_braintree/pull/316) ([tvdeyen](https://github.com/tvdeyen)) +- Release SolidusBraintree 2.0.0 [\#130](https://github.com/solidusio/solidus_braintree/issues/130) **Merged pull requests:** -- Update to the latest dev-support defaults [\#339](https://github.com/solidusio/solidus_paypal_braintree/pull/339) ([elia](https://github.com/elia)) -- 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)) -- Fix sandbox generator [\#329](https://github.com/solidusio/solidus_paypal_braintree/pull/329) ([RyanofWoods](https://github.com/RyanofWoods)) -- Fix broken specs [\#328](https://github.com/solidusio/solidus_paypal_braintree/pull/328) ([RyanofWoods](https://github.com/RyanofWoods)) -- Drop compatibility with Solidus \< 2.4 [\#326](https://github.com/solidusio/solidus_paypal_braintree/pull/326) ([mamhoff](https://github.com/mamhoff)) -- Add BIN \(bank identification number\) to SolidusPaypalBraintree::Source [\#308](https://github.com/solidusio/solidus_paypal_braintree/pull/308) ([RyanofWoods](https://github.com/RyanofWoods)) -- Improve README PayPal styling information [\#307](https://github.com/solidusio/solidus_paypal_braintree/pull/307) ([RyanofWoods](https://github.com/RyanofWoods)) -- Make extension compliant to solidus\_dev\_support [\#289](https://github.com/solidusio/solidus_paypal_braintree/pull/289) ([MinasMazar](https://github.com/MinasMazar)) +- Fix: last version supporting SolidusFrontend should be 2.x [\#137](https://github.com/solidusio/solidus_braintree/pull/137) ([gsmendoza](https://github.com/gsmendoza)) +- Fix: user should still be able to disable data collection in a SolidusBraintree hosted form [\#129](https://github.com/solidusio/solidus_braintree/pull/129) ([gsmendoza](https://github.com/gsmendoza)) +- Improve SolidusBraintree README [\#125](https://github.com/solidusio/solidus_braintree/pull/125) ([gsmendoza](https://github.com/gsmendoza)) +- Fix: deprecated version in warning should be 1.x instead of 0.x [\#118](https://github.com/solidusio/solidus_braintree/pull/118) ([gsmendoza](https://github.com/gsmendoza)) +- Migrate database by default [\#117](https://github.com/solidusio/solidus_braintree/pull/117) ([gsmendoza](https://github.com/gsmendoza)) +- Add device data collection [\#116](https://github.com/solidusio/solidus_braintree/pull/116) ([gsmendoza](https://github.com/gsmendoza)) +- Update Solidus dependency to \>= 3.4.0.dev and \< 4 [\#114](https://github.com/solidusio/solidus_braintree/pull/114) ([gsmendoza](https://github.com/gsmendoza)) +- Update SolidusBraintree InstallGenerator to install frontend code [\#112](https://github.com/solidusio/solidus_braintree/pull/112) ([gsmendoza](https://github.com/gsmendoza)) +- Deep stringify the keys of the result params [\#111](https://github.com/solidusio/solidus_braintree/pull/111) ([gsmendoza](https://github.com/gsmendoza)) +- Add Response to log entry permitted classes [\#109](https://github.com/solidusio/solidus_braintree/pull/109) ([gsmendoza](https://github.com/gsmendoza)) +- Make Solidus Braintree compatible with Starter Frontend [\#102](https://github.com/solidusio/solidus_braintree/pull/102) ([gsmendoza](https://github.com/gsmendoza)) +- Make migrations independent of existing models [\#100](https://github.com/solidusio/solidus_braintree/pull/100) ([elia](https://github.com/elia)) +- Update the SolidusPaypalBraintree namespace to SolidusBraintree [\#99](https://github.com/solidusio/solidus_braintree/pull/99) ([gsmendoza](https://github.com/gsmendoza)) +- Merge the history of Solidus PayPal Braintree into this repository [\#98](https://github.com/solidusio/solidus_braintree/pull/98) ([gsmendoza](https://github.com/gsmendoza)) +- Add stale bot [\#89](https://github.com/solidusio/solidus_braintree/pull/89) ([gsmendoza](https://github.com/gsmendoza)) +- Update to use forked solidus\_frontend when needed [\#88](https://github.com/solidusio/solidus_braintree/pull/88) ([waiting-for-dev](https://github.com/waiting-for-dev)) +- Add deprecation notice to README [\#87](https://github.com/solidusio/solidus_braintree/pull/87) ([seand7565](https://github.com/seand7565)) +- Adopt CircleCI instead of Travis [\#85](https://github.com/solidusio/solidus_braintree/pull/85) ([aldesantis](https://github.com/aldesantis)) +- Suggest setting a value for environment preference [\#82](https://github.com/solidusio/solidus_braintree/pull/82) ([mdesantis](https://github.com/mdesantis)) +- Test suite improvements [\#80](https://github.com/solidusio/solidus_braintree/pull/80) ([aitbw](https://github.com/aitbw)) +- Extension maintenance [\#78](https://github.com/solidusio/solidus_braintree/pull/78) ([aitbw](https://github.com/aitbw)) +- Fix references to Spree.t [\#77](https://github.com/solidusio/solidus_braintree/pull/77) ([skukx](https://github.com/skukx)) +- Remove 2.2 from CI \(EOL\) [\#71](https://github.com/solidusio/solidus_braintree/pull/71) ([jacobherrington](https://github.com/jacobherrington)) +- Fix Travis issue with Solidus old versions \(Factory Bot gem\) [\#70](https://github.com/solidusio/solidus_braintree/pull/70) ([spaghetticode](https://github.com/spaghetticode)) +- Remove versions past EOL from .travis.yml [\#69](https://github.com/solidusio/solidus_braintree/pull/69) ([jacobherrington](https://github.com/jacobherrington)) +- Add Solidus 2.7 to .travis.yml [\#68](https://github.com/solidusio/solidus_braintree/pull/68) ([jacobherrington](https://github.com/jacobherrington)) + +## [v2.0.0](https://github.com/solidusio/solidus_braintree/tree/v2.0.0) (2023-03-17) + +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v1.2.0...v2.0.0) -## [v1.1.2](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.1.2) (2022-10-14) +**Implemented enhancements:** -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v1.1.1...v1.1.2) +- Backport SolidusBraintree README changes to v2.x [\#131](https://github.com/solidusio/solidus_braintree/issues/131) +- Release SolidusBraintree 1.3 [\#127](https://github.com/solidusio/solidus_braintree/issues/127) +- Add overview to SolidusBraintree README [\#123](https://github.com/solidusio/solidus_braintree/issues/123) +- Add device data collection [\#115](https://github.com/solidusio/solidus_braintree/issues/115) +- Set Solidus dependency of SolidusBraintree to `> 3.4.0.dev, < 4` [\#113](https://github.com/solidusio/solidus_braintree/issues/113) +- Port device data collection from 1.x to 2.x [\#107](https://github.com/solidusio/solidus_braintree/issues/107) +- Support PayPal through frontend [\#26](https://github.com/solidusio/solidus_braintree/issues/26) -**Merged pull requests:** +**Fixed bugs:** -- Fix broken factory [\#325](https://github.com/solidusio/solidus_paypal_braintree/pull/325) ([johnpitchko](https://github.com/johnpitchko)) -- 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)) -- Fix specs to stub spree\_current\_user [\#323](https://github.com/solidusio/solidus_paypal_braintree/pull/323) ([gsmendoza](https://github.com/gsmendoza)) -- Bump Rubocop TargetRubyVersion from 2.5 to 2.6 [\#319](https://github.com/solidusio/solidus_paypal_braintree/pull/319) ([RyanofWoods](https://github.com/RyanofWoods)) -- Fix exception when other payment methods active [\#318](https://github.com/solidusio/solidus_paypal_braintree/pull/318) ([embold-tyler](https://github.com/embold-tyler)) +- Fix: user should still be able to disable data collection in a SolidusBraintree hosted form [\#126](https://github.com/solidusio/solidus_braintree/issues/126) +- Fix Spree::LogEntry::DisallowedClass error for failed responses [\#110](https://github.com/solidusio/solidus_braintree/issues/110) +- Fix Spree::LogEntry::DisallowedClass error [\#108](https://github.com/solidusio/solidus_braintree/issues/108) -## [v1.1.1](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.1.1) (2022-06-30) +**Closed issues:** -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v1.1.0...v1.1.1) +- Fix: last version supporting SolidusFrontend should be 2.x instead of 1.x [\#136](https://github.com/solidusio/solidus_braintree/issues/136) +- Test SolidusBraintree SSF update with Venmo Pay [\#106](https://github.com/solidusio/solidus_braintree/issues/106) +- Update SolidusBraintree InstallGenerator to install frontend code [\#104](https://github.com/solidusio/solidus_braintree/issues/104) +- Release SolidusBraintree 1.3.0 [\#97](https://github.com/solidusio/solidus_braintree/issues/97) +- Update the SolidusPaypalBraintree namespace to SolidusBraintree [\#96](https://github.com/solidusio/solidus_braintree/issues/96) +- Merge the history of Solidus PayPal Braintree into this repository [\#92](https://github.com/solidusio/solidus_braintree/issues/92) +- Make Solidus Braintree compatible with Starter Frontend [\#91](https://github.com/solidusio/solidus_braintree/issues/91) +- Merge with `solidus_paypal_braintree` [\#90](https://github.com/solidusio/solidus_braintree/issues/90) +- Fix Deprecation warnings for use of Spree.t [\#76](https://github.com/solidusio/solidus_braintree/issues/76) +- New VCR specs with paypal fail [\#75](https://github.com/solidusio/solidus_braintree/issues/75) +- Drop-in Ui [\#73](https://github.com/solidusio/solidus_braintree/issues/73) +- Configure Solidus Braintree with Paypal Braintree SDK Token [\#67](https://github.com/solidusio/solidus_braintree/issues/67) +- Authenticate the payment client token endpoint [\#66](https://github.com/solidusio/solidus_braintree/issues/66) +- Is 3D Secure supported? [\#64](https://github.com/solidusio/solidus_braintree/issues/64) +- Deface Override requires solidus\_frontend [\#57](https://github.com/solidusio/solidus_braintree/issues/57) +- Allow to optionally create token with `customer_id` option [\#56](https://github.com/solidusio/solidus_braintree/issues/56) +- Guest checkout tries to create a customer profile [\#37](https://github.com/solidusio/solidus_braintree/issues/37) +- Use of undefined show\_flash function in frontend [\#31](https://github.com/solidusio/solidus_braintree/issues/31) +- Select an implementation for how to store non credit card data in Solidus [\#3](https://github.com/solidusio/solidus_braintree/issues/3) + +## [v1.2.0](https://github.com/solidusio/solidus_braintree/tree/v1.2.0) (2018-05-25) + +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v1.1.0...v1.2.0) **Closed issues:** -- StateMachines::InvalidTransition: Cannot transition state via :invalidate from :checkout \(Reason\(s\): Payment method can't be blank\) [\#320](https://github.com/solidusio/solidus_paypal_braintree/issues/320) -- Enable Venmo [\#304](https://github.com/solidusio/solidus_paypal_braintree/issues/304) -- Make the Venmo button testable from outside US contries [\#303](https://github.com/solidusio/solidus_paypal_braintree/issues/303) +- Undefined local variable or method `solidus\_paypal\_braintree' [\#62](https://github.com/solidusio/solidus_braintree/issues/62) +- Solidus 1.3 Admin UI changes breaking New Card form [\#48](https://github.com/solidusio/solidus_braintree/issues/48) **Merged pull requests:** -- Make gem compatible with Rails 7 [\#321](https://github.com/solidusio/solidus_paypal_braintree/pull/321) ([gsmendoza](https://github.com/gsmendoza)) -- Rubocop -a on spec files [\#317](https://github.com/solidusio/solidus_paypal_braintree/pull/317) ([tvdeyen](https://github.com/tvdeyen)) -- Add email to Braintree customer [\#310](https://github.com/solidusio/solidus_paypal_braintree/pull/310) ([RyanofWoods](https://github.com/RyanofWoods)) - -## [v1.1.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.1.0) (2022-02-01) +- Specify Rails versions in Gemfile [\#63](https://github.com/solidusio/solidus_braintree/pull/63) ([jhawthorn](https://github.com/jhawthorn)) +- Re-record failing VCR cassettes [\#61](https://github.com/solidusio/solidus_braintree/pull/61) ([jhawthorn](https://github.com/jhawthorn)) +- Revert "Ignore AVS response code in Paypal transactions." [\#60](https://github.com/solidusio/solidus_braintree/pull/60) ([jhawthorn](https://github.com/jhawthorn)) +- Fixes link to Braintree v.zero docs [\#59](https://github.com/solidusio/solidus_braintree/pull/59) ([tvdeyen](https://github.com/tvdeyen)) +- Download PhantomJS from github mirror [\#58](https://github.com/solidusio/solidus_braintree/pull/58) ([jhawthorn](https://github.com/jhawthorn)) +- Add --ssl-protocol=any to phantomjs\_options [\#55](https://github.com/solidusio/solidus_braintree/pull/55) ([jhawthorn](https://github.com/jhawthorn)) +- Fix spec failures due to missing address last\_name [\#54](https://github.com/solidusio/solidus_braintree/pull/54) ([jhawthorn](https://github.com/jhawthorn)) +- Ignore AVS response code in Paypal transactions. [\#36](https://github.com/solidusio/solidus_braintree/pull/36) ([hectoregm](https://github.com/hectoregm)) -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v1.0.0...v1.1.0) +## [v1.1.0](https://github.com/solidusio/solidus_braintree/tree/v1.1.0) (2016-09-22) -**Closed issues:** - -- solidus-frontend dependency still exists [\#294](https://github.com/solidusio/solidus_paypal_braintree/issues/294) -- Could we get a new release? [\#259](https://github.com/solidusio/solidus_paypal_braintree/issues/259) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v1.0.0...v1.1.0) **Merged pull requests:** -- Lower ActiveRecord::Migration version in add\_paypal\_funding\_source [\#314](https://github.com/solidusio/solidus_paypal_braintree/pull/314) ([mamhoff](https://github.com/mamhoff)) -- Fix rubocop warnings [\#313](https://github.com/solidusio/solidus_paypal_braintree/pull/313) ([mamhoff](https://github.com/mamhoff)) -- Add skip\_avs and skip\_cvv AVS Result Mapping [\#312](https://github.com/solidusio/solidus_paypal_braintree/pull/312) ([mamhoff](https://github.com/mamhoff)) -- Integrate Braintree Venmo [\#311](https://github.com/solidusio/solidus_paypal_braintree/pull/311) ([RyanofWoods](https://github.com/RyanofWoods)) -- Require MFA for RubyGems actions [\#306](https://github.com/solidusio/solidus_paypal_braintree/pull/306) ([RyanofWoods](https://github.com/RyanofWoods)) -- Add Venmo as a PayPal funding option for checkout [\#305](https://github.com/solidusio/solidus_paypal_braintree/pull/305) ([RyanofWoods](https://github.com/RyanofWoods)) -- Update PayPal configuration steps in README [\#300](https://github.com/solidusio/solidus_paypal_braintree/pull/300) ([RyanofWoods](https://github.com/RyanofWoods)) -- Update to Braintree 3.4.0 [\#299](https://github.com/solidusio/solidus_paypal_braintree/pull/299) ([pelargir](https://github.com/pelargir)) -- Remove remaining frontend dependencies [\#296](https://github.com/solidusio/solidus_paypal_braintree/pull/296) ([Rtwena](https://github.com/Rtwena)) -- Set sandbox mode if environment is sandbox [\#291](https://github.com/solidusio/solidus_paypal_braintree/pull/291) ([alexblackie](https://github.com/alexblackie)) -- Update to Solidus 3.0 [\#286](https://github.com/solidusio/solidus_paypal_braintree/pull/286) ([MinasMazar](https://github.com/MinasMazar)) -- Added 3ds errors in it locale [\#285](https://github.com/solidusio/solidus_paypal_braintree/pull/285) ([thomasrossetto](https://github.com/thomasrossetto)) -- Make use of data collector in JS configurable [\#238](https://github.com/solidusio/solidus_paypal_braintree/pull/238) ([mamhoff](https://github.com/mamhoff)) +- Add support for Solidus 2.0 and Rails 5.0 [\#51](https://github.com/solidusio/solidus_braintree/pull/51) ([jhawthorn](https://github.com/jhawthorn)) +- Spec to test new card [\#50](https://github.com/solidusio/solidus_braintree/pull/50) ([Murph33](https://github.com/Murph33)) +- Add config to disable ship address verification [\#47](https://github.com/solidusio/solidus_braintree/pull/47) ([gmacdougall](https://github.com/gmacdougall)) +- Add support for cancel [\#45](https://github.com/solidusio/solidus_braintree/pull/45) ([gmacdougall](https://github.com/gmacdougall)) -## [v1.0.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v1.0.0) (2020-11-11) +## [v1.0.0](https://github.com/solidusio/solidus_braintree/tree/v1.0.0) (2016-06-24) -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v0.4.0...v1.0.0) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.2.1...v1.0.0) -**Implemented enhancements:** +**Closed issues:** -- Respect Spree::Config\[:address\_requires\_state\] setting in frontend view rendering [\#93](https://github.com/solidusio/solidus_paypal_braintree/issues/93) +- Use Braintree Hosted Fields in frontend checkout [\#27](https://github.com/solidusio/solidus_braintree/issues/27) +- Not using v.zero SDK [\#14](https://github.com/solidusio/solidus_braintree/issues/14) -**Closed issues:** +**Merged pull requests:** -- Make the PayPal messaging component a bit more modular [\#281](https://github.com/solidusio/solidus_paypal_braintree/issues/281) -- Error launching migrations [\#262](https://github.com/solidusio/solidus_paypal_braintree/issues/262) -- Refunds not allowed after a PayPal dispute has been resolved [\#256](https://github.com/solidusio/solidus_paypal_braintree/issues/256) -- Spree::Core::GatewayError generates error [\#254](https://github.com/solidusio/solidus_paypal_braintree/issues/254) -- Paypal button preference helper not found [\#251](https://github.com/solidusio/solidus_paypal_braintree/issues/251) -- Installer breaks during migration [\#244](https://github.com/solidusio/solidus_paypal_braintree/issues/244) -- Some card unsuccessful verification numbers are accepted and marked as paid [\#241](https://github.com/solidusio/solidus_paypal_braintree/issues/241) -- PayPal button: customize style [\#229](https://github.com/solidusio/solidus_paypal_braintree/issues/229) -- On PayPal payment user shipping address gets set with uncorrect firstname and lastname values if they contain a space [\#226](https://github.com/solidusio/solidus_paypal_braintree/issues/226) -- Default Braintree configuration on store creation overwrites custom configuration [\#224](https://github.com/solidusio/solidus_paypal_braintree/issues/224) -- Undefined local variable or method `id' error on payment page [\#222](https://github.com/solidusio/solidus_paypal_braintree/issues/222) -- Can't render JSON about an order as SolidusPaypalBraintree::Source doesn't have a `expiration_month` method [\#221](https://github.com/solidusio/solidus_paypal_braintree/issues/221) -- Paypal payment return invalid address [\#218](https://github.com/solidusio/solidus_paypal_braintree/issues/218) -- Random Travis CI Failures [\#215](https://github.com/solidusio/solidus_paypal_braintree/issues/215) -- Add Association for spree user to customer [\#210](https://github.com/solidusio/solidus_paypal_braintree/issues/210) -- Ambiguous behavior for generate token method [\#208](https://github.com/solidusio/solidus_paypal_braintree/issues/208) -- Unable to pass specs locally when developing for gem [\#207](https://github.com/solidusio/solidus_paypal_braintree/issues/207) -- Nonce payment sources should not be reusable [\#203](https://github.com/solidusio/solidus_paypal_braintree/issues/203) -- Save and Continue button disabled for credit card payments - Rails 5.2.0 [\#202](https://github.com/solidusio/solidus_paypal_braintree/issues/202) -- when only using PayPal invalid address on return [\#195](https://github.com/solidusio/solidus_paypal_braintree/issues/195) -- Unable to set preference source [\#194](https://github.com/solidusio/solidus_paypal_braintree/issues/194) -- hard dependency on solidus instead of just solidus\_core [\#187](https://github.com/solidusio/solidus_paypal_braintree/issues/187) -- patch release 0.4.1 [\#186](https://github.com/solidusio/solidus_paypal_braintree/issues/186) -- Amount must be greater than zero. \(81531\) [\#185](https://github.com/solidusio/solidus_paypal_braintree/issues/185) -- ActiveRecord::SubclassNotFound [\#184](https://github.com/solidusio/solidus_paypal_braintree/issues/184) -- state: '\#{address.state.name}' undefined for Hong Kong address \(or countries with no states\) [\#182](https://github.com/solidusio/solidus_paypal_braintree/issues/182) -- ReferenceError: braintree is not defined [\#181](https://github.com/solidusio/solidus_paypal_braintree/issues/181) -- Page refreshes from payment -\> confirm step [\#172](https://github.com/solidusio/solidus_paypal_braintree/issues/172) -- Creditcard fields are readonly [\#171](https://github.com/solidusio/solidus_paypal_braintree/issues/171) -- Solidus 2.6 requires spree/api/payments/source\_views/\_paypal\_braintree.json.jbuilder [\#167](https://github.com/solidusio/solidus_paypal_braintree/issues/167) -- Will there be a integration of 3D Secure soon? [\#162](https://github.com/solidusio/solidus_paypal_braintree/issues/162) -- Products invisible in Admin Order view / Crash in the log [\#159](https://github.com/solidusio/solidus_paypal_braintree/issues/159) -- Invalid transactions, NoMethodError \(strip\) when cancelling order with invalid payment [\#158](https://github.com/solidusio/solidus_paypal_braintree/issues/158) -- NoMethodError in Spree::Checkout\#edit when address.state == nil [\#156](https://github.com/solidusio/solidus_paypal_braintree/issues/156) -- Cancel PayPal order causes 500 error [\#155](https://github.com/solidusio/solidus_paypal_braintree/issues/155) -- Silent failure after payment [\#153](https://github.com/solidusio/solidus_paypal_braintree/issues/153) -- Undefined local variable or method `solidus\_paypal\_braintree' [\#152](https://github.com/solidusio/solidus_paypal_braintree/issues/152) -- Braintree Callback Webhooks Supported? [\#148](https://github.com/solidusio/solidus_paypal_braintree/issues/148) -- Missing partial spree/checkout/existing\_payment/\_paypal\_braintree [\#135](https://github.com/solidusio/solidus_paypal_braintree/issues/135) -- No route if the engine is not mounted in Solidus path [\#134](https://github.com/solidusio/solidus_paypal_braintree/issues/134) -- Allow passing of styles and placeholder text into braintree hosted fields [\#121](https://github.com/solidusio/solidus_paypal_braintree/issues/121) -- When spree javascript is included at bottom of page, checkout fails [\#119](https://github.com/solidusio/solidus_paypal_braintree/issues/119) -- Document "Paypal Payee Email Map" [\#103](https://github.com/solidusio/solidus_paypal_braintree/issues/103) -- Disable backend CC submit button until ready [\#102](https://github.com/solidusio/solidus_paypal_braintree/issues/102) -- Documentation improvements [\#92](https://github.com/solidusio/solidus_paypal_braintree/issues/92) +- Change solidus dependency to components [\#44](https://github.com/solidusio/solidus_braintree/pull/44) ([gmacdougall](https://github.com/gmacdougall)) +- Add placeholder text for each of the credit card inputs. [\#40](https://github.com/solidusio/solidus_braintree/pull/40) ([hectoregm](https://github.com/hectoregm)) +- Get client token from braintree only in the payment page. [\#39](https://github.com/solidusio/solidus_braintree/pull/39) ([hectoregm](https://github.com/hectoregm)) +- Fix tests [\#38](https://github.com/solidusio/solidus_braintree/pull/38) ([jhawthorn](https://github.com/jhawthorn)) +- Ensure device\_data is added to the gateway\_options hash. [\#35](https://github.com/solidusio/solidus_braintree/pull/35) ([hectoregm](https://github.com/hectoregm)) +- Paypal improvements [\#34](https://github.com/solidusio/solidus_braintree/pull/34) ([hectoregm](https://github.com/hectoregm)) +- Fraud hosted fields [\#32](https://github.com/solidusio/solidus_braintree/pull/32) ([hectoregm](https://github.com/hectoregm)) +- Add paypal button [\#30](https://github.com/solidusio/solidus_braintree/pull/30) ([jhawthorn](https://github.com/jhawthorn)) +- Use braintree's Hosted Fields [\#29](https://github.com/solidusio/solidus_braintree/pull/29) ([jhawthorn](https://github.com/jhawthorn)) +- Add feature spec for frontend checkout [\#25](https://github.com/solidusio/solidus_braintree/pull/25) ([jhawthorn](https://github.com/jhawthorn)) +- Update braintree-web to 2.23.0 [\#24](https://github.com/solidusio/solidus_braintree/pull/24) ([hectoregm](https://github.com/hectoregm)) +- Void payment in checkout state without authorization code [\#23](https://github.com/solidusio/solidus_braintree/pull/23) ([ericsaupe](https://github.com/ericsaupe)) +- Hosted Forms Frontend [\#22](https://github.com/solidusio/solidus_braintree/pull/22) ([ericsaupe](https://github.com/ericsaupe)) +- Cleanup dependencies [\#20](https://github.com/solidusio/solidus_braintree/pull/20) ([jhawthorn](https://github.com/jhawthorn)) +- Remove out.json [\#19](https://github.com/solidusio/solidus_braintree/pull/19) ([jhawthorn](https://github.com/jhawthorn)) +- Rebase \#9 [\#18](https://github.com/solidusio/solidus_braintree/pull/18) ([jhawthorn](https://github.com/jhawthorn)) +- Rebase \#11 [\#17](https://github.com/solidusio/solidus_braintree/pull/17) ([jhawthorn](https://github.com/jhawthorn)) +- MySQL support [\#16](https://github.com/solidusio/solidus_braintree/pull/16) ([jhawthorn](https://github.com/jhawthorn)) +- Update travis.yml [\#15](https://github.com/solidusio/solidus_braintree/pull/15) ([jhawthorn](https://github.com/jhawthorn)) + +## [v0.2.1](https://github.com/solidusio/solidus_braintree/tree/v0.2.1) (2015-11-03) + +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.2.0...v0.2.1) **Merged pull requests:** -- Add note about PayPal recommendations for messaging component [\#280](https://github.com/solidusio/solidus_paypal_braintree/pull/280) ([seand7565](https://github.com/seand7565)) -- Move decorators to the correct folders and add EngineExtensions [\#279](https://github.com/solidusio/solidus_paypal_braintree/pull/279) ([seand7565](https://github.com/seand7565)) -- Disable PayPal messaging when vault flow is enabled [\#278](https://github.com/solidusio/solidus_paypal_braintree/pull/278) ([seand7565](https://github.com/seand7565)) -- Fix deprecated solidus\_gem\_version reference in spec [\#277](https://github.com/solidusio/solidus_paypal_braintree/pull/277) ([pelargir](https://github.com/pelargir)) -- Allow user to specify style and placeholder\_text of hosted\_fields [\#276](https://github.com/solidusio/solidus_paypal_braintree/pull/276) ([seand7565](https://github.com/seand7565)) -- Add a PayPal messaging component partial [\#275](https://github.com/solidusio/solidus_paypal_braintree/pull/275) ([seand7565](https://github.com/seand7565)) -- Sanitize user address json for PayPal button [\#274](https://github.com/solidusio/solidus_paypal_braintree/pull/274) ([seand7565](https://github.com/seand7565)) -- Add PayPal messaging component to cart button partial [\#273](https://github.com/solidusio/solidus_paypal_braintree/pull/273) ([seand7565](https://github.com/seand7565)) -- Update transaction\_address to support name attribute [\#271](https://github.com/solidusio/solidus_paypal_braintree/pull/271) ([seand7565](https://github.com/seand7565)) -- Fix api source view path [\#270](https://github.com/solidusio/solidus_paypal_braintree/pull/270) ([seand7565](https://github.com/seand7565)) -- Add info about paypal\_payee\_map to readme [\#269](https://github.com/solidusio/solidus_paypal_braintree/pull/269) ([seand7565](https://github.com/seand7565)) -- Update rubocop definitions and fix violations [\#268](https://github.com/solidusio/solidus_paypal_braintree/pull/268) ([seand7565](https://github.com/seand7565)) -- Update to New PayPal SDK [\#267](https://github.com/solidusio/solidus_paypal_braintree/pull/267) ([seand7565](https://github.com/seand7565)) -- Fix Spree::Core lookup in gateway [\#266](https://github.com/solidusio/solidus_paypal_braintree/pull/266) ([seand7565](https://github.com/seand7565)) -- Move decorators out of models folder [\#265](https://github.com/solidusio/solidus_paypal_braintree/pull/265) ([seand7565](https://github.com/seand7565)) -- Fix 3DS testing [\#264](https://github.com/solidusio/solidus_paypal_braintree/pull/264) ([seand7565](https://github.com/seand7565)) -- Fix value conversion method [\#263](https://github.com/solidusio/solidus_paypal_braintree/pull/263) ([seand7565](https://github.com/seand7565)) -- Updated solidus\_support gem version [\#261](https://github.com/solidusio/solidus_paypal_braintree/pull/261) ([mustiag](https://github.com/mustiag)) -- Fix feature specs with new CC expiration date [\#253](https://github.com/solidusio/solidus_paypal_braintree/pull/253) ([MinasMazar](https://github.com/MinasMazar)) -- Fix Braintree checkout helpers [\#252](https://github.com/solidusio/solidus_paypal_braintree/pull/252) ([MinasMazar](https://github.com/MinasMazar)) -- Remove AddBraintreeConfigurationToStores migration [\#249](https://github.com/solidusio/solidus_paypal_braintree/pull/249) ([MinasMazar](https://github.com/MinasMazar)) -- Upgrade the extension using solidus\_dev\_support [\#248](https://github.com/solidusio/solidus_paypal_braintree/pull/248) ([blocknotes](https://github.com/blocknotes)) -- Update README.md [\#246](https://github.com/solidusio/solidus_paypal_braintree/pull/246) ([bazfer](https://github.com/bazfer)) -- Make http open and read timeouts configurable [\#245](https://github.com/solidusio/solidus_paypal_braintree/pull/245) ([tvdeyen](https://github.com/tvdeyen)) -- Add PayPal button customizable style also for cart page [\#243](https://github.com/solidusio/solidus_paypal_braintree/pull/243) ([MinasMazar](https://github.com/MinasMazar)) -- Respect vault/checkout configuration on cart paypal button [\#239](https://github.com/solidusio/solidus_paypal_braintree/pull/239) ([mamhoff](https://github.com/mamhoff)) -- Only add state if available in Paypal Checkout Button View [\#237](https://github.com/solidusio/solidus_paypal_braintree/pull/237) ([mamhoff](https://github.com/mamhoff)) -- Let PayPal button to receive locale/style parameters [\#236](https://github.com/solidusio/solidus_paypal_braintree/pull/236) ([MinasMazar](https://github.com/MinasMazar)) -- Fix shipping contact name for ApplePay [\#234](https://github.com/solidusio/solidus_paypal_braintree/pull/234) ([cedum](https://github.com/cedum)) -- Adopt CircleCI instead of Travis [\#233](https://github.com/solidusio/solidus_paypal_braintree/pull/233) ([aldesantis](https://github.com/aldesantis)) -- Introduce 3D Secure support for credit cards [\#232](https://github.com/solidusio/solidus_paypal_braintree/pull/232) ([cedum](https://github.com/cedum)) -- Update italian translations [\#230](https://github.com/solidusio/solidus_paypal_braintree/pull/230) ([delphaber](https://github.com/delphaber)) -- Skip building default config on config presence [\#225](https://github.com/solidusio/solidus_paypal_braintree/pull/225) ([mdesantis](https://github.com/mdesantis)) -- Fix undefined local variable or method `id' error [\#223](https://github.com/solidusio/solidus_paypal_braintree/pull/223) ([mdesantis](https://github.com/mdesantis)) -- Simplify Solidus Dependencies [\#220](https://github.com/solidusio/solidus_paypal_braintree/pull/220) ([gmacdougall](https://github.com/gmacdougall)) -- Extension maintenance [\#216](https://github.com/solidusio/solidus_paypal_braintree/pull/216) ([aitbw](https://github.com/aitbw)) -- Add byebug dependency [\#214](https://github.com/solidusio/solidus_paypal_braintree/pull/214) ([skukx](https://github.com/skukx)) -- Add API payment source view for Braintree payments [\#213](https://github.com/solidusio/solidus_paypal_braintree/pull/213) ([aldesantis](https://github.com/aldesantis)) -- Add association from user to customer [\#211](https://github.com/solidusio/solidus_paypal_braintree/pull/211) ([skukx](https://github.com/skukx)) -- Fix ambiguous behavior in generate\_token method [\#209](https://github.com/solidusio/solidus_paypal_braintree/pull/209) ([skukx](https://github.com/skukx)) -- Make nonce-only payment sources non-reusable [\#204](https://github.com/solidusio/solidus_paypal_braintree/pull/204) ([fastjames](https://github.com/fastjames)) -- Check for rails-ujs object when re-enabling button [\#201](https://github.com/solidusio/solidus_paypal_braintree/pull/201) ([masonjeffreys](https://github.com/masonjeffreys)) -- Allow null address Paypal payload [\#199](https://github.com/solidusio/solidus_paypal_braintree/pull/199) ([alepore](https://github.com/alepore)) -- Display Paypal setup errors on console [\#198](https://github.com/solidusio/solidus_paypal_braintree/pull/198) ([alepore](https://github.com/alepore)) -- Fix CI build [\#193](https://github.com/solidusio/solidus_paypal_braintree/pull/193) ([kennyadsl](https://github.com/kennyadsl)) -- Remove versions past EOL from .travis.yml [\#189](https://github.com/solidusio/solidus_paypal_braintree/pull/189) ([jacobherrington](https://github.com/jacobherrington)) -- Add Solidus 2.7 to .travis.yml [\#188](https://github.com/solidusio/solidus_paypal_braintree/pull/188) ([jacobherrington](https://github.com/jacobherrington)) -- Manage PAYPAL\_POPUP\_CLOSED JS error [\#183](https://github.com/solidusio/solidus_paypal_braintree/pull/183) ([spaghetticode](https://github.com/spaghetticode)) -- Add fields to match Spree::CreditCard's interface [\#180](https://github.com/solidusio/solidus_paypal_braintree/pull/180) ([adammathys](https://github.com/adammathys)) -- Add existing payments partial [\#175](https://github.com/solidusio/solidus_paypal_braintree/pull/175) ([alepore](https://github.com/alepore)) -- Fix error display [\#174](https://github.com/solidusio/solidus_paypal_braintree/pull/174) ([alepore](https://github.com/alepore)) -- Express Checkout support [\#168](https://github.com/solidusio/solidus_paypal_braintree/pull/168) ([aldesantis](https://github.com/aldesantis)) -- Update PayPal configuration instructions [\#164](https://github.com/solidusio/solidus_paypal_braintree/pull/164) ([kennyadsl](https://github.com/kennyadsl)) - -## [v0.4.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v0.4.0) (2018-07-20) - -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v0.3.0...v0.4.0) +- supply first and last name in shipping address [\#8](https://github.com/solidusio/solidus_braintree/pull/8) ([gvaughn](https://github.com/gvaughn)) -**Closed issues:** +## [v0.2.0](https://github.com/solidusio/solidus_braintree/tree/v0.2.0) (2015-09-17) -- Move from the deprecated paypal.js library to the current paypal-checkout.js library? [\#157](https://github.com/solidusio/solidus_paypal_braintree/issues/157) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.1.5...v0.2.0) **Merged pull requests:** -- Prepare 0.4.0 release. [\#179](https://github.com/solidusio/solidus_paypal_braintree/pull/179) ([snarfmason](https://github.com/snarfmason)) -- Remove Deface [\#178](https://github.com/solidusio/solidus_paypal_braintree/pull/178) ([snarfmason](https://github.com/snarfmason)) -- Update CI Ruby and specs config [\#177](https://github.com/solidusio/solidus_paypal_braintree/pull/177) ([alepore](https://github.com/alepore)) -- Fix Gateway\#try\_void expecting a respose code instead of a payment [\#173](https://github.com/solidusio/solidus_paypal_braintree/pull/173) ([aldesantis](https://github.com/aldesantis)) -- Update Braintree and PayPal libs [\#170](https://github.com/solidusio/solidus_paypal_braintree/pull/170) ([alepore](https://github.com/alepore)) -- Scope the payment method lookup to store when the id is unknown [\#150](https://github.com/solidusio/solidus_paypal_braintree/pull/150) ([dholdren](https://github.com/dholdren)) -- Restart checkout when cart Paypal button is used [\#144](https://github.com/solidusio/solidus_paypal_braintree/pull/144) ([alepore](https://github.com/alepore)) -- Set Braintree log level as a gateway preference [\#110](https://github.com/solidusio/solidus_paypal_braintree/pull/110) ([isaacfreeman](https://github.com/isaacfreeman)) +- Update braintree-web to 2.14.0 [\#7](https://github.com/solidusio/solidus_braintree/pull/7) ([kamui](https://github.com/kamui)) +- Make Spree::CreditCard more flexible for handling paypal payments by … [\#6](https://github.com/solidusio/solidus_braintree/pull/6) ([allisonlarson](https://github.com/allisonlarson)) -## [v0.3.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v0.3.0) (2018-05-25) +## [v0.1.5](https://github.com/solidusio/solidus_braintree/tree/v0.1.5) (2015-09-08) -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v0.2.0...v0.3.0) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.1.4...v0.1.5) -**Closed issues:** +## [v0.1.4](https://github.com/solidusio/solidus_braintree/tree/v0.1.4) (2015-09-08) -- Using Only PayPal [\#166](https://github.com/solidusio/solidus_paypal_braintree/issues/166) -- Handle changed address from Paypal [\#163](https://github.com/solidusio/solidus_paypal_braintree/issues/163) -- ActiveRecord::SubclassNotFound after trying to save payment gateway record [\#147](https://github.com/solidusio/solidus_paypal_braintree/issues/147) -- uninitialized constant AVSResult [\#137](https://github.com/solidusio/solidus_paypal_braintree/issues/137) -- Missing partial spree/admin/shared/preference\_fields/\_hash [\#132](https://github.com/solidusio/solidus_paypal_braintree/issues/132) -- Allow sources to be added to the wallet on charge [\#122](https://github.com/solidusio/solidus_paypal_braintree/issues/122) -- Address deprecation warnings [\#108](https://github.com/solidusio/solidus_paypal_braintree/issues/108) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.1.3...v0.1.4) **Merged pull requests:** -- Remove unmaintained Solidus versions from the build matrix [\#169](https://github.com/solidusio/solidus_paypal_braintree/pull/169) ([aldesantis](https://github.com/aldesantis)) -- Specify bourbon \<5 [\#146](https://github.com/solidusio/solidus_paypal_braintree/pull/146) ([jhawthorn](https://github.com/jhawthorn)) -- Use latest Bundler while building [\#145](https://github.com/solidusio/solidus_paypal_braintree/pull/145) ([tvdeyen](https://github.com/tvdeyen)) -- Recalculate payment total when order total decreases [\#142](https://github.com/solidusio/solidus_paypal_braintree/pull/142) ([dholdren](https://github.com/dholdren)) -- Update TransactionAddress\#state\_code validation [\#141](https://github.com/solidusio/solidus_paypal_braintree/pull/141) ([alepore](https://github.com/alepore)) -- Remove Transaction\#phone validation [\#140](https://github.com/solidusio/solidus_paypal_braintree/pull/140) ([alepore](https://github.com/alepore)) -- Rescue Braintree void errors and refund instead [\#139](https://github.com/solidusio/solidus_paypal_braintree/pull/139) ([tvdeyen](https://github.com/tvdeyen)) -- fix uninitialized constant AVSResult \#137 [\#138](https://github.com/solidusio/solidus_paypal_braintree/pull/138) ([afdev82](https://github.com/afdev82)) -- Add a partial for the hash preference field [\#136](https://github.com/solidusio/solidus_paypal_braintree/pull/136) ([tvdeyen](https://github.com/tvdeyen)) -- Support 18n for Braintree error messages [\#133](https://github.com/solidusio/solidus_paypal_braintree/pull/133) ([vassalloandrea](https://github.com/vassalloandrea)) -- Follow the factory\_bot rename [\#131](https://github.com/solidusio/solidus_paypal_braintree/pull/131) ([tvdeyen](https://github.com/tvdeyen)) -- Pend paypal spec if paypal popup not available [\#130](https://github.com/solidusio/solidus_paypal_braintree/pull/130) ([tvdeyen](https://github.com/tvdeyen)) -- Add more versions and test both DBs on travis [\#129](https://github.com/solidusio/solidus_paypal_braintree/pull/129) ([jhawthorn](https://github.com/jhawthorn)) -- Use the shared spec\_helper from solidus\_support [\#128](https://github.com/solidusio/solidus_paypal_braintree/pull/128) ([tvdeyen](https://github.com/tvdeyen)) -- Try to harden the PayPal integration spec [\#127](https://github.com/solidusio/solidus_paypal_braintree/pull/127) ([tvdeyen](https://github.com/tvdeyen)) -- Protect against connection errors [\#126](https://github.com/solidusio/solidus_paypal_braintree/pull/126) ([tvdeyen](https://github.com/tvdeyen)) -- Adding ffaker as test dependency [\#125](https://github.com/solidusio/solidus_paypal_braintree/pull/125) ([tvdeyen](https://github.com/tvdeyen)) -- Rescue Braintree::NotFound errors in source display methods [\#124](https://github.com/solidusio/solidus_paypal_braintree/pull/124) ([tvdeyen](https://github.com/tvdeyen)) -- Allows the paypal\_braintree source to be added to the wallet on checkout [\#123](https://github.com/solidusio/solidus_paypal_braintree/pull/123) ([joeljackson](https://github.com/joeljackson)) -- Update braintree client libs to v3.22.1 [\#118](https://github.com/solidusio/solidus_paypal_braintree/pull/118) ([tvdeyen](https://github.com/tvdeyen)) -- Minor improvements to README.md [\#117](https://github.com/solidusio/solidus_paypal_braintree/pull/117) ([isaacfreeman](https://github.com/isaacfreeman)) -- Better error handling [\#115](https://github.com/solidusio/solidus_paypal_braintree/pull/115) ([tvdeyen](https://github.com/tvdeyen)) -- Fix the address retrieval on the PayPal payload [\#112](https://github.com/solidusio/solidus_paypal_braintree/pull/112) ([tvdeyen](https://github.com/tvdeyen)) -- Fix deprecated code [\#111](https://github.com/solidusio/solidus_paypal_braintree/pull/111) ([isaacfreeman](https://github.com/isaacfreeman)) -- Use transaction status to decide if payment can\_void? [\#109](https://github.com/solidusio/solidus_paypal_braintree/pull/109) ([tvdeyen](https://github.com/tvdeyen)) - -## [v0.2.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v0.2.0) (2017-07-20) - -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/v0.1.0...v0.2.0) +- Use CARD\_TYPE\_MAPPING for setting cc\_type [\#5](https://github.com/solidusio/solidus_braintree/pull/5) ([allisonlarson](https://github.com/allisonlarson)) + +## [v0.1.3](https://github.com/solidusio/solidus_braintree/tree/v0.1.3) (2015-09-04) + +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.1.2...v0.1.3) **Merged pull requests:** -- JS Overhaul [\#101](https://github.com/solidusio/solidus_paypal_braintree/pull/101) ([isaacfreeman](https://github.com/isaacfreeman)) +- Add name presence validation on create [\#4](https://github.com/solidusio/solidus_braintree/pull/4) ([kamui](https://github.com/kamui)) -## [v0.1.0](https://github.com/solidusio/solidus_paypal_braintree/tree/v0.1.0) (2017-07-17) +## [v0.1.2](https://github.com/solidusio/solidus_braintree/tree/v0.1.2) (2015-09-04) -[Full Changelog](https://github.com/solidusio/solidus_paypal_braintree/compare/86edca9b8a31a0d7a092f1871d53eb3191523c4c...v0.1.0) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.1.1...v0.1.2) -**Closed issues:** +## [v0.1.1](https://github.com/solidusio/solidus_braintree/tree/v0.1.1) (2015-09-02) + +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/v0.1.0...v0.1.1) + +## [v0.1.0](https://github.com/solidusio/solidus_braintree/tree/v0.1.0) (2015-09-02) -- Payments in backend not working [\#74](https://github.com/solidusio/solidus_paypal_braintree/issues/74) -- Strip whitespace on payment methods form fields. [\#66](https://github.com/solidusio/solidus_paypal_braintree/issues/66) -- Generate token with existing braintree customer id. [\#63](https://github.com/solidusio/solidus_paypal_braintree/issues/63) +[Full Changelog](https://github.com/solidusio/solidus_braintree/compare/411a93001c017d41fd545e0dc9d4edef3422759e...v0.1.0) **Merged pull requests:** -- Show transaction link [\#107](https://github.com/solidusio/solidus_paypal_braintree/pull/107) ([isaacfreeman](https://github.com/isaacfreeman)) -- Rename Gateway\#method\_type to Gateway\#partial\_name [\#105](https://github.com/solidusio/solidus_paypal_braintree/pull/105) ([isaacfreeman](https://github.com/isaacfreeman)) -- Setup recipe in README.md [\#100](https://github.com/solidusio/solidus_paypal_braintree/pull/100) ([isaacfreeman](https://github.com/isaacfreeman)) -- Make Paypal button bg transparent on hover [\#99](https://github.com/solidusio/solidus_paypal_braintree/pull/99) ([isaacfreeman](https://github.com/isaacfreeman)) -- Backend payments [\#97](https://github.com/solidusio/solidus_paypal_braintree/pull/97) ([isaacfreeman](https://github.com/isaacfreeman)) -- Support Rails 5.1 [\#95](https://github.com/solidusio/solidus_paypal_braintree/pull/95) ([isaacfreeman](https://github.com/isaacfreeman)) -- Set payment type for credit cards [\#91](https://github.com/solidusio/solidus_paypal_braintree/pull/91) ([Senjai](https://github.com/Senjai)) -- Add translation for Credit Card payment type [\#89](https://github.com/solidusio/solidus_paypal_braintree/pull/89) ([luukveenis](https://github.com/luukveenis)) -- Asset pipeline fixes [\#88](https://github.com/solidusio/solidus_paypal_braintree/pull/88) ([tvdeyen](https://github.com/tvdeyen)) -- Attempt to stop infinite dep resolution [\#87](https://github.com/solidusio/solidus_paypal_braintree/pull/87) ([Senjai](https://github.com/Senjai)) -- Use flashes for displaying frontend errors [\#86](https://github.com/solidusio/solidus_paypal_braintree/pull/86) ([Senjai](https://github.com/Senjai)) -- Always use the same zipcode in address factory [\#84](https://github.com/solidusio/solidus_paypal_braintree/pull/84) ([tvdeyen](https://github.com/tvdeyen)) -- Ensure payment\_method\_id cannot be null on sources [\#83](https://github.com/solidusio/solidus_paypal_braintree/pull/83) ([Senjai](https://github.com/Senjai)) -- Use Spree user class handle [\#82](https://github.com/solidusio/solidus_paypal_braintree/pull/82) ([tvdeyen](https://github.com/tvdeyen)) -- Send billing address with credit card transactions [\#81](https://github.com/solidusio/solidus_paypal_braintree/pull/81) ([tvdeyen](https://github.com/tvdeyen)) -- Coverage [\#78](https://github.com/solidusio/solidus_paypal_braintree/pull/78) ([Senjai](https://github.com/Senjai)) -- Test 2.1 and 2.2 [\#77](https://github.com/solidusio/solidus_paypal_braintree/pull/77) ([Senjai](https://github.com/Senjai)) -- Add alias for last\_4 [\#76](https://github.com/solidusio/solidus_paypal_braintree/pull/76) ([adammathys](https://github.com/adammathys)) -- Submit shipping address with PayPal transactions [\#75](https://github.com/solidusio/solidus_paypal_braintree/pull/75) ([luukveenis](https://github.com/luukveenis)) -- Spec fixes [\#73](https://github.com/solidusio/solidus_paypal_braintree/pull/73) ([Senjai](https://github.com/Senjai)) -- Handle processor and gateway error responses [\#72](https://github.com/solidusio/solidus_paypal_braintree/pull/72) ([luukveenis](https://github.com/luukveenis)) -- Fix credit card spec [\#71](https://github.com/solidusio/solidus_paypal_braintree/pull/71) ([adammathys](https://github.com/adammathys)) -- Handle errors when creating customer [\#70](https://github.com/solidusio/solidus_paypal_braintree/pull/70) ([adammathys](https://github.com/adammathys)) -- Download phantomjs from github mirror [\#69](https://github.com/solidusio/solidus_paypal_braintree/pull/69) ([omnistegan](https://github.com/omnistegan)) -- Remove vendored assets [\#67](https://github.com/solidusio/solidus_paypal_braintree/pull/67) ([adammathys](https://github.com/adammathys)) -- Only setup Apple Pay if HTTPS [\#65](https://github.com/solidusio/solidus_paypal_braintree/pull/65) ([adammathys](https://github.com/adammathys)) -- Bump Braintree JS to 3.9.0 [\#64](https://github.com/solidusio/solidus_paypal_braintree/pull/64) ([adammathys](https://github.com/adammathys)) -- Couple of minor improvements [\#62](https://github.com/solidusio/solidus_paypal_braintree/pull/62) ([adammathys](https://github.com/adammathys)) -- Clean-up vendor assets [\#61](https://github.com/solidusio/solidus_paypal_braintree/pull/61) ([adammathys](https://github.com/adammathys)) -- Add convenience methods for card details [\#60](https://github.com/solidusio/solidus_paypal_braintree/pull/60) ([adammathys](https://github.com/adammathys)) -- Some minor project fixes [\#59](https://github.com/solidusio/solidus_paypal_braintree/pull/59) ([adammathys](https://github.com/adammathys)) -- Add dependent :destroy to configuration association [\#58](https://github.com/solidusio/solidus_paypal_braintree/pull/58) ([luukveenis](https://github.com/luukveenis)) -- Bump rubocop and add exclude blocklength from spec [\#57](https://github.com/solidusio/solidus_paypal_braintree/pull/57) ([cbrunsdon](https://github.com/cbrunsdon)) -- Add 'channel' param to payment requests [\#56](https://github.com/solidusio/solidus_paypal_braintree/pull/56) ([luukveenis](https://github.com/luukveenis)) -- Fix error when saving braintree payment method [\#55](https://github.com/solidusio/solidus_paypal_braintree/pull/55) ([luukveenis](https://github.com/luukveenis)) -- Adds '\n' to the routes.rb addition [\#54](https://github.com/solidusio/solidus_paypal_braintree/pull/54) ([seantaylor](https://github.com/seantaylor)) -- Some small spec fixes [\#53](https://github.com/solidusio/solidus_paypal_braintree/pull/53) ([adammathys](https://github.com/adammathys)) -- Add Apple Pay section to README [\#52](https://github.com/solidusio/solidus_paypal_braintree/pull/52) ([adammathys](https://github.com/adammathys)) -- Update usage instructions in README [\#51](https://github.com/solidusio/solidus_paypal_braintree/pull/51) ([luukveenis](https://github.com/luukveenis)) -- Add proper intro to README [\#50](https://github.com/solidusio/solidus_paypal_braintree/pull/50) ([adammathys](https://github.com/adammathys)) -- Pass order state to transaction import [\#48](https://github.com/solidusio/solidus_paypal_braintree/pull/48) ([luukveenis](https://github.com/luukveenis)) -- Validate the address on a transaction if it exists [\#47](https://github.com/solidusio/solidus_paypal_braintree/pull/47) ([luukveenis](https://github.com/luukveenis)) -- Set PayPal payee emails as preference on gateway [\#46](https://github.com/solidusio/solidus_paypal_braintree/pull/46) ([luukveenis](https://github.com/luukveenis)) -- Fix Apple Pay feature spec [\#45](https://github.com/solidusio/solidus_paypal_braintree/pull/45) ([luukveenis](https://github.com/luukveenis)) -- Add Braintree configuration to Spree::Store model [\#44](https://github.com/solidusio/solidus_paypal_braintree/pull/44) ([luukveenis](https://github.com/luukveenis)) -- Map country names to ISO codes [\#43](https://github.com/solidusio/solidus_paypal_braintree/pull/43) ([luukveenis](https://github.com/luukveenis)) -- Enable PayPal as a payment method [\#42](https://github.com/solidusio/solidus_paypal_braintree/pull/42) ([luukveenis](https://github.com/luukveenis)) -- Submit transactions via AJAX [\#41](https://github.com/solidusio/solidus_paypal_braintree/pull/41) ([luukveenis](https://github.com/luukveenis)) -- Support tokens without specifying payment\_method [\#40](https://github.com/solidusio/solidus_paypal_braintree/pull/40) ([cbrunsdon](https://github.com/cbrunsdon)) -- Enable Braintree credit card payments via hosted fields [\#39](https://github.com/solidusio/solidus_paypal_braintree/pull/39) ([luukveenis](https://github.com/luukveenis)) -- Address improvements [\#38](https://github.com/solidusio/solidus_paypal_braintree/pull/38) ([cbrunsdon](https://github.com/cbrunsdon)) -- Add a javascript method to fetch braintree tokens [\#37](https://github.com/solidusio/solidus_paypal_braintree/pull/37) ([cbrunsdon](https://github.com/cbrunsdon)) -- Braintree nonce and cassettes update [\#36](https://github.com/solidusio/solidus_paypal_braintree/pull/36) ([omnistegan](https://github.com/omnistegan)) -- Update transaction\_import to work correctly on solidus master [\#35](https://github.com/solidusio/solidus_paypal_braintree/pull/35) ([omnistegan](https://github.com/omnistegan)) -- Support multiple merchant account ids by currency [\#33](https://github.com/solidusio/solidus_paypal_braintree/pull/33) ([cbrunsdon](https://github.com/cbrunsdon)) -- Default to US country code [\#32](https://github.com/solidusio/solidus_paypal_braintree/pull/32) ([adammathys](https://github.com/adammathys)) -- Allow JSON requests to transactions controller [\#31](https://github.com/solidusio/solidus_paypal_braintree/pull/31) ([luukveenis](https://github.com/luukveenis)) -- Vcr improvements [\#30](https://github.com/solidusio/solidus_paypal_braintree/pull/30) ([cbrunsdon](https://github.com/cbrunsdon)) -- Only prompt for email for not logged in users [\#29](https://github.com/solidusio/solidus_paypal_braintree/pull/29) ([luukveenis](https://github.com/luukveenis)) -- Implement API Controller to generate client tokens [\#28](https://github.com/solidusio/solidus_paypal_braintree/pull/28) ([stewart](https://github.com/stewart)) -- Conditionally load frontend code [\#27](https://github.com/solidusio/solidus_paypal_braintree/pull/27) ([adammathys](https://github.com/adammathys)) -- Show Source token in source\_view [\#26](https://github.com/solidusio/solidus_paypal_braintree/pull/26) ([stewart](https://github.com/stewart)) -- Set token on Source when creating customer profile [\#25](https://github.com/solidusio/solidus_paypal_braintree/pull/25) ([stewart](https://github.com/stewart)) -- Validate address before processing imports [\#24](https://github.com/solidusio/solidus_paypal_braintree/pull/24) ([luukveenis](https://github.com/luukveenis)) -- Add tests for gateway and source models [\#23](https://github.com/solidusio/solidus_paypal_braintree/pull/23) ([luukveenis](https://github.com/luukveenis)) -- Raise error for invalid transactions and add specs [\#22](https://github.com/solidusio/solidus_paypal_braintree/pull/22) ([luukveenis](https://github.com/luukveenis)) -- Save payment type to source [\#21](https://github.com/solidusio/solidus_paypal_braintree/pull/21) ([luukveenis](https://github.com/luukveenis)) -- Correctly parse error message for failure response [\#20](https://github.com/solidusio/solidus_paypal_braintree/pull/20) ([stewart](https://github.com/stewart)) -- Upcase country [\#19](https://github.com/solidusio/solidus_paypal_braintree/pull/19) ([cbrunsdon](https://github.com/cbrunsdon)) -- Add Source View [\#18](https://github.com/solidusio/solidus_paypal_braintree/pull/18) ([stewart](https://github.com/stewart)) -- Add actions, can\_\*? predicate methods to Source [\#17](https://github.com/solidusio/solidus_paypal_braintree/pull/17) ([stewart](https://github.com/stewart)) -- End to end transaction [\#16](https://github.com/solidusio/solidus_paypal_braintree/pull/16) ([cbrunsdon](https://github.com/cbrunsdon)) -- Correct foreign\_key creation for payment\_method reference on Source [\#15](https://github.com/solidusio/solidus_paypal_braintree/pull/15) ([stewart](https://github.com/stewart)) -- Update Gateway Configuration [\#14](https://github.com/solidusio/solidus_paypal_braintree/pull/14) ([stewart](https://github.com/stewart)) -- Use Braintree Customer ID, Payment Method ID when creating transactions [\#13](https://github.com/solidusio/solidus_paypal_braintree/pull/13) ([stewart](https://github.com/stewart)) -- Register gateway with Solidus [\#12](https://github.com/solidusio/solidus_paypal_braintree/pull/12) ([adammathys](https://github.com/adammathys)) -- Add Gateway\#cancel [\#11](https://github.com/solidusio/solidus_paypal_braintree/pull/11) ([adammathys](https://github.com/adammathys)) -- Implement Gateway\#create\_profile [\#10](https://github.com/solidusio/solidus_paypal_braintree/pull/10) ([stewart](https://github.com/stewart)) -- Add option to send extra options to Braintree [\#9](https://github.com/solidusio/solidus_paypal_braintree/pull/9) ([adammathys](https://github.com/adammathys)) -- Convert cents to dollars [\#8](https://github.com/solidusio/solidus_paypal_braintree/pull/8) ([adammathys](https://github.com/adammathys)) -- Add ability to capture authorized payments [\#7](https://github.com/solidusio/solidus_paypal_braintree/pull/7) ([adammathys](https://github.com/adammathys)) -- VCR Fixups [\#6](https://github.com/solidusio/solidus_paypal_braintree/pull/6) ([stewart](https://github.com/stewart)) -- Add support for refunding payments [\#5](https://github.com/solidusio/solidus_paypal_braintree/pull/5) ([adammathys](https://github.com/adammathys)) -- Add implementation for authorization transactions [\#4](https://github.com/solidusio/solidus_paypal_braintree/pull/4) ([stewart](https://github.com/stewart)) -- Implement voiding transactions [\#3](https://github.com/solidusio/solidus_paypal_braintree/pull/3) ([adammathys](https://github.com/adammathys)) -- Some minor clean-up [\#2](https://github.com/solidusio/solidus_paypal_braintree/pull/2) ([adammathys](https://github.com/adammathys)) -- FIx Up Test Environment [\#1](https://github.com/solidusio/solidus_paypal_braintree/pull/1) ([stewart](https://github.com/stewart)) +- Provide an option for always sending the bill address [\#2](https://github.com/solidusio/solidus_braintree/pull/2) ([jordan-brough](https://github.com/jordan-brough)) diff --git a/lib/solidus_braintree/version.rb b/lib/solidus_braintree/version.rb index 5e6d9000..4897d1ef 100644 --- a/lib/solidus_braintree/version.rb +++ b/lib/solidus_braintree/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SolidusBraintree - VERSION = '1.2.0' + VERSION = '3.0.0' end