ideal-mollie 0.0.2 → 0.0.3
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/CHANGELOG.md +10 -0
- data/README.md +79 -4
- data/ideal-mollie.gemspec +1 -0
- data/lib/ideal-mollie.rb +46 -75
- data/lib/ideal-mollie/bank.rb +27 -0
- data/lib/ideal-mollie/config.rb +12 -1
- data/lib/ideal-mollie/engine.rb +2 -1
- data/lib/ideal-mollie/ideal_exception.rb +8 -3
- data/lib/ideal-mollie/order.rb +41 -0
- data/lib/ideal-mollie/order_result.rb +52 -0
- data/lib/ideal-mollie/version.rb +1 -1
- data/spec/config_spec.rb +2 -0
- data/spec/ideal_exception_spec.rb +10 -8
- data/spec/ideal_mollie_spec.rb +41 -33
- data/spec/spec_helper.rb +1 -2
- data/spec/vcr_cassettes/{check_payment.yml → check_order.yml} +0 -0
- data/spec/vcr_cassettes/{new_payment.yml → new_order.yml} +0 -0
- metadata +31 -28
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
- **26 January 2012**: version 0.0.3
|
4
|
+
- Added `Bank`, `Order` and `OrderResult`. Should be easier then hashes.
|
5
|
+
- Added example to the README
|
6
|
+
- Now you can override the return_url within the controller
|
7
|
+
|
8
|
+
- **25 January 2012**: version 0.0.2
|
9
|
+
- Dependecies fixed
|
10
|
+
- Tests fixed
|
11
|
+
- Automation with Travis and Gemnasium
|
12
|
+
|
3
13
|
- **25 January 2012**: version 0.0.1
|
4
14
|
- Initial release
|
data/README.md
CHANGED
@@ -34,20 +34,95 @@ git clone --depth 1 git://github.com/manuelvanrijn/ideal-mollie.git ideal-mollie
|
|
34
34
|
|
35
35
|
Add the following config parameters to your environment config file
|
36
36
|
|
37
|
-
```
|
37
|
+
```yaml
|
38
38
|
config.ideal_mollie.partner_id = 123456
|
39
39
|
config.ideal_mollie.report_url = "http://example.org/report"
|
40
40
|
config.ideal_mollie.return_url = "http://example.org/return"
|
41
41
|
config.ideal_mollie.test_mode = false
|
42
42
|
```
|
43
|
+
## Rails Example
|
44
|
+
|
45
|
+
Below you will find a simple `TransactionController` and a view to display the bank selectbox. Note that this is just a very basic example.
|
46
|
+
|
47
|
+
### Transaction Controller
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class TransactionsController < ApplicationController
|
51
|
+
def index
|
52
|
+
@banks = IdealMollie.banks
|
53
|
+
end
|
54
|
+
|
55
|
+
def start
|
56
|
+
# redirect to banks if there is no bank_id given
|
57
|
+
redirect_to transaction_path if params[:bank_id].nil?
|
58
|
+
bank_id = params[:bank_id]
|
59
|
+
|
60
|
+
# 10,00 EUR
|
61
|
+
request = IdealMollie.new_order(1000, 'some payment description', bank_id)
|
62
|
+
|
63
|
+
transaction_id = request.transaction_id
|
64
|
+
|
65
|
+
# TODO: store the transaction_id like:
|
66
|
+
# For example:
|
67
|
+
# my_order = MyOrderObject.find(id)
|
68
|
+
# my_order.transaction_id = transaction_id
|
69
|
+
# my_order.save
|
70
|
+
|
71
|
+
redirect_to request.url
|
72
|
+
end
|
73
|
+
|
74
|
+
def check
|
75
|
+
transaction_id = params[:transaction_id]
|
76
|
+
response = IdealMollie.check_order(transaction_id)
|
77
|
+
|
78
|
+
if response.payed
|
79
|
+
# TODO: store the result information for the payed payment
|
80
|
+
# For example:
|
81
|
+
# my_order = MyOrder.find_by_transaction_id(transaction_id)
|
82
|
+
# my_order.payed = true
|
83
|
+
# my_order.payed_on = Time.now
|
84
|
+
# my_order.customer_name = response.customer_name
|
85
|
+
# my_order.customer_account = response.customer_account
|
86
|
+
# my_order.customer_city = response.customer_city
|
87
|
+
# my_order.save
|
88
|
+
else
|
89
|
+
# canceled or re-checking?
|
90
|
+
if my_order.payed.nil?
|
91
|
+
# TODO: store the result information for the canceled payment
|
92
|
+
# For example:
|
93
|
+
# my_order = MyOrder.find_by_transaction_id(transaction_id)
|
94
|
+
# my_order.payed = false
|
95
|
+
# my_order.save
|
96
|
+
end
|
97
|
+
end
|
98
|
+
render :nothing => true
|
99
|
+
end
|
100
|
+
|
101
|
+
def result
|
102
|
+
# TODO show the result
|
103
|
+
# For example:
|
104
|
+
# my_order = MyOrderObject.find(id)
|
105
|
+
#if @my_order.payed
|
106
|
+
render :text => "Thank you for your payment."
|
107
|
+
else
|
108
|
+
render :text => "Transaction has been cancelled or couldn't complete"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
```
|
43
113
|
|
44
|
-
###
|
114
|
+
### View (transactions/index.html.erb)
|
45
115
|
|
46
|
-
|
116
|
+
```erb
|
117
|
+
<%= form_tag transaction_start_path, :method => :post do %>
|
118
|
+
<%= select_tag "bank_id", options_from_collection_for_select(@banks, "id", "name") %>
|
119
|
+
<%= button_submit_tag "Checkout" %>
|
120
|
+
<% end %>
|
121
|
+
```
|
47
122
|
|
48
123
|
## Changelog
|
49
124
|
|
50
|
-
A
|
125
|
+
A detailed overview of can be found in the [CHANGELOG](https://github.com/manuelvanrijn/ideal-mollie/blob/master/CHANGELOG.md).
|
51
126
|
|
52
127
|
## Copyright
|
53
128
|
|
data/ideal-mollie.gemspec
CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
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) }
|
18
19
|
s.require_paths = ["lib"]
|
19
20
|
|
20
21
|
s.add_development_dependency "rspec"
|
data/lib/ideal-mollie.rb
CHANGED
@@ -4,9 +4,12 @@ require "faraday_middleware"
|
|
4
4
|
require "multi_xml"
|
5
5
|
|
6
6
|
# Files
|
7
|
+
require "ideal-mollie/bank"
|
7
8
|
require "ideal-mollie/config"
|
8
|
-
require "ideal-mollie/ideal_exception"
|
9
9
|
require "ideal-mollie/engine" if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
10
|
+
require "ideal-mollie/ideal_exception"
|
11
|
+
require "ideal-mollie/order"
|
12
|
+
require "ideal-mollie/order_result"
|
10
13
|
|
11
14
|
#
|
12
15
|
# IdealMollie Module
|
@@ -19,115 +22,61 @@ module IdealMollie
|
|
19
22
|
#
|
20
23
|
# @example
|
21
24
|
# IdealMollie.banks
|
22
|
-
# # => [{:id=>"9999", :name=>"TBM Bank"}, ...]
|
23
25
|
#
|
24
|
-
# @return [Array] list of supported
|
26
|
+
# @return [Array<IdealMollie::Bank>] list of supported +Bank+'s.
|
25
27
|
def self.banks
|
26
28
|
response = IdealMollie.request("banklist")
|
27
29
|
|
28
30
|
banks = response["bank"]
|
29
31
|
banks = [banks] unless banks.is_a?Array # to array if it isn't already
|
30
32
|
|
31
|
-
banks.
|
32
|
-
{:id => bank["bank_id"], :name => bank["bank_name"]}
|
33
|
-
end
|
33
|
+
banks.inject([]) { |result, bank| result << IdealMollie::Bank.new(bank); result }
|
34
34
|
end
|
35
35
|
|
36
36
|
#
|
37
|
-
# Create a new
|
37
|
+
# Create a new order.
|
38
38
|
#
|
39
39
|
# @visibility public
|
40
40
|
#
|
41
41
|
# @param [int] amount The amount of money to transfer (defined in cents).
|
42
42
|
# @param [String] description The description of the payment on the bank transfer.
|
43
43
|
# @param [String] bank_id The id of the bank selected from one of the supported banks.
|
44
|
+
# @param [String] return_url Optional override of the return url specified in the Config
|
44
45
|
#
|
45
46
|
# @example
|
47
|
+
# IdealMollie.new_order(1000, "Ordernumber #123: new gadget", "0031")
|
46
48
|
#
|
47
|
-
#
|
48
|
-
# #
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# # :message=>"Your iDEAL-payment has successfully been setup. Your customer should visit the given URL to make the payment"
|
54
|
-
# # }
|
55
|
-
#
|
56
|
-
# @return [Hash] the transaction object
|
57
|
-
def self.new_payment(amount, description, bank_id)
|
58
|
-
response = IdealMollie.request("fetch", {
|
59
|
-
:partnerid => Config.partner_id,
|
60
|
-
:reporturl => Config.report_url,
|
61
|
-
:returnurl => Config.return_url,
|
62
|
-
:description => description,
|
63
|
-
:amount => amount,
|
64
|
-
:bank_id => bank_id
|
65
|
-
})
|
66
|
-
order = response["order"]
|
49
|
+
# @example
|
50
|
+
# IdealMollie.new_order(1000, "Ordernumber #123: new gadget", "0031", "http://override.url/controller/return_action")
|
51
|
+
# @return [IdealMollie::Order] the +Order+.
|
52
|
+
def self.new_order(amount, description, bank_id, return_url=nil)
|
53
|
+
params = new_order_params(amount, description, bank_id, return_url)
|
54
|
+
response = IdealMollie.request("fetch", params)
|
67
55
|
|
68
|
-
|
69
|
-
:transaction_id => order["transaction_id"],
|
70
|
-
:amount => order["amount"].to_i,
|
71
|
-
:currency => order["currency"],
|
72
|
-
:url => order["URL"],
|
73
|
-
:message => order["message"]
|
74
|
-
}
|
75
|
-
result
|
56
|
+
IdealMollie::Order.new(response["order"])
|
76
57
|
end
|
77
58
|
|
78
59
|
#
|
79
|
-
# Check the status of a
|
60
|
+
# Check the status of a order.
|
80
61
|
#
|
81
62
|
# @visibility public
|
82
63
|
#
|
83
64
|
# @param [String] transaction_id the transaction to verify.
|
84
65
|
#
|
85
66
|
# @example
|
86
|
-
# IdealMollie.
|
87
|
-
# # => {
|
88
|
-
# # :transaction_id => '4b99662febb42ce6f889d9c57f5cf3fa',
|
89
|
-
# # :amount => 1465,
|
90
|
-
# # :currency => "EUR",
|
91
|
-
# # :payed => true,
|
92
|
-
# # :consumer => {
|
93
|
-
# # :name => "Hr J Janssen",
|
94
|
-
# # :account => "P001234567",
|
95
|
-
# # :city => "Amsterdam"
|
96
|
-
# # },
|
97
|
-
# # :message => "This iDEAL-order has successfuly been payed for,
|
98
|
-
# # and this is the first time you check it.",
|
99
|
-
# # :status => "Expired"
|
100
|
-
# # }
|
67
|
+
# IdealMollie.check_order("4b99662febb42ce6f889d9c57f5cf3fa")
|
101
68
|
#
|
102
69
|
# @note Once a transaction is payed, only the next time you verify the
|
103
|
-
# transaction will the value of
|
104
|
-
# Else it will be
|
70
|
+
# transaction will the value of +payed+ be +true+.
|
71
|
+
# Else it will be +false+.
|
105
72
|
#
|
106
|
-
# @return [
|
107
|
-
def self.
|
73
|
+
# @return [IdealMollie::OrderResult] the +OrderResult+.
|
74
|
+
def self.check_order(transaction_id)
|
108
75
|
response = IdealMollie.request("check", {
|
109
76
|
:partnerid => Config.partner_id,
|
110
77
|
:transaction_id => transaction_id
|
111
78
|
})
|
112
|
-
|
113
|
-
|
114
|
-
result = {
|
115
|
-
:transaction_id => order["transaction_id"],
|
116
|
-
:amount => order["amount"].to_i,
|
117
|
-
:currency => order["currency"],
|
118
|
-
:payed => order["payed"] == "true" ? true : false,
|
119
|
-
:message => order["message"],
|
120
|
-
:status => order["status"]
|
121
|
-
}
|
122
|
-
if order.has_key?("consumer")
|
123
|
-
consumer = order["consumer"]
|
124
|
-
result.merge!(:consumer => {
|
125
|
-
:name => consumer["consumerName"],
|
126
|
-
:account => consumer["consumerAccount"],
|
127
|
-
:city => consumer["consumerCity"]
|
128
|
-
})
|
129
|
-
end
|
130
|
-
result
|
79
|
+
IdealMollie::OrderResult.new(response["order"])
|
131
80
|
end
|
132
81
|
|
133
82
|
class << self
|
@@ -142,7 +91,7 @@ module IdealMollie
|
|
142
91
|
#
|
143
92
|
# @raise [IdealMollie::IdealException] When a error is returned by Mollie
|
144
93
|
#
|
145
|
-
# @return [Hash] the returned XML as a Hash
|
94
|
+
# @return [Hash] the returned XML as a +Hash+
|
146
95
|
def request(action, params={})
|
147
96
|
params.merge!(:a => action)
|
148
97
|
params.merge!(:testmode => Config.test_mode)
|
@@ -158,6 +107,28 @@ module IdealMollie
|
|
158
107
|
response
|
159
108
|
end
|
160
109
|
|
110
|
+
#
|
111
|
+
# Builds a +Hash+ with the parameters, that are needed for making a new order
|
112
|
+
# Makes sure the +return_url+ is set to the correct value
|
113
|
+
#
|
114
|
+
# @param [int] amount The amount of money to transfer (defined in cents).
|
115
|
+
# @param [String] description The description of the payment on the bank transfer.
|
116
|
+
# @param [String] bank_id The id of the bank selected from one of the supported banks.
|
117
|
+
# @param [String] return_url Optional override of the return url specified in the Config
|
118
|
+
#
|
119
|
+
# @return [Hash] the parameter +Hash+ for the new order.
|
120
|
+
def new_order_params(amount, description, bank_id, return_url=nil)
|
121
|
+
return_url = Config.return_url if return_url.nil?
|
122
|
+
{
|
123
|
+
:partnerid => Config.partner_id,
|
124
|
+
:reporturl => Config.report_url,
|
125
|
+
:returnurl => return_url,
|
126
|
+
:description => description,
|
127
|
+
:amount => amount,
|
128
|
+
:bank_id => bank_id
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
161
132
|
private
|
162
133
|
|
163
134
|
def connection
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module IdealMollie
|
2
|
+
#
|
3
|
+
# Object representing a "Bank" object with attributes provided by Mollie
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# Bank.new({
|
7
|
+
# :bank_id => "0031"
|
8
|
+
# :bank_name => "ABN AMRO"
|
9
|
+
# })
|
10
|
+
class Bank
|
11
|
+
# @return [String] The id of the bank provided by Mollie.
|
12
|
+
attr_accessor :id
|
13
|
+
# @return [String] The name of the bank.
|
14
|
+
attr_accessor :name
|
15
|
+
|
16
|
+
#
|
17
|
+
# Initializer to transform a +Hash+ into an Bank object
|
18
|
+
#
|
19
|
+
# @param [Hash] values
|
20
|
+
def initialize(values=nil)
|
21
|
+
return if values.nil?
|
22
|
+
|
23
|
+
@id = values["bank_id"].to_s
|
24
|
+
@name = values["bank_name"].to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ideal-mollie/config.rb
CHANGED
@@ -3,9 +3,18 @@
|
|
3
3
|
#
|
4
4
|
module IdealMollie::Config
|
5
5
|
class << self
|
6
|
-
|
6
|
+
# @return [int] You Mollie partner id.
|
7
|
+
# @note You can find you partner id here: https://www.mollie.nl/beheer/betaaldiensten/documentatie/ideal/
|
8
|
+
attr_accessor :partner_id
|
9
|
+
# @return [String] The url Mollie uses to report the status of the payment
|
10
|
+
attr_accessor :report_url
|
11
|
+
# @return [String] The url Mollie sends you to when a transaction is finished
|
12
|
+
attr_accessor :return_url
|
13
|
+
# @return [Boolean] Test mode switch
|
14
|
+
attr_accessor :test_mode
|
7
15
|
|
8
16
|
# Set's the default value's to nil and false
|
17
|
+
# @return [Hash] configuration options
|
9
18
|
def init!
|
10
19
|
@defaults = {
|
11
20
|
:@partner_id => nil,
|
@@ -16,11 +25,13 @@ module IdealMollie::Config
|
|
16
25
|
end
|
17
26
|
|
18
27
|
# Resets the value's to there previous value (instance_variable)
|
28
|
+
# @return [Hash] configuration options
|
19
29
|
def reset!
|
20
30
|
@defaults.each { |key, value| instance_variable_set(key, value) }
|
21
31
|
end
|
22
32
|
|
23
33
|
# Set's the new value's as instance variables
|
34
|
+
# @return [Hash] configuration options
|
24
35
|
def update!
|
25
36
|
@defaults.each do |key, value|
|
26
37
|
instance_variable_set(key, value) unless instance_variable_defined?(key)
|
data/lib/ideal-mollie/engine.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module IdealMollie
|
2
2
|
#
|
3
|
-
# Simpel extend on the Rails::Engine to add support for a new config section within
|
3
|
+
# Simpel extend on the +Rails::Engine+ to add support for a new config section within
|
4
|
+
# the environment configs
|
4
5
|
#
|
5
6
|
# @example
|
6
7
|
# # /config/environments/development.rb
|
@@ -3,10 +3,15 @@ module IdealMollie
|
|
3
3
|
# Exception class specific for the IdealMollie error that might occur
|
4
4
|
#
|
5
5
|
class IdealException < Exception
|
6
|
-
|
6
|
+
# @return [String] The errorcode
|
7
|
+
attr_accessor :errorcode
|
8
|
+
# @return [String] The error description
|
9
|
+
attr_accessor :message
|
10
|
+
# @return [String] The error type
|
11
|
+
attr_accessor :type
|
7
12
|
|
8
|
-
# @param [String] errorcode The
|
9
|
-
# @param [String] message The error
|
13
|
+
# @param [String] errorcode The error code
|
14
|
+
# @param [String] message The error message
|
10
15
|
# @param [String] type The error type
|
11
16
|
def initialize(errorcode, message, type)
|
12
17
|
self.errorcode = errorcode
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module IdealMollie
|
2
|
+
#
|
3
|
+
# Object representing a "Order" object with attributes provided by Mollie
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# Order.new({
|
7
|
+
# :transaction_id => "c9f93e5c2bd6c1e7c5bee5c5580c6f83"
|
8
|
+
# :amount => "1000",
|
9
|
+
# :currency => "EUR"
|
10
|
+
# :url => "https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=8433910909&trxid=30000217841224"
|
11
|
+
# :message => "Your iDEAL-payment has successfully been setup. Your customer should visit the given URL to make the payment"
|
12
|
+
# })
|
13
|
+
#
|
14
|
+
# @note The amount is always specified in *cents*. So 10,00 EUR would be 1000.
|
15
|
+
class Order
|
16
|
+
# @return [String] A unique id generated by Mollie.
|
17
|
+
attr_accessor :transaction_id
|
18
|
+
# @return [int] The amount of money for the transaction.
|
19
|
+
attr_accessor :amount
|
20
|
+
# @return [String] The currency for the transaction.
|
21
|
+
attr_accessor :currency
|
22
|
+
# @return [String] The url to the bank, to complete payment.
|
23
|
+
attr_accessor :url
|
24
|
+
# @return [String] A message with additional information about the Order.
|
25
|
+
attr_accessor :message
|
26
|
+
|
27
|
+
#
|
28
|
+
# Initializer to transform a +Hash+ into an Order object
|
29
|
+
#
|
30
|
+
# @param [Hash] values
|
31
|
+
def initialize(values=nil)
|
32
|
+
return if values.nil?
|
33
|
+
|
34
|
+
@transaction_id = values["transaction_id"].to_s if values.has_key?("transaction_id")
|
35
|
+
@amount = values["amount"].to_i if values.has_key?("amount")
|
36
|
+
@currency = values["currency"].to_s if values.has_key?("currency")
|
37
|
+
@url = values["URL"].to_s if values.has_key?("URL")
|
38
|
+
@message = values["message"].to_s if values.has_key?("message")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module IdealMollie
|
2
|
+
#
|
3
|
+
# Object representing a "OrderResult" object with attributes provided by Mollie
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# Order.new({
|
7
|
+
# :transaction_id => "4b99662febb42ce6f889d9c57f5cf3fa",
|
8
|
+
# :amount => 1465,
|
9
|
+
# :currency => "EUR",
|
10
|
+
# :payed => true,
|
11
|
+
# :consumer => {
|
12
|
+
# :consumerName => "Hr J Janssen",
|
13
|
+
# :consumerAccount => "P001234567",
|
14
|
+
# :consumerCity => "Amsterdam"
|
15
|
+
# },
|
16
|
+
# :message => "This iDEAL-order has successfuly been payed for,
|
17
|
+
# and this is the first time you check it.",
|
18
|
+
# :status => "Expired"
|
19
|
+
# })
|
20
|
+
class OrderResult < Order
|
21
|
+
# @return [Boolean] Order was payed.
|
22
|
+
attr_accessor :payed
|
23
|
+
# @return [String] The name of the customer.
|
24
|
+
attr_accessor :customer_name
|
25
|
+
# @return [String] The bankaccount number of the customer.
|
26
|
+
attr_accessor :customer_account
|
27
|
+
# @return [String] The city of the customer.
|
28
|
+
attr_accessor :customer_city
|
29
|
+
# @return [String] Status of the Order.
|
30
|
+
attr_accessor :status
|
31
|
+
|
32
|
+
#
|
33
|
+
# Initializer to transform a +Hash+ into an OrderResult object
|
34
|
+
#
|
35
|
+
# @param [Hash] values
|
36
|
+
def initialize(values=nil)
|
37
|
+
return if values.nil?
|
38
|
+
|
39
|
+
super(values)
|
40
|
+
|
41
|
+
@payed = values["payed"] == "true" ? true : false if values.has_key?("payed")
|
42
|
+
@status = values["status"].to_s if values.has_key?("status")
|
43
|
+
|
44
|
+
if values.has_key?("consumer")
|
45
|
+
consumer = values["consumer"]
|
46
|
+
@customer_name = consumer["consumerName"].to_s if consumer.has_key?("consumerName")
|
47
|
+
@customer_account = consumer["consumerAccount"].to_s if consumer.has_key?("consumerAccount")
|
48
|
+
@customer_city = consumer["consumerCity"].to_s if consumer.has_key?("consumerCity")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/ideal-mollie/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -8,6 +8,7 @@ describe IdealMollie::Config do
|
|
8
8
|
@config.report_url = "http://example.org/report"
|
9
9
|
@config.return_url = "http://example.org/return"
|
10
10
|
end
|
11
|
+
|
11
12
|
describe "#reset!" do
|
12
13
|
it "should reset the values" do
|
13
14
|
@config.reset!
|
@@ -17,6 +18,7 @@ describe IdealMollie::Config do
|
|
17
18
|
@config.return_url.should be_nil
|
18
19
|
end
|
19
20
|
end
|
21
|
+
|
20
22
|
describe "#update!" do
|
21
23
|
it "should update" do
|
22
24
|
@config.test_mode = false
|
@@ -1,15 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe IdealMollie::IdealException do
|
4
|
-
context "#
|
4
|
+
context "#new_order" do
|
5
5
|
it "should throw exception when no config is set" do
|
6
|
-
VCR.use_cassette("
|
6
|
+
VCR.use_cassette("new_order") do
|
7
7
|
config = IdealMollie::Config
|
8
8
|
config.reset!
|
9
|
-
expect { IdealMollie.
|
9
|
+
expect { IdealMollie.new_order(1234, "exception test", "0031") }.
|
10
10
|
to raise_error(IdealMollie::IdealException, /A fetch was issued without specification of 'partnerid'./)
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
13
14
|
it "should throw an exception when a unknown account is specified" do
|
14
15
|
config = IdealMollie::Config
|
15
16
|
config.test_mode = false
|
@@ -17,13 +18,14 @@ describe IdealMollie::IdealException do
|
|
17
18
|
config.report_url = "http://example.org/report"
|
18
19
|
config.return_url = "http://example.org/return"
|
19
20
|
|
20
|
-
VCR.use_cassette("
|
21
|
-
expect { IdealMollie.
|
21
|
+
VCR.use_cassette("new_order") do
|
22
|
+
expect { IdealMollie.new_order(1234, "exception test", "0031") }.
|
22
23
|
to raise_error(IdealMollie::IdealException, /This account does not exist or is suspended./)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
26
|
-
|
27
|
+
|
28
|
+
context "#check_order" do
|
27
29
|
it "should raise an exception when a invalid transaction_id is asked" do
|
28
30
|
config = IdealMollie::Config
|
29
31
|
config.test_mode = false
|
@@ -31,8 +33,8 @@ describe IdealMollie::IdealException do
|
|
31
33
|
config.report_url = "http://example.org/report"
|
32
34
|
config.return_url = "http://example.org/return"
|
33
35
|
|
34
|
-
VCR.use_cassette("
|
35
|
-
expect { IdealMollie.
|
36
|
+
VCR.use_cassette("check_order") do
|
37
|
+
expect { IdealMollie.check_order("482d599bbcc7795727650330ad65fe9b") }.
|
36
38
|
to raise_error(IdealMollie::IdealException, /This is an unknown order./)
|
37
39
|
end
|
38
40
|
end
|
data/spec/ideal_mollie_spec.rb
CHANGED
@@ -17,49 +17,57 @@ describe IdealMollie do
|
|
17
17
|
banks.count > 0
|
18
18
|
|
19
19
|
bank = banks.first
|
20
|
-
bank
|
21
|
-
bank
|
20
|
+
bank.id.should eq "0031"
|
21
|
+
bank.name.should eq "ABN AMRO"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
context "#
|
27
|
-
it "should return a
|
28
|
-
VCR.use_cassette("
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
context "#new_order" do
|
27
|
+
it "should return a Order with the correct values" do
|
28
|
+
VCR.use_cassette("new_order") do
|
29
|
+
order = IdealMollie.new_order(1000, "test", "0031")
|
30
|
+
order.transaction_id.should eq "c9f93e5c2bd6c1e7c5bee5c5580c6f83"
|
31
|
+
order.amount.should eq 1000
|
32
|
+
order.currency.should eq "EUR"
|
33
|
+
order.url.should eq "https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=8433910909&trxid=30000217841224"
|
34
|
+
order.message.should eq "Your iDEAL-payment has successfully been setup. Your customer should visit the given URL to make the payment"
|
35
35
|
end
|
36
36
|
end
|
37
|
+
it "should override the return url when specified" do
|
38
|
+
params = IdealMollie.new_order_params(1200, "test", "0031")
|
39
|
+
params[:returnurl].should eq "http://example.org/return"
|
40
|
+
|
41
|
+
params = IdealMollie.new_order_params(1200, "test", "0031", "http://another.example.org/return")
|
42
|
+
params[:returnurl].should eq "http://another.example.org/return"
|
43
|
+
end
|
37
44
|
end
|
38
45
|
|
39
|
-
context "#
|
40
|
-
it "should return a
|
41
|
-
VCR.use_cassette("
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
context "#check_order" do
|
47
|
+
it "should return a OrderResult with the correct values" do
|
48
|
+
VCR.use_cassette("check_order") do
|
49
|
+
order_result = IdealMollie.check_order("c9f93e5c2bd6c1e7c5bee5c5580c6f83")
|
50
|
+
order_result.transaction_id.should eq "c9f93e5c2bd6c1e7c5bee5c5580c6f83"
|
51
|
+
order_result.amount.should eq 1000
|
52
|
+
order_result.currency.should eq "EUR"
|
53
|
+
order_result.payed.should eq false
|
54
|
+
order_result.message.should eq "This iDEAL-order wasn't payed for, or was already checked by you. (We give payed=true only once, for your protection)"
|
55
|
+
order_result.status.should eq "CheckedBefore"
|
49
56
|
end
|
50
57
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
|
59
|
+
it "should mark the OrderResult as payed and contain the customer information when called by mollie" do
|
60
|
+
VCR.use_cassette("check_order") do
|
61
|
+
order_result = IdealMollie.check_order("482d599bbcc7795727650330ad65fe9b")
|
62
|
+
order_result.transaction_id.should eq "482d599bbcc7795727650330ad65fe9b"
|
63
|
+
order_result.amount.should eq 1000
|
64
|
+
order_result.currency.should eq "EUR"
|
65
|
+
order_result.payed.should eq true
|
66
|
+
order_result.message.should eq "This iDEAL-order has successfuly been payed for, and this is the first time you check it."
|
67
|
+
|
68
|
+
order_result.customer_name.should eq "Hr J Janssen"
|
69
|
+
order_result.customer_account.should eq "P001234567"
|
70
|
+
order_result.customer_city.should eq "Amsterdam"
|
63
71
|
end
|
64
72
|
end
|
65
73
|
end
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
File without changes
|
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
|
+
version: 0.0.3
|
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-
|
12
|
+
date: 2012-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &12831420 !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: *
|
24
|
+
version_requirements: *12831420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &12830360 !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: *
|
35
|
+
version_requirements: *12830360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fakeweb
|
38
|
-
requirement: &
|
38
|
+
requirement: &12829240 !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: *
|
46
|
+
version_requirements: *12829240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &12828120 !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: *
|
57
|
+
version_requirements: *12828120
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: redcarpet
|
60
|
-
requirement: &
|
60
|
+
requirement: &12826860 !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: *
|
68
|
+
version_requirements: *12826860
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
|
-
requirement: &
|
71
|
+
requirement: &12825560 !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: *
|
79
|
+
version_requirements: *12825560
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rake
|
82
|
-
requirement: &
|
82
|
+
requirement: &12824660 !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: *
|
90
|
+
version_requirements: *12824660
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: faraday
|
93
|
-
requirement: &
|
93
|
+
requirement: &12837640 !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: *
|
101
|
+
version_requirements: *12837640
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: faraday_middleware
|
104
|
-
requirement: &
|
104
|
+
requirement: &12836900 !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: *
|
112
|
+
version_requirements: *12836900
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: multi_xml
|
115
|
-
requirement: &
|
115
|
+
requirement: &12834660 !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: *
|
123
|
+
version_requirements: *12834660
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: nokogiri
|
126
|
-
requirement: &
|
126
|
+
requirement: &12848640 !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: *
|
134
|
+
version_requirements: *12848640
|
135
135
|
description: A simple Ruby implementation for handeling iDeal transactions with the
|
136
136
|
Mollie API
|
137
137
|
email:
|
@@ -151,17 +151,20 @@ files:
|
|
151
151
|
- Rakefile
|
152
152
|
- ideal-mollie.gemspec
|
153
153
|
- lib/ideal-mollie.rb
|
154
|
+
- lib/ideal-mollie/bank.rb
|
154
155
|
- lib/ideal-mollie/config.rb
|
155
156
|
- lib/ideal-mollie/engine.rb
|
156
157
|
- lib/ideal-mollie/ideal_exception.rb
|
158
|
+
- lib/ideal-mollie/order.rb
|
159
|
+
- lib/ideal-mollie/order_result.rb
|
157
160
|
- lib/ideal-mollie/version.rb
|
158
161
|
- spec/config_spec.rb
|
159
162
|
- spec/ideal_exception_spec.rb
|
160
163
|
- spec/ideal_mollie_spec.rb
|
161
164
|
- spec/spec_helper.rb
|
162
165
|
- spec/vcr_cassettes/banks.yml
|
163
|
-
- spec/vcr_cassettes/
|
164
|
-
- spec/vcr_cassettes/
|
166
|
+
- spec/vcr_cassettes/check_order.yml
|
167
|
+
- spec/vcr_cassettes/new_order.yml
|
165
168
|
- spec/vcr_cassettes/request_payment.yml
|
166
169
|
homepage: https://github.com/manuelvanrijn/ideal-mollie
|
167
170
|
licenses: []
|
@@ -177,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
180
|
version: '0'
|
178
181
|
segments:
|
179
182
|
- 0
|
180
|
-
hash:
|
183
|
+
hash: -3816386497103677641
|
181
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
185
|
none: false
|
183
186
|
requirements:
|
@@ -186,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
189
|
version: '0'
|
187
190
|
segments:
|
188
191
|
- 0
|
189
|
-
hash:
|
192
|
+
hash: -3816386497103677641
|
190
193
|
requirements: []
|
191
194
|
rubyforge_project: ideal-mollie
|
192
195
|
rubygems_version: 1.8.11
|