active_merchant_mollie 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ .bundle/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in active_merchant_targetpay.gemspec
4
+ gemspec
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active_merchant_mollie (0.1.1)
5
+ activemerchant
6
+ nokogiri
7
+ rspec
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ active_utils (1.0.3)
13
+ activesupport (>= 2.3.11)
14
+ i18n
15
+ activemerchant (1.25.0)
16
+ active_utils (>= 1.0.2)
17
+ activesupport (>= 2.3.11)
18
+ builder (>= 2.0.0)
19
+ i18n
20
+ json (>= 1.5.1)
21
+ money
22
+ nokogiri
23
+ activesupport (3.2.6)
24
+ i18n (~> 0.6)
25
+ multi_json (~> 1.0)
26
+ builder (3.0.0)
27
+ diff-lcs (1.1.3)
28
+ i18n (0.6.0)
29
+ json (1.7.3)
30
+ money (5.0.0)
31
+ i18n (~> 0.4)
32
+ json
33
+ multi_json (1.3.6)
34
+ nokogiri (1.5.5)
35
+ rspec (2.10.0)
36
+ rspec-core (~> 2.10.0)
37
+ rspec-expectations (~> 2.10.0)
38
+ rspec-mocks (~> 2.10.0)
39
+ rspec-core (2.10.1)
40
+ rspec-expectations (2.10.0)
41
+ diff-lcs (~> 1.1.3)
42
+ rspec-mocks (2.10.1)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ active_merchant_mollie!
data/Rakefile CHANGED
@@ -1,52 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "active_merchant_mollie"
8
- gem.summary = "ActiveMerchant extension to support the Dutch PSP Mollie with iDeal transactions"
9
- gem.email = "info@moneybird.com"
10
- gem.homepage = "http://github.com/bluetools/active_merchant_mollie"
11
- gem.description = "ActiveMerchant extension to support the Dutch PSP Mollie with iDeal transactions"
12
- gem.authors = ["Edwin Vlieg"]
13
- gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*"]
14
- gem.add_dependency 'active_merchant'
15
- gem.add_dependency 'hpricot'
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
-
23
- require 'spec/rake/spectask'
24
- desc "Run all examples"
25
- Spec::Rake::SpecTask.new('spec') do |t|
26
- t.spec_files = FileList['spec/*_spec.rb']
27
- end
28
-
29
- begin
30
- require 'rcov/rcovtask'
31
- Rcov::RcovTask.new do |test|
32
- test.libs << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
- rescue LoadError
37
- task :rcov do
38
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
- end
40
- end
41
-
42
- task :default => :spec
43
-
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
-
48
- rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "active_merchant_mollie #{version}"
50
- rdoc.rdoc_files.include('README*')
51
- rdoc.rdoc_files.include('lib/**/*.rb')
52
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = %q{active_merchant_mollie}
6
+ s.version = "0.1.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Berend"]
9
+ s.email = ["info@bluetools.nl"]
10
+ s.homepage = ""
11
+ s.summary = %q{ActiveMerchant extension to support the Dutch PSP Mollie with iDeal transactions}
12
+ s.description = %q{ActiveMerchant extension to support the Dutch PSP Mollie with iDeal transactions}
13
+
14
+ s.rubyforge_project = "active_merchant_mollie"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency('activemerchant')
22
+ s.add_dependency('nokogiri')
23
+ s.add_dependency('rspec')
24
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'active_merchant_mollie'
@@ -1,4 +1,4 @@
1
- require "hpricot"
1
+ require "nokogiri"
2
2
 
3
3
  module ActiveMerchant
4
4
  module Billing
@@ -8,14 +8,14 @@ module ActiveMerchant
8
8
 
9
9
  def initialize(options={})
10
10
  requires!(options, :partner_id)
11
-
12
11
  @options = options
12
+ super
13
13
  end
14
14
 
15
15
  def setup_purchase(money, options)
