ideal-mollie 0.0.4 → 0.0.5

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/.travis.yml CHANGED
@@ -3,6 +3,8 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
+ - ree
7
+ - jruby
6
8
  script: "bundle exec rake spec"
7
9
  notifications:
8
10
  recipients:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ - **30 January 2012**: version 0.0.5
4
+ - Added support for multiple profile's
5
+
3
6
  - **26 January 2012**: version 0.0.4
4
7
  - Changed property `payed` to `paid`
5
8
 
data/README.md CHANGED
@@ -41,6 +41,12 @@ config.ideal_mollie.return_url = "http://example.org/return"
41
41
  config.ideal_mollie.test_mode = false
42
42
  ```
43
43
 
44
+ Optionally you can add a profile_key if you have multiple profile's
45
+
46
+ ```
47
+ config.ideal_mollie.profile_key = "123abc45"
48
+ ```
49
+
44
50
  ## Rails Example
45
51
 
46
52
  Below you will find a simple `TransactionController` and a view to display the bank selectbox. Note that this is just a very basic example.
@@ -87,27 +93,25 @@ class TransactionsController < ApplicationController
87
93
  # my_order.customer_city = response.customer_city
88
94
  # my_order.save
89
95
  else
90
- # canceled or re-checking?
91
- if my_order.paid.nil?
92
- # TODO: store the result information for the canceled payment
93
- # For example:
94
- # my_order = MyOrder.find_by_transaction_id(transaction_id)
95
- # my_order.paid = false
96
- # my_order.save
97
- end
96
+ # TODO: store the result information for the canceled payment
97
+ # For example:
98
+ # my_order = MyOrder.find_by_transaction_id(transaction_id)
99
+ # my_order.paid = false
100
+ # my_order.save
98
101
  end
99
102
  render :nothing => true
100
103
  end
101
104
 
102
105
  def result
106
+ transaction_id = params[:transaction_id]
103
107
  # TODO show the result
104
108
  # For example:
105
- # my_order = MyOrderObject.find(id)
106
- #if @my_order.paid
107
- render :text => "Thank you for your payment."
108
- else
109
- render :text => "Transaction has been cancelled or couldn't complete"
110
- end
109
+ # my_order = MyOrder.find_by_transaction_id(transaction_id)
110
+ # if my_order.paid
111
+ # render :text => "Thank you for your payment."
112
+ # else
113
+ # render :text => "Transaction has been cancelled or couldn't complete"
114
+ # end
111
115
  end
112
116
  end
113
117
  ```
data/ideal-mollie.gemspec CHANGED
@@ -30,4 +30,5 @@ Gem::Specification.new do |s|
30
30
  s.add_dependency "faraday_middleware", "~> 0.8.1"
31
31
  s.add_dependency "multi_xml", "~> 0.4.1"
32
32
  s.add_dependency "nokogiri", "~> 1.5.0"
33
+ s.add_dependency "jruby-openssl" if RUBY_PLATFORM == 'java'
33
34
  end
data/lib/ideal-mollie.rb CHANGED
@@ -67,7 +67,7 @@ module IdealMollie
67
67
  # IdealMollie.check_order("4b99662febb42ce6f889d9c57f5cf3fa")
68
68
  #
69
69
  # @note Once a transaction is paid, only the next time you verify the
70
- # transaction will the value of +payed+ be +true+.
70
+ # transaction will the value of +paid+ be +true+.
71
71
  # Else it will be +false+.
72
72
  #
73
73
  # @return [IdealMollie::OrderResult] the +OrderResult+.
@@ -119,7 +119,7 @@ module IdealMollie
119
119
  # @return [Hash] the parameter +Hash+ for the new order.
120
120
  def new_order_params(amount, description, bank_id, return_url=nil)
121
121
  return_url = Config.return_url if return_url.nil?
