Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Mollie payment selector #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------

Expand Down
5 changes: 4 additions & 1 deletion app/controllers/spree/checkout_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion app/models/spree/payment_method/mollie.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 9 additions & 2 deletions spec/models/spree/payment_method/mollie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spree_mollie.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down