16
16
  requires!(options, :return_url, :report_url, :bank_id, :description)
17
17
 
18
- raise ArgumentError.new("Amount should be at least 1,80EUR") if money < 180
18
+ raise ArgumentError.new("Amount should be at least EUR 1,18") if money < 118
19
19
 
20
20
  @response = build_response_fetch(commit("fetch", {
21
21
  :amount => money,
@@ -45,19 +45,23 @@ module ActiveMerchant
45
45
  url = URL + "?a=#{action}&#{parameters.collect { |k,v| "#{k}=#{v}" }.join("&") }"
46
46
  uri = URI.parse(url)
47
47
  http = Net::HTTP.new(uri.host, uri.port)
48
+ http.use_ssl = (uri.scheme == 'https')
49
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ActiveMerchant::Billing::Base.test?
48
50
  http.get(uri.request_uri).body
49
51
  end
50
52
 
51
53
  def build_response_fetch(response)
54
+
52
55
  vars = {}
53
- doc = Hpricot.XML(response)
54
56
  success = false
55
- if doc.search("response/item").size > 0
56
- errorcode = doc.at('response/item/errorcode').inner_text
57
- message = doc.at('response/item/message').inner_text + " (#{errorcode})"
58
- elsif doc.search("response/order").size > 0
57
+
58
+ doc = Nokogiri.XML(response)
59
+ if doc.search("//response/item").size > 0
60
+ errorcode = doc.at('//response/item/errorcode').inner_text
61
+ message = doc.at('//response/item/message').inner_text + " (#{errorcode})"
62
+ elsif doc.search("//response/order").size > 0
59
63
  vars = {}
60
- resp = doc.at('response/order')
64
+ resp = doc.at('//response/order')
61
65
  if resp && resp.at('amount') && resp.at('transaction_id') && resp.at('URL')
62
66
  vars[:amount] = resp.at('amount').inner_text
63
67
  vars[:transaction_id] = resp.at('transaction_id').inner_text
@@ -69,18 +73,28 @@ module ActiveMerchant
69
73
  end
70
74
 
71
75
  def build_response_check(response)
72
- doc = Hpricot.XML(response)
76
+
77
+ vars = {}
73
78
  success = false
74
- if doc.search("response/item").size > 0
75
- errorcode = doc.at('response/item/errorcode').inner_text
76
- message = doc.at('response/item/message').inner_text + " (#{errorcode})"
77
- elsif doc.search("response/order").size > 0
78
- resp = doc.at('response/order')
79
+
80
+ doc = Nokogiri.XML(response)
81
+ if doc.search("//response/item").size > 0
82
+ errorcode = doc.at('//response/item/errorcode').inner_text
83
+ message = doc.at('//response/item/message').inner_text + " (#{errorcode})"
84
+ elsif doc.search("//response/order").size > 0
85
+ resp = doc.at('//response/order')
79
86
  success = resp && resp.at('payed') && resp.at('payed').inner_text.downcase == "true"
87
+
88
+ resp = doc.at("//response/order/consumer")
89
+ if resp && resp.at('consumerAccount') && resp.at('consumerName')
90
+ vars[:consumer_account] = resp.at('consumerAccount').inner_text
91
+ vars[:consumer_city] = resp.at('consumerCity').inner_text
92
+ vars[:consumer_name] = resp.at('consumerName').inner_text
93
+ end
80
94
  end
81
- MollieIdealCheckResponse.new(success, message)
95
+ MollieIdealCheckResponse.new(success, message, vars)
82
96
  end
83
97
 
84
98
  end
85
99
  end
86
- end
100
+ end
@@ -2,6 +2,18 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class MollieIdealCheckResponse < Response
4
4
 
5
+ def consumer_account
6
+ @params['consumer_account']
7
+ end
8
+
9
+ def consumer_city
10
+ @params['consumer_city']
11
+ end
12
+
13
+ def consumer_name
14
+ @params['consumer_name']
15
+ end
16
+
5
17
  end
6
18
  end
7
- end
19
+ end
@@ -16,4 +16,4 @@ module ActiveMerchant #:nodoc:
16
16
 
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -2,5 +2,3 @@ require 'active_merchant'
2
2
  require 'active_merchant/billing/mollie_ideal'
3
3
  require 'active_merchant/billing/mollie_ideal_check_response'
4
4
  require 'active_merchant/billing/mollie_ideal_fetch_response'
5
-
6
- VERSION = "0.0.1"
@@ -25,6 +25,7 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
25
25
 
26
26
  it "should create a new purchase via the Mollie API" do
27
27
  http_mock = mock(Net::HTTP)
28
+ http_mock.should_receive(:use_ssl=).once.with(true)
28
29
  Net::HTTP.should_receive(:new).with("secure.mollie.nl", 443).and_return(http_mock)
29
30
 
30
31
  response_mock = mock(Net::HTTPResponse)
@@ -34,7 +35,7 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
34
35
  <transaction_id>482d599bbcc7795727650330ad65fe9b</transaction_id>
35
36
  <amount>123</amount>
36
37
  <currency>EUR</currency>
37
- <URL>https://mijn.postbank.nl/internetbankieren/SesamLoginServlet?sessie=ideal&trxid=003123456789123&random=123456789abcdefgh</URL>
38
+ <URL>https://ideal.ing.nl/internetbankieren/SesamLoginServlet?sessie=ideal&amp;trxid=0030000123497790&amp;random=bac53c612328151</URL>
38
39
  <message>Your iDEAL-payment has succesfuly been setup. Your customer should visit the given URL to make the payment</message>
39
40
  </order>
40
41
  </response>')
@@ -54,7 +55,7 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
54
55
  })
55
56
 
56
57
  @response.token.should == "482d599bbcc7795727650330ad65fe9b"
57
- @gateway.redirect_url_for(@response.token).should == "https://mijn.postbank.nl/internetbankieren/SesamLoginServlet?sessie=ideal&trxid=003123456789123&random=123456789abcdefgh"
58
+ @gateway.redirect_url_for(@response.token).should == "https://ideal.ing.nl/internetbankieren/SesamLoginServlet?sessie=ideal&trxid=0030000123497790&random=bac53c612328151"
58
59
  end
59
60
 
60
61
  it "should not allow a purchase without a return url" do
@@ -97,9 +98,9 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
97
98
  }.should raise_error(ArgumentError)
