Skip to content

Commit

Permalink
Add Braintree to the installer as a payment method option
Browse files Browse the repository at this point in the history
Closes #4749.
  • Loading branch information
gsmendoza committed Mar 3, 2023
1 parent a63449f commit e3f7cf1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
unless Bundler.locked_gems.dependencies['solidus_braintree']
bundle_command "add solidus_braintree #{version} --git='https://github.com/solidusio/solidus_braintree' --branch='master'"
end

generate 'solidus_braintree:install'
7 changes: 5 additions & 2 deletions core/lib/generators/solidus/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class InstallGenerator < Rails::Generators::AppBase
PAYMENT_METHODS = %w[
paypal
bolt
braintree
none
]

Expand Down Expand Up @@ -322,16 +323,18 @@ def detect_authentication_to_install
def detect_payment_method_to_install
return 'paypal' if Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
return 'bolt' if Bundler.locked_gems.dependencies['solidus_bolt']
return 'braintree' if Bundler.locked_gems.dependencies['solidus_braintree']

allowable_payment_methods_hash = {
'none' => ['paypal', 'none'],
'none' => ['paypal', 'braintree', 'none'],
'classic' => ['paypal', 'bolt', 'none'],
'starter' => ['paypal', 'none'],
'starter' => ['paypal', 'braintree', 'none'],
}

payment_methods_hash = {
'paypal' => "- [#{set_color 'paypal', :bold}] Install `solidus_paypal_commerce_platform` (#{set_color :default, :bold}).",
'bolt' => "- [#{set_color 'bolt', :bold}] Install `solidus_bolt`.",
'braintree' => "- [#{set_color 'braintree', :bold}] Install `solidus_braintree`.",
'none' => "- [#{set_color 'none', :bold}] Skip installing a payment method.",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
expect(questions.first[:default]).to eq('paypal')
expect(strip_ansi questions.first[:desc]).to include('[paypal]')
expect(strip_ansi questions.first[:desc]).to include('[bolt]')
expect(strip_ansi questions.first[:desc]).to_not include('[braintree]')
expect(strip_ansi questions.first[:desc]).to include('[none]')
end

Expand All @@ -121,10 +122,11 @@
generator.prepare_options

expect(questions.size).to eq(1)
expect(questions.first[:limited_to]).to eq(['paypal', 'none'])
expect(questions.first[:limited_to]).to eq(['paypal', 'braintree', 'none'])
expect(questions.first[:default]).to eq('paypal')
expect(strip_ansi questions.first[:desc]).to include('[paypal]')
expect(strip_ansi questions.first[:desc]).not_to include('[bolt]')
expect(strip_ansi questions.first[:desc]).to include('[braintree]')
expect(strip_ansi questions.first[:desc]).to include('[none]')
end
end
Expand Down

0 comments on commit e3f7cf1

Please sign in to comment.