mollienl-ideal 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "bundler", "~> 1.0.0"
10
+ gem "jeweler", "~> 1.6.0"
11
+ gem "rcov", ">= 0"
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,18 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.0)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+ rcov (0.9.9)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.0.0)
17
+ jeweler (~> 1.6.0)
18
+ rcov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Raymond Sneekes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,48 @@
1
+ = mollie-ideal
2
+
3
+ Simple gem for processing mollie.nl iDeal payments.
4
+
5
+ configuration parameters
6
+ config.mollie_ideal.partner_id = numeric mollie partner id
7
+ config.mollie_ideal.report_url = url mollie calls to report transaction status
8
+ config.mollie_ideal.return_url = url Mollie redirects to after the transaction
9
+ config.mollie_ideal.test_mode = true/false Test mode parameter for Mollie.nl
10
+
11
+ methods
12
+ get_banks
13
+ Returns a list of banks of which one must be selected to process the
14
+ transaction.
15
+
16
+ do_request_payment(amount, description, bank_id)
17
+ Requests a payment for the specified amount (in cents) with description for
18
+ the bank selected from the get_banks method.
19
+
20
+ The response holds a transaction_id which is the reference to this
21
+ transaction, and a url to which must be redirected to in order to make the
22
+ payment on the website of the selected bank
23
+
24
+ check_status(transaction_id)
25
+ Can be used for the report_url or standalone to check the status of the
26
+ transaction. The mollie documentation specifies that this method can be
27
+ called only once for a transaction.
28
+
29
+ TODO:
30
+ Generators for model/controller
31
+ Tests
32
+ Better error handling
33
+
34
+ == Contributing to mollie-ideal
35
+
36
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
37
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
38
+ * Fork the project
39
+ * Start a feature/bugfix branch
40
+ * Commit and push until you are happy with your contribution
41
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
42
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
43
+
44
+ == Copyright
45
+
46
+ Copyright (c) 2011 Raymond Sneekes. See LICENSE.txt for
47
+ further details.
48
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "mollienl-ideal"
18
+ gem.homepage = "http://github.com/rsneekes/mollienl-ideal"
19
+ gem.license = "MIT"
20
+ gem.summary = "mollie.nl iDEAL payment processor integration Gem"
21
+ gem.description = "Simple mollie.nl iDEAL payment processor integration Gem"
22
+ gem.email = "raymond@sneek.es"
23
+ gem.authors = ["Raymond Sneekes"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "mollienl-ideal #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,74 @@
1
+ module MollieIDeal
2
+ MOLLIE_URL = "https://secure.mollie.nl/xml/ideal?"
3
+
4
+ # Returns a list of banks of which one must be selected to process the
5
+ # transaction
6
+ def self.get_banks
7
+ banks = []
8
+
9
+ doc = get_data({ "a" => "banklist"})
10
+ doc.elements.each("response/bank") do |elem|
11
+ banks << Bank.new(elem)
12
+ end
13
+
14
+ banks
15
+ end
16
+
17
+ # Requests a payment for the specified amount (in cents) with description for
18
+ # the bank selected from the get_banks method.
19
+ #
20
+ # the response holds a transaction_id which is the reference to this
21
+ # transaction, and a url to which must be redirected to in order to make the
22
+ # payment on the website of the selected bank
23
+ def self.do_request_payment(amount, description, bank_id)
24
+ p = {
25
+ :a => "fetch",
26
+ :partnerid => Config.partner_id,
27
+ :description => description,
28
+ :reporturl => Config.report_url,
29
+ :returnurl => Config.return_url,
30
+ :amount => amount,
31
+ :bank_id => bank_id
32
+ }
33
+
34
+ doc = get_data(p)
35
+ doc.elements.each("response/order") do |elem|
36
+ return PaymentRequest.new(elem)
37
+ end
38
+ end
39
+
40
+ # can be used for the report_url or standalone to check the status of the
41
+ # transaction. The mollie documentation specifies that this method can be
42
+ # called only once for a transaction.
43
+ def self.check_status(transaction_id)
44
+ p = {
45
+ :a => "check",
46
+ :partnerid => Config.partner_id,
47
+ :transaction_id => transaction_id
48
+ }
49
+
50
+ doc = get_data(p)
51
+ doc.elements.each("response/order") do |elem|
52
+ return PaymentResult.new(elem)
53
+ end
54
+ end
55
+
56
+ def self.get_data(params)
57
+ params["testmode"] = Config.test_mode
58
+
59
+ uri = URI.parse(MOLLIE_URL + URI.encode_www_form(params))
60
+ http = Net::HTTP.new(uri.host, uri.port)
61
+ http.use_ssl = true
62
+
63
+ response = http.request(Net::HTTP::Get.new(uri.request_uri))
64
+ puts response.body
65
+
66
+ doc = REXML::Document.new response.body
67
+ doc.elements.each("response/item[@type='error']/message") do |elem|
68
+ raise elem.text
69
+ end
70
+
71
+ doc
72
+ end
73
+ end
74
+
@@ -0,0 +1,17 @@
1
+ module MollieIDeal
2
+ class Bank
3
+ attr_accessor :id, :name
4
+
5
+ def initialize(values=nil)
6
+ return if values.nil?
7
+
8
+ if values.kind_of?(Hash)
9
+ values.each { |key, value| self.send key.to_s + "=", value }
10
+ elsif values.kind_of?(REXML::Element)
11
+ @id = values.get_text("bank_id").to_s.to_i
12
+ @name = values.get_text("bank_name").to_s
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,33 @@
1
+ module MollieIDeal
2
+ module Config
3
+ class << self
4
+ # partner_id = numeric mollie partner id
5
+ # report_url = url mollie calls to report transaction status
6
+ # return_url = url Mollie redirects to after the transaction
7
+ # test_mode = true/false Test mode parameter for Mollie.nl
8
+ attr_accessor :partner_id, :report_url, :return_url, :test_mode
9
+
10
+ def init!
11
+ puts "Init config"
12
+ @defaults = {
13
+ :@partner_id => nil,
14
+ :@report_url => nil,
15
+ :@return_url => nil,
16
+ :@test_mode => false
17
+ }
18
+ end
19
+
20
+ def reset!
21
+ @defaults.each { |k, v| instance_variable_set(k, v) }
22
+ end
23
+
24
+ def update!
25
+ @defaults.each do |k, v|
26
+ instance_variable_set(k, v) unless instance_variable_defined(k)
27
+ end
28
+ end
29
+ end
30
+ init!
31
+ reset!
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ module MollieIDeal
2
+ module Config
3
+ class << self
4
+ attr_accessor :partner_id, :report_url, :return_url, :test_mode
5
+
6
+ def init!
7
+ puts "Init config"
8
+ @defaults = {
9
+ :@partner_id => nil,
10
+ :@report_url => nil,
11
+ :@return_url => nil,
12
+ :@test_mode => false
13
+ }
14
+ end
15
+
16
+ def reset!
17
+ @defaults.each { |k, v| instance_variable_set(k, v) }
18
+ end
19
+ end
20
+ init!
21
+ reset!
22
+ end
23
+
24
+ class Engine < Rails::Engine
25
+ config.mollie_ideal = MollieIDeal::Config
26
+ end
27
+ end
28
+
@@ -0,0 +1,21 @@
1
+ module MollieIDeal
2
+ class PaymentRequest
3
+ attr_accessor :transaction_id, :amount, :currency, :url, :message
4
+
5
+ def initialize(values=nil)
6
+ return if values.nil?
7
+
8
+ if values.kind_of?(Hash)
9
+ values.each { |key, value| self.send key.to_s + "=", value }
10
+ elsif values.kind_of?(REXML::Element)
11
+ puts values
12
+ @transaction_id = values.get_text("transaction_id").to_s
13
+ @amount = values.get_text("amount").to_s.to_i
14
+ @currency = values.get_text("currency").to_s
15
+ @url = URI.unescape(values.get_text("URL").to_s)
16
+ @message = values.get_text("message").to_s
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,19 @@
1
+ module MollieIDeal
2
+ class PaymentResult < PaymentRequest
3
+ attr_accessor :payed, :consumer_name, :consumer_account, :consumer_city
4
+
5
+ def initialize(values)
6
+ return if values.nil?
7
+
8
+ super(values)
9
+
10
+ if values.kind_of?(REXML::Element)
11
+ @payed = ("true" === values.get_text("payed").to_s)
12
+ @consumer_name = values.get_text("consumer/consumerName").to_s
13
+ @consumer_name = values.get_text("consumer/consumerAccount").to_s
14
+ @consumer_name = values.get_text("consumer/consumerCity").to_s
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,13 @@
1
+ require "net/http"
2
+ require "uri"
3
+ require 'rexml/document'
4
+ require 'rails'
5
+
6
+ require 'mollie-ideal/config'
7
+
8
+ require 'mollie-ideal/api'
9
+ require 'mollie-ideal/bank'
10
+ require 'mollie-ideal/payment_request'
11
+ require 'mollie-ideal/payment_result'
12
+
13
+ require 'mollie-ideal/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{mollie-ideal}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Raymond Sneekes"]
12
+ s.date = %q{2011-05-08}
13
+ s.description = %q{mollie.nl iDEAL payment processor integration Gem}
14
+ s.email = %q{raymond@sneek.es}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/mollie-ideal.rb",
28
+ "lib/mollie-ideal/api.rb",
29
+ "lib/mollie-ideal/bank.rb",
30
+ "lib/mollie-ideal/config.rb",
31
+ "lib/mollie-ideal/engine.rb",
32
+ "lib/mollie-ideal/payment_request.rb",
33
+ "lib/mollie-ideal/payment_result.rb",
34
+ "mollie-ideal.gemspec",
35
+ "test/helper.rb",
36
+ "test/test_mollie-ideal.rb"
37
+ ]
38
+ s.homepage = %q{http://github.com/rsneekes/mollie-ideal}
39
+ s.licenses = ["MIT"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.6.2}
42
+ s.summary = %q{mollie.nl iDEAL payment processor integration Gem}
43
+
44
+ if s.respond_to? :specification_version then
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
53
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
54
+ s.add_dependency(%q<rcov>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
59
+ s.add_dependency(%q<rcov>, [">= 0"])
60
+ end
61
+ end
62
+
data/test/helper.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ require 'mollie-ideal'
15
+
16
+ class Test::Unit::TestCase
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestMollieIdeal < Test::Unit::TestCase
4
+ def test_something_for_real
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mollienl-ideal
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Raymond Sneekes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-08 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: jeweler
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.6.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rcov
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ description: Simple mollie.nl iDEAL payment processor integration Gem
50
+ email: raymond@sneek.es
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - LICENSE.txt
57
+ - README.rdoc
58
+ files:
59
+ - .document
60
+ - Gemfile
61
+ - Gemfile.lock
62
+ - LICENSE.txt
63
+ - README.rdoc
64
+ - Rakefile
65
+ - VERSION
66
+ - lib/mollie-ideal.rb
67
+ - lib/mollie-ideal/api.rb
68
+ - lib/mollie-ideal/bank.rb
69
+ - lib/mollie-ideal/config.rb
70
+ - lib/mollie-ideal/engine.rb
71
+ - lib/mollie-ideal/payment_request.rb
72
+ - lib/mollie-ideal/payment_result.rb
73
+ - mollie-ideal.gemspec
74
+ - test/helper.rb
75
+ - test/test_mollie-ideal.rb
76
+ has_rdoc: true
77
+ homepage: http://github.com/rsneekes/mollienl-ideal
78
+ licenses:
79
+ - MIT
80
+ post_install_message:
81
+ rdoc_options: []
82
+
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 2298755911466464606
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.6.2
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: mollie.nl iDEAL payment processor integration Gem
107
+ test_files: []
108
+