98
99
  end
99
100
 
100
- it "should not allow a purchase with less than 1,80EUR" do
101
+ it "should not allow a purchase with less than 1,18EUR" do
101
102
  lambda {
102
- @gateway.setup_purchase(179, {
103
+ @gateway.setup_purchase(117, {
103
104
  :return_url => @return_url,
104
105
  :report_url => @report_url,
105
106
  :bank_id => @bank_id,
@@ -110,6 +111,7 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
110
111
 
111
112
  it "should return information about the error Mollie is throwing" do
112
113
  http_mock = mock(Net::HTTP)
114
+ http_mock.should_receive(:use_ssl=).once.with(true)
113
115
  Net::HTTP.should_receive(:new).with("secure.mollie.nl", 443).and_return(http_mock)
114
116
 
115
117
  response_mock = mock(Net::HTTPResponse)
@@ -145,6 +147,7 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
145
147
 
146
148
  it "should return information about a successfull transaction" do
147
149
  http_mock = mock(Net::HTTP)
150
+ http_mock.should_receive(:use_ssl=).once.with(true)
148
151
  Net::HTTP.should_receive(:new).with("secure.mollie.nl", 443).and_return(http_mock)
149
152
 
150
153
  response_mock = mock(Net::HTTPResponse)
@@ -173,10 +176,14 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
173
176
 
174
177
  @details_response = @gateway.details_for(@token)
175
178
  @details_response.success?.should be_true
179
+ @details_response.consumer_account.should == "P001234567"
180
+ @details_response.consumer_city.should == "Amsterdam"
181
+ @details_response.consumer_name.should == "Hr J Janssen"
176
182
  end
177
183
 
178
184
  it "should return information about a successfull transaction" do
179
185
  http_mock = mock(Net::HTTP)
186
+ http_mock.should_receive(:use_ssl=).once.with(true)
180
187
  Net::HTTP.should_receive(:new).with("secure.mollie.nl", 443).and_return(http_mock)
181
188
 
182
189
  response_mock = mock(Net::HTTPResponse)
@@ -204,6 +211,7 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
204
211
 
205
212
  it "should return information about the error Mollie is throwing" do
206
213
  http_mock = mock(Net::HTTP)
214
+ http_mock.should_receive(:use_ssl=).once.with(true)
207
215
  Net::HTTP.should_receive(:new).with("secure.mollie.nl", 443).and_return(http_mock)
208
216
 
209
217
  response_mock = mock(Net::HTTPResponse)
@@ -229,4 +237,4 @@ describe "Mollie iDeal implementation for ActiveMerchant" do
229
237
 
230
238
  end
231
239
 
232
- end
240
+ end
@@ -1,11 +1,6 @@
1
1
  require "rubygems"
2
- require "spec"
3
2
  require "active_merchant"
3
+ require "active_merchant_mollie"
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
-
8
- require "active_merchant_mollie"
9
-
10
- ActiveMerchant::Billing::Base.mode = :test
11
-
metadata CHANGED
@@ -1,94 +1,110 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_merchant_mollie
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
12
- - Edwin Vlieg
7
+ authors:
8
+ - Berend
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-04-18 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: active_merchant
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activemerchant
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
22
23
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: nokogiri
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
30
38
  type: :runtime
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: hpricot
34
39
  prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
42
54
  type: :runtime
43
- version_requirements: *id002
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
44
62
  description: ActiveMerchant extension to support the Dutch PSP Mollie with iDeal transactions
45
- email: info@moneybird.com
63
+ email:
64
+ - info@bluetools.nl
46
65
  executables: []
47
-
48
66
  extensions: []
49
-
50
- extra_rdoc_files:
51
- - LICENSE
52
- - README.rdoc
53
- files:
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .document
70
+ - .gitignore
71
+ - Gemfile
72
+ - Gemfile.lock
54
73
  - LICENSE
55
74
  - README.rdoc
56
75
  - Rakefile
57
- - VERSION
76
+ - active_merchant_mollie.gemspec
77
+ - init.rb
58
78
  - lib/active_merchant/billing/mollie_ideal.rb
59
79
  - lib/active_merchant/billing/mollie_ideal_check_response.rb
60
80
  - lib/active_merchant/billing/mollie_ideal_fetch_response.rb
61
81
  - lib/active_merchant_mollie.rb
62
- has_rdoc: true
63
- homepage: http://github.com/bluetools/active_merchant_mollie
82
+ - spec/mollie_ideal_spec.rb
83
+ - spec/spec_helper.rb
84
+ homepage: ''
64
85
  licenses: []
65
-
66
86
  post_install_message:
67
- rdoc_options:
68
- - --charset=UTF-8
69
- require_paths:
87
+ rdoc_options: []
88
+ require_paths:
70
89
  - lib
71
- required_ruby_version: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- segments:
83
- - 0
84
- version: "0"
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
85
102
  requirements: []
86
-
87
- rubyforge_project:
88
- rubygems_version: 1.3.6
103
+ rubyforge_project: active_merchant_mollie
104
+ rubygems_version: 1.8.23
89
105
  signing_key:
90
106
  specification_version: 3
91
107
  summary: ActiveMerchant extension to support the Dutch PSP Mollie with iDeal transactions
92
- test_files:
108
+ test_files:
93
109
  - spec/mollie_ideal_spec.rb
94
110
  - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.0