122
- {
122
+ params = {
123
123
  :partnerid => Config.partner_id,
124
124
  :reporturl => Config.report_url,
125
125
  :returnurl => return_url,
@@ -127,6 +127,12 @@ module IdealMollie
127
127
  :amount => amount,
128
128
  :bank_id => bank_id
129
129
  }
130
+
131
+ unless Config.profile_key.nil?
132
+ params.merge!({:profile_key => Config.profile_key})
133
+ end
134
+
135
+ params
130
136
  end
131
137
 
132
138
  private
@@ -3,9 +3,13 @@
3
3
  #
4
4
  module IdealMollie::Config
5
5
  class << self
6
- # @return [int] You Mollie partner id.
7
- # @note You can find you partner id here: https://www.mollie.nl/beheer/betaaldiensten/documentatie/ideal/
6
+ # @return [int] Your Mollie partner id.
7
+ # @note See: https://www.mollie.nl/beheer/betaaldiensten/documentatie/ideal/ for your partner id
8
8
  attr_accessor :partner_id
9
+ # @return [String] Your Mollie profile key
10
+ # @note The is a optional parameter. You only need this if you have multiple profiles
11
+ # @note See: https://www.mollie.nl/beheer/betaaldiensten/profielen/ for the list of profiles
12
+ attr_accessor :profile_key
9
13
  # @return [String] The url Mollie uses to report the status of the payment
10
14
  attr_accessor :report_url
11
15
  # @return [String] The url Mollie sends you to when a transaction is finished
@@ -18,6 +22,7 @@ module IdealMollie::Config
18
22
  def init!
19
23
  @defaults = {
20
24
  :@partner_id => nil,
25
+ :@profile_key => nil,
21
26
  :@report_url => nil,
22
27
  :@return_url => nil,
23
28
  :@test_mode => false
@@ -3,13 +3,21 @@ module IdealMollie
3
3
  # Simpel extend on the +Rails::Engine+ to add support for a new config section within
4
4
  # the environment configs
5
5
  #
6
- # @example
6
+ # @example default
7
7
  # # /config/environments/development.rb
8
8
  # config.ideal_mollie.partner_id = 123456
9
9
  # config.ideal_mollie.report_url = "http://example.org/report"
10
10
  # config.ideal_mollie.return_url = "http://example.org/return"
11
11
  # config.ideal_mollie.test_mode = false
12
12
  #
13
+ # @example optional profile_key when having to deal with multiple profile's
14
+ # # /config/environments/development.rb
15
+ # config.ideal_mollie.partner_id = 123456
16
+ # config.ideal_mollie.report_url = "http://example.org/report"
17
+ # config.ideal_mollie.return_url = "http://example.org/return"
18
+ # config.ideal_mollie.test_mode = false
19
+ # config.ideal_mollie.profile_key = "123abc45"
20
+ #
13
21
  class Engine < Rails::Engine
14
22
  config.ideal_mollie = IdealMollie::Config
15
23
  end
@@ -1,4 +1,4 @@
1
1
  module IdealMollie
2
2
  # Version number of IdealMollie
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
data/spec/config_spec.rb CHANGED
@@ -5,6 +5,7 @@ describe IdealMollie::Config do
5
5
  @config = IdealMollie::Config
6
6
  @config.test_mode = true
7
7
  @config.partner_id = 123456
8
+ @config.profile_key = "321zyx12"
8
9
  @config.report_url = "http://example.org/report"
9
10
  @config.return_url = "http://example.org/return"
10
11
  end
@@ -14,6 +15,7 @@ describe IdealMollie::Config do
14
15
  @config.reset!
15
16
  @config.test_mode.should be_false
16
17
  @config.partner_id.should be_nil
18
+ @config.profile_key.should be_nil
17
19
  @config.report_url.should be_nil
18
20
  @config.return_url.should be_nil
19
21
  end
@@ -21,8 +23,10 @@ describe IdealMollie::Config do
21
23
 
22
24
  describe "#update!" do
23
25
  it "should update" do
26
+ @config.reset!
24
27
  @config.test_mode = false
25
28
  @config.partner_id = 987654
29
+ @config.profile_key = "123abc45"
26
30
  @config.report_url = "report"
27
31
  @config.return_url = "return"
28
32
  @config.update!
@@ -30,6 +34,7 @@ describe IdealMollie::Config do
30
34
  config = IdealMollie::Config
31
35
  config.test_mode.should be_false
32
36
  config.partner_id.should eq 987654
37
+ config.profile_key.should eq "123abc45"
33
38
  config.report_url.should eq "report"
34
39
  config.return_url.should eq "return"
35
40
  end
@@ -23,6 +23,20 @@ describe IdealMollie::IdealException do
23
23
  to raise_error(IdealMollie::IdealException, /This account does not exist or is suspended./)
24
24
  end
25
25
  end
26
+
27
+ it "should throw an exception when a unknown profile key is specified" do
28
+ config = IdealMollie::Config
29
+ config.test_mode = false
30
+ config.partner_id = 123456
31
+ config.profile_key = "00000000"
32
+ config.report_url = "http://example.org/report"
33
+ config.return_url = "http://example.org/return"
34
+
35
+ VCR.use_cassette("new_order") do
36
+ expect { IdealMollie.new_order(1234, "exception test", "0031") }.
37
+ to raise_error(IdealMollie::IdealException, /A fetch was issued for an unknown or inactive profile./)
38
+ end
39
+ end
26
40
  end
27
41
 
28
42
  context "#check_order" do
@@ -2,11 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe IdealMollie do
4
4
  before(:each) do
5
- config = IdealMollie::Config
6
- config.test_mode = false
7
- config.partner_id = 987654
8
- config.report_url = "http://example.org/report"
9
- config.return_url = "http://example.org/return"
5
+ @config = IdealMollie::Config
6
+ @config.reset!
7
+ @config.test_mode = false
8
+ @config.partner_id = 987654
9
+ @config.report_url = "http://example.org/report"
10
+ @config.return_url = "http://example.org/return"
10
11
  end
11
12
 
12
13
  context "#banks" do
@@ -34,6 +35,18 @@ describe IdealMollie do
34
35
  order.message.should eq "Your iDEAL-payment has successfully been setup. Your customer should visit the given URL to make the payment"
35
36
  end
36
37
  end
38
+ it "should return a Order for profile_key with the correct values" do
39
+ @config.profile_key = "123abc45"
40
+ @config.update!
41
+ VCR.use_cassette("new_order") do
42
+ order = IdealMollie.new_order(1000, "test", "0031")
43
+ order.transaction_id.should eq "474ed7b2735cbe4d1f4fd4da23269263"
44
+ order.amount.should eq 1000
45
+ order.currency.should eq "EUR"
46
+ order.url.should eq "https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=6616737002&trxid=30000226032385"
47
+ order.message.should eq "Your iDEAL-payment has successfully been setup. Your customer should visit the given URL to make the payment"
48
+ end
49
+ end
37
50
  it "should override the return url when specified" do
38
51
  params = IdealMollie.new_order_params(1200, "test", "0031")
39
52
  params[:returnurl].should eq "http://example.org/return"
@@ -41,6 +54,17 @@ describe IdealMollie do
41
54
  params = IdealMollie.new_order_params(1200, "test", "0031", "http://another.example.org/return")
42
55
  params[:returnurl].should eq "http://another.example.org/return"
43
56
  end
57
+ it "should not append the profile_key this isn't specified in the config" do
58
+ params = IdealMollie.new_order_params(1200, "test", "0031")
59
+ params.has_key?(:profile_key).should be_false
60
+ end
61
+ it "should append the profile_key if specified in the config" do
62
+ @config.profile_key = 12345
63
+ @config.update!
64
+
65
+ params = IdealMollie.new_order_params(1200, "test", "0031")
66
+ params.has_key?(:profile_key).should be_true
67
+ end
44
68
  end
45
69
 
46
70
  context "#check_order" do
@@ -55,6 +55,35 @@
55
55
  body: ! "<?xml version=\"1.0\" ?>\n<response>\n\t<item type=\"error\">\n\t\t<errorcode>-2</errorcode>\n\t\t<message>This
56
56
  account does not exist or is suspended.</message>\n\t</item>\n</response>"
57
57
  http_version: '1.1'
58
+ - !ruby/struct:VCR::HTTPInteraction
59
+ request: !ruby/struct:VCR::Request
60
+ method: :post
61
+ uri: https://secure.mollie.nl:443/xml/ideal?partnerid=123456&reporturl=http%3A%2F%2Fexample.org%2Freport&returnurl=http%3A%2F%2Fexample.org%2Freturn&description=exception%20test&amount=1234&bank_id=0031&profile_key=00000000&a=fetch&testmode=false
62
+ body:
63
+ headers:
64
+ user-agent:
65
+ - Ruby-IdealMollie
66
+ content-length:
67
+ - '0'
68
+ response: !ruby/struct:VCR::Response
69
+ status: !ruby/struct:VCR::ResponseStatus
70
+ code: 200
71
+ message: OK
72
+ headers:
73
+ server:
74
+ - nginx/0.7.67
75
+ date:
76
+ - Mon, 30 Jan 2012 11:30:43 GMT
77
+ content-type:
78
+ - text/xml
79
+ x-powered-by:
80
+ - PHP/5.2.6-1+lenny13
81
+ content-length:
82
+ - '180'
83
+ body: ! "<?xml version=\"1.0\" ?>\n<response>\n\t<item type=\"error\">\n\t\t<errorcode>-16</errorcode>\n\t\t<message>A
84
+ fetch was issued for an unknown or inactive profile.</message>\n\t</item>\n</response>"
85
+ http_version: '1.1'
86
+
58
87
  - !ruby/struct:VCR::HTTPInteraction
59
88
  request: !ruby/struct:VCR::Request
60
89
  method: :post
@@ -84,3 +113,32 @@
84
113
  iDEAL-payment has successfully been setup. Your customer should visit the given
85
114
  URL to make the payment</message>\n\t</order>\n</response>"
86
115
  http_version: '1.1'
116
+ - !ruby/struct:VCR::HTTPInteraction
117
+ request: !ruby/struct:VCR::Request
118
+ method: :post
119
+ uri: https://secure.mollie.nl:443/xml/ideal?partnerid=987654&reporturl=http%3A%2F%2Fexample.org%2Freport&returnurl=http%3A%2F%2Fexample.org%2Freturn&description=test&amount=1000&bank_id=0031&profile_key=123abc45&a=fetch&testmode=false
120
+ body:
121
+ headers:
122
+ user-agent:
123
+ - Ruby-IdealMollie
124
+ content-length:
125
+ - '0'
126
+ response: !ruby/struct:VCR::Response
127
+ status: !ruby/struct:VCR::ResponseStatus
128
+ code: 200
129
+ message: OK
130
+ headers:
131
+ server:
132
+ - nginx/0.7.67
133
+ date:
134
+ - Mon, 30 Jan 2012 11:27:25 GMT
135
+ content-type:
136
+ - text/xml
137
+ x-powered-by:
138
+ - PHP/5.2.6-1+lenny13
139
+ content-length:
140
+ - '429'
141
+ body: ! "<?xml version=\"1.0\" ?>\n<response>\n\t<order>\n\t\t<transaction_id>474ed7b2735cbe4d1f4fd4da23269263</transaction_id>\n\t\t<amount>1000</amount>\n\t\t<currency>EUR</currency>\n\t\t<URL>https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=6616737002&amp;trxid=30000226032385</URL>\n\t\t<message>Your
142
+ iDEAL-payment has successfully been setup. Your customer should visit the given
143
+ URL to make the payment</message>\n\t</order>\n</response>"
144
+ http_version: '1.1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ideal-mollie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-27 00:00:00.000000000 Z
12
+ date: 2012-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &17571080 !ruby/object:Gem::Requirement
16
+ requirement: &8774100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *17571080
24
+ version_requirements: *8774100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: vcr
27
- requirement: &17585420 !ruby/object:Gem::Requirement
27
+ requirement: &8788740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *17585420
35
+ version_requirements: *8788740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fakeweb
38
- requirement: &17584460 !ruby/object:Gem::Requirement
38
+ requirement: &8785780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *17584460
46
+ version_requirements: *8785780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &17583660 !ruby/object:Gem::Requirement
49
+ requirement: &8784680 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *17583660
57
+ version_requirements: *8784680
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: redcarpet
60
- requirement: &17582880 !ruby/object:Gem::Requirement
60
+ requirement: &8783740 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *17582880
68
+ version_requirements: *8783740
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &17582100 !ruby/object:Gem::Requirement
71
+ requirement: &8782940 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *17582100
79
+ version_requirements: *8782940
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &17581020 !ruby/object:Gem::Requirement
82
+ requirement: &8782060 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.9.0
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *17581020
90
+ version_requirements: *8782060
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: faraday
93
- requirement: &17579760 !ruby/object:Gem::Requirement
93
+ requirement: &8797660 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 0.7.6
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *17579760
101
+ version_requirements: *8797660
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: faraday_middleware
104
- requirement: &17578880 !ruby/object:Gem::Requirement
104
+ requirement: &8796900 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.8.1
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *17578880
112
+ version_requirements: *8796900
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: multi_xml
115
- requirement: &17593740 !ruby/object:Gem::Requirement
115
+ requirement: &8795760 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.4.1
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *17593740
123
+ version_requirements: *8795760
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: nokogiri
126
- requirement: &17592060 !ruby/object:Gem::Requirement
126
+ requirement: &8793840 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: 1.5.0
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *17592060
134
+ version_requirements: *8793840
135
135
  description: A simple Ruby implementation for handeling iDeal transactions with the
136
136
  Mollie API
137
137
  email:
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: '0'
181
181
  segments:
182
182
  - 0
183
- hash: -2711657379205421306
183
+ hash: -4164822868320701030
184
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  none: false
186
186
  requirements:
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  segments:
191
191
  - 0
192
- hash: -2711657379205421306
192
+ hash: -4164822868320701030
193
193
  requirements: []
194
194
  rubyforge_project: ideal-mollie
195
195
  rubygems_version: 1.8.11