Skip to content

Commit

Permalink
WIP multi-currency support using unstable mollie-api-ruby client.
Browse files Browse the repository at this point in the history
  • Loading branch information
vernondegoede committed Jun 6, 2018
1 parent 72f1be6 commit caee8da
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'mollie-api-ruby', '~> 3.1.4'
gem 'mollie-api-ruby', :git => 'git://github.com/mollie/mollie-api-ruby.git', :branch => 'mollie-v2'

# Specify your gem's dependencies in spree_mollie_gateway.gemspec
gemspec
6 changes: 5 additions & 1 deletion app/models/spree/gateway/mollie_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ def prepare_payment_params(money_in_cents, source, gateway_options)
order_number = gateway_options[:order_id]
customer_id = gateway_options[:customer_id]
amount = money_in_cents / 100.0
currency = gateway_options[:currency]

order_params = {
amount: amount,
amount: {
value: amount.to_s,
currency: currency
},
description: "Spree Order: #{order_number}",
redirectUrl: spree_routes.mollie_validate_payment_mollie_url(
order_number: order_number,
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/mollie_gateway_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

before(:create) do |gateway|
gateway.preferences[:api_key] = ENV['MOLLIE_API_KEY']
gateway.preferences[:hostname] = 'https://example.com'
gateway.preferences[:hostname] = 'https://mollie.test'
end
end
end
9 changes: 8 additions & 1 deletion spec/factories/mollie_payment_source_factory.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
FactoryBot.define do
factory :mollie_payment_source, class: Spree::MolliePaymentSource do
# Creditcard payment
factory :mollie_cc_payment_source, class: Spree::MolliePaymentSource do
payment_method_name 'creditcard'
status 'open'
end

# iDEAL payment
factory :mollie_ideal_payment_source, class: Spree::MolliePaymentSource do
payment_method_name 'ideal'
issuer 'ideal_ABNANL2A'
status 'open'
Expand Down
10 changes: 9 additions & 1 deletion spec/factories/payment_factory_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
factory :mollie_payment, class: Spree::Payment do
amount 12.73
association(:payment_method, factory: :mollie_gateway)
association(:source, factory: :mollie_payment_source)
association(:source, factory: :mollie_cc_payment_source)
order
state 'checkout'
end

factory :mollie_multicurrency_payment, class: Spree::Payment do
amount 12.73
association(:payment_method, factory: :mollie_gateway)
association(:source, factory: :mollie_ideal_payment_source)
order
state 'checkout'
end
Expand Down
4 changes: 4 additions & 0 deletions spec/models/spree/gateway/mollie_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@
expect(gateway.available_payment_methods.first.issuers.first).to include('id' => 'ideal_ABNANL2A', 'method' => 'ideal')
end
end

context 'multi-currency' do
it 'should '
end
end
end
2 changes: 1 addition & 1 deletion spree_mollie_gateway.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'coffee-rails'
spec.add_development_dependency 'database_cleaner'

spec.add_runtime_dependency 'mollie-api-ruby', '~> 3.1', '>= 3.1.4'
spec.add_runtime_dependency 'mollie-api-ruby'
end

0 comments on commit caee8da

Please sign in to comment.