diff --git a/Gemfile b/Gemfile index 24851ea..6154bbe 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source 'https://rubygems.org' -gem 'spree', github: 'spree/spree', branch: 'master' +gem 'spree', '~> 3.1.0' # Provides basic authentication functionality for testing parts of your engine -gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master' +gem 'spree_auth_devise', '~> 3.1.0' gem "codeclimate-test-reporter", group: :test, require: nil diff --git a/README.md b/README.md index 635fe1c..d6da705 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ bundle bundle exec rails g spree_mollie:install ``` +Activate SpreeMollie by selecting Spree::PaymentMethod::Mollie as a new payment method in the backend. Set the 'payment methods' setting to a comma separated string with the mollie payment methods you want to present in the frontend. Default value "ideal, creditcard, mistercash, sofort, banktransfer, paypal, bitcoin, podiumcadeaukaart, paysafecard, kbc, belfius" + Testing ------- diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index b88501c..1a790d0 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -34,7 +34,10 @@ def load_mollie_methods payment_method = Spree::PaymentMethod.first service = MolliePaymentService.new(payment_method: payment_method) - @payment_methods = service.payment_methods + enabled_payment_methods = payment_method.preferred_payment_methods.split(/\s*[,;]\s*/) + @payment_methods = service.payment_methods.find_all do |p| + enabled_payment_methods.include? p["id"] + end @issuers = service.issuers end diff --git a/app/models/spree/payment_method/mollie.rb b/app/models/spree/payment_method/mollie.rb index d69b88c..89d5ae9 100644 --- a/app/models/spree/payment_method/mollie.rb +++ b/app/models/spree/payment_method/mollie.rb @@ -1,7 +1,8 @@ module Spree class PaymentMethod::Mollie < PaymentMethod preference :api_key, :string - + preference :payment_methods, :string, default: "ideal, creditcard, mistercash, sofort, banktransfer, paypal, bitcoin, podiumcadeaukaart, paysafecard, kbc, belfius" + def payment_profiles_supported? false end diff --git a/spec/models/spree/payment_method/mollie_spec.rb b/spec/models/spree/payment_method/mollie_spec.rb index 72711a7..2b8d0fe 100644 --- a/spec/models/spree/payment_method/mollie_spec.rb +++ b/spec/models/spree/payment_method/mollie_spec.rb @@ -4,13 +4,20 @@ describe Spree::PaymentMethod::Mollie do - describe "set api_key in preferences" do + describe "preferences" do + let(:mollie) { Spree::PaymentMethod::Mollie.new(name: "Mollie") } + it "can save an api_key attribute" do - mollie = Spree::PaymentMethod::Mollie.new({name: "Mollie"}) mollie.set_preference(:api_key, "my-awesome-key") mollie.save! expect(mollie.get_preference(:api_key)).to eql "my-awesome-key" end + + it "can save preferred payment_methods" do + mollie.set_preference(:payment_methods, "ideal, creditcard") + mollie.save! + expect(mollie.get_preference(:payment_methods)).to eql "ideal, creditcard" + end end end diff --git a/spree_mollie.gemspec b/spree_mollie.gemspec index 15736e1..e4ab25e 100644 --- a/spree_mollie.gemspec +++ b/spree_mollie.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.require_path = 'lib' s.requirements << 'none' - s.add_dependency 'spree_core', '~> 3.1.0.beta' + s.add_dependency 'spree_core', '~> 3.1.0' s.add_dependency 'mollie-ruby', '0.2.0' s.add_development_dependency 'capybara', '~> 2.4' @@ -25,7 +25,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'factory_girl', '~> 4.5' s.add_development_dependency 'ffaker' s.add_development_dependency 'rspec-rails', '~> 3.1' - s.add_development_dependency 'sass-rails', '~> 4.0.2' + s.add_development_dependency 'sass-rails', '~> 5.0.6' s.add_development_dependency 'selenium-webdriver' s.add_development_dependency 'simplecov' s.add_development_dependency 'sqlite3'