mollie-payment 0.1.0 → 0.5.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/.rspec +2 -0
- data/README.md +3 -2
- data/Rakefile +13 -0
- data/lib/{mollie-ideal.rb → mollie-payment.rb} +0 -0
- data/lib/mollie/ideal.rb +92 -19
- data/lib/mollie/payment/version.rb +5 -0
- data/mollie-ideal.gemspec +10 -4
- data/spec/fixtures/vcr_cassettes/banks.yml +39 -0
- data/spec/fixtures/vcr_cassettes/request_transaction.yml +66 -0
- data/spec/fixtures/vcr_cassettes/verify_transaction.yml +34 -0
- data/spec/mollie/ideal_spec.rb +66 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +14 -0
- metadata +79 -11
- data/lib/mollie/ideal/version.rb +0 -5
data/.rspec
ADDED
data/README.md
CHANGED
|
@@ -3,9 +3,9 @@ Mollie Payment
|
|
|
3
3
|
|
|
4
4
|
This repository is currently a work in progress and under [Documentation Driven Development](http://thinkingphp.org/spliceit/docs/0.1_alpha/pages/ddd_info.html).
|
|
5
5
|
|
|
6
|
-
On the one hand to get familiar with documenting and [YARD](http://yardoc.org/). On the other hand to
|
|
6
|
+
On the one hand to get familiar with documenting and [YARD](http://yardoc.org/). On the other hand to focus on creating an opiniated Ruby-wrapper for the Mollie [iDEAL API](https://www.mollie.nl/beheer/betaaldiensten/documentatie/ideal/).
|
|
7
7
|
|
|
8
|
-
The generated docs can be [found here](http://rubydoc.info/gems/mollie-payment
|
|
8
|
+
The generated docs can be [found here](http://rubydoc.info/gems/mollie-payment).
|
|
9
9
|
|
|
10
10
|
Develop
|
|
11
11
|
------------
|
|
@@ -13,6 +13,7 @@ Develop
|
|
|
13
13
|
$ git clone git://github.com/eval/mollie-payment.git
|
|
14
14
|
$ cd mollie-payment
|
|
15
15
|
$ bundle
|
|
16
|
+
$ bundle exec autotest -s rspec2
|
|
16
17
|
|
|
17
18
|
Author
|
|
18
19
|
------
|
data/Rakefile
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
|
+
require "rspec/core/rake_task"
|
|
3
|
+
|
|
4
|
+
RSpec::Core::RakeTask.new do |t|
|
|
5
|
+
t.rspec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
desc "Run the specs"
|
|
9
|
+
task :default => :spec
|
|
10
|
+
|
|
11
|
+
desc 'Removes trailing whitespace'
|
|
12
|
+
task :whitespace do
|
|
13
|
+
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
|
|
14
|
+
end
|
|
File without changes
|
data/lib/mollie/ideal.rb
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
|
|
1
3
|
module Mollie
|
|
2
4
|
class Ideal
|
|
5
|
+
include HTTParty
|
|
6
|
+
base_uri 'https://secure.mollie.nl/xml/ideal'
|
|
7
|
+
|
|
8
|
+
attr_reader :partner_id, :production
|
|
3
9
|
# Create a new Ideal object
|
|
4
10
|
#
|
|
5
11
|
# @param [String] partner_id your Mollie partner id
|
|
6
12
|
# @param [Hash] options
|
|
7
|
-
# @option options [Boolean] :production (false) whether or not to operate
|
|
13
|
+
# @option options [Boolean] :production (false) whether or not to operate
|
|
8
14
|
# in production-mode
|
|
9
|
-
def initialize(partner_id, options={:production => false})
|
|
15
|
+
def initialize(partner_id, options={:production => false})
|
|
16
|
+
@partner_id = partner_id
|
|
17
|
+
@production = options[:production]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
alias :production? :production
|
|
10
21
|
|
|
11
22
|
# All supported banks.
|
|
12
23
|
#
|
|
@@ -17,7 +28,12 @@ module Mollie
|
|
|
17
28
|
# # => [{:id => '0031', :name => 'ABN AMRO'}, ...]
|
|
18
29
|
#
|
|
19
30
|
# @return [Array<Hash{Symbol => String}>] the list of banks.
|
|
20
|
-
def self.banks
|
|
31
|
+
def self.banks
|
|
32
|
+
resp = get('', :query => {:a => 'banklist'}).parsed_response
|
|
33
|
+
resp["response"]["bank"].map do |b|
|
|
34
|
+
{:id => b["bank_id"], :name => b["bank_name"]}
|
|
35
|
+
end
|
|
36
|
+
end
|
|
21
37
|
class << self
|
|
22
38
|
alias :banklist :banks
|
|
23
39
|
end
|
|
@@ -29,20 +45,20 @@ module Mollie
|
|
|
29
45
|
# @param [Hash] opts
|
|
30
46
|
# @option opts [Fixnum] :amount the amount in cents.
|
|
31
47
|
# @option opts [String] :bank_id the id of the bank (see {banks}).
|
|
32
|
-
# @option opts [String] :description description of the transaction
|
|
48
|
+
# @option opts [String] :description description of the transaction
|
|
33
49
|
# (max. 30 characters).
|
|
34
|
-
# @option opts [String] :report_url address where the result of the
|
|
50
|
+
# @option opts [String] :report_url address where the result of the
|
|
35
51
|
# transaction is sent (POSTed?).
|
|
36
52
|
# @option opts [String] :return_url address where the visitor is sent.
|
|
37
|
-
# @option opts [String] :profile_key (nil) the profile this transaction
|
|
53
|
+
# @option opts [String] :profile_key (nil) the profile this transaction
|
|
38
54
|
# should be linked to.
|
|
39
|
-
#
|
|
55
|
+
#
|
|
40
56
|
# @example
|
|
41
|
-
#
|
|
42
|
-
# mi = Mollie::Ideal.new('12345')
|
|
43
|
-
# mi.request_transaction(:amount => 1465,
|
|
57
|
+
#
|
|
58
|
+
# mi = Mollie::Ideal.new('12345')
|
|
59
|
+
# mi.request_transaction(:amount => 1465,
|
|
44
60
|
# :bank_id => '0721',
|
|
45
|
-
# :description => "Charlie Brown's Tree",
|
|
61
|
+
# :description => "Charlie Brown's Tree",
|
|
46
62
|
# :report_url => 'http://example.org/report',
|
|
47
63
|
# :return_url => 'http://example.org/return')
|
|
48
64
|
# # => {
|
|
@@ -53,7 +69,23 @@ module Mollie
|
|
|
53
69
|
# # }
|
|
54
70
|
#
|
|
55
71
|
# @return [Hash] the transaction (see example)
|
|
56
|
-
def request_transaction(
|
|
72
|
+
def request_transaction(options={})
|
|
73
|
+
query_options = options_to_query_options(options)
|
|
74
|
+
|
|
75
|
+
query_options.merge!(:a => 'fetch', :partnerid => self.partner_id)
|
|
76
|
+
query_options.merge!(:testmode => 'true') unless self.production?
|
|
77
|
+
|
|
78
|
+
resp = self.class.get('', :query => query_options).parsed_response
|
|
79
|
+
order = resp["response"]["order"]
|
|
80
|
+
|
|
81
|
+
%w(transaction_id amount currency url).map(&:to_sym).inject({}) do |res, k|
|
|
82
|
+
v = order[k.to_s]
|
|
83
|
+
v = v.to_i if k == :amount
|
|
84
|
+
|
|
85
|
+
res[k] = v
|
|
86
|
+
res
|
|
87
|
+
end
|
|
88
|
+
end
|
|
57
89
|
|
|
58
90
|
# Verify the status of a transaction.
|
|
59
91
|
#
|
|
@@ -61,7 +93,7 @@ module Mollie
|
|
|
61
93
|
#
|
|
62
94
|
# @param [Hash] options
|
|
63
95
|
# @option options [String] :transaction_id the transaction to verify.
|
|
64
|
-
#
|
|
96
|
+
#
|
|
65
97
|
# @example
|
|
66
98
|
# mi = Mollie::Ideal.new('12345')
|
|
67
99
|
# mi.verify_transaction(:transaction_id => '482d599bbcc7795727650330ad65fe9b')
|
|
@@ -75,15 +107,56 @@ module Mollie
|
|
|
75
107
|
# # :account => 'P001234567',
|
|
76
108
|
# # :city => 'Amsterdam'
|
|
77
109
|
# # },
|
|
78
|
-
# # :message => 'This iDEAL-order has successfuly been payed for,
|
|
79
|
-
# # and this is the first time you check it.'
|
|
110
|
+
# # :message => 'This iDEAL-order has successfuly been payed for,
|
|
111
|
+
# # and this is the first time you check it.',
|
|
112
|
+
# # :status => 'Expired'
|
|
80
113
|
# # }
|
|
81
|
-
#
|
|
82
|
-
#
|
|
114
|
+
#
|
|
83
115
|
# @note Once a transaction is payed, only the next time you verify the
|
|
84
|
-
# transaction will the value of 'payed' be 'true'.
|
|
116
|
+
# transaction will the value of 'payed' be 'true'.
|
|
85
117
|
# Else it will be 'false'.
|
|
86
118
|
# @return [Hash] the status of the transaction (see example)
|
|
87
|
-
def verify_transaction(options)
|
|
119
|
+
def verify_transaction(options={})
|
|
120
|
+
query_options = options_to_query_options(options)
|
|
121
|
+
query_options.merge!(:a => 'check', :partnerid => self.partner_id)
|
|
122
|
+
query_options.merge!(:testmode => 'true') unless self.production?
|
|
123
|
+
|
|
124
|
+
resp = self.class.get('', :query => query_options).parsed_response
|
|
125
|
+
order = resp["response"]["order"]
|
|
126
|
+
|
|
127
|
+
result = %w(transaction_id amount currency payed status message).map(&:to_sym).inject({}) do |res, k|
|
|
128
|
+
v = order[k.to_s]
|
|
129
|
+
v = v.to_i if k == :amount
|
|
130
|
+
v = (v == 'true') if k == :payed
|
|
131
|
+
|
|
132
|
+
res[k] = v
|
|
133
|
+
res
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if consumer = order["consumer"]
|
|
137
|
+
consumer = {'consumerName' => 'name', 'consumerAccount' => 'account', 'consumerCity' => 'city'}.inject({}) do |res, (theirs, ours)|
|
|
138
|
+
res[ours.to_sym] = consumer[theirs]
|
|
139
|
+
res
|
|
140
|
+
end
|
|
141
|
+
result[:consumer] = consumer
|
|
142
|
+
end
|
|
143
|
+
result
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
protected
|
|
147
|
+
# Convert our naming to their naming
|
|
148
|
+
def options_to_query_options(options)
|
|
149
|
+
{
|
|
150
|
+
:bank_id => :bank_id,
|
|
151
|
+
:amount => :amount,
|
|
152
|
+
:return_url => :returnurl,
|
|
153
|
+
:report_url => :reporturl,
|
|
154
|
+
:description => :description,
|
|
155
|
+
:transaction_id => :transaction_id
|
|
156
|
+
}.inject({}) do |result, (ours, theirs)|
|
|
157
|
+
result[theirs] = options[ours] if options[ours]
|
|
158
|
+
result
|
|
159
|
+
end
|
|
160
|
+
end
|
|
88
161
|
end
|
|
89
162
|
end
|
data/mollie-ideal.gemspec
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
-
require "mollie/
|
|
3
|
+
require "mollie/payment/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
6
|
s.name = "mollie-payment"
|
|
7
|
-
s.version = Mollie::
|
|
7
|
+
s.version = Mollie::Payment::VERSION
|
|
8
8
|
s.authors = ["Gert Goet"]
|
|
9
9
|
s.email = ["gert@thinkcreate.nl"]
|
|
10
10
|
s.homepage = "https://github.com/eval/mollie-payment"
|
|
11
|
-
s.summary = %q{
|
|
12
|
-
s.description = %q{
|
|
11
|
+
s.summary = %q{Client for the Mollie API (currently iDEAL only}
|
|
12
|
+
s.description = %q{Client for the Mollie API (currently iDEAL only}
|
|
13
13
|
|
|
14
14
|
s.rubyforge_project = "mollie-payment"
|
|
15
15
|
|
|
@@ -18,6 +18,12 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
19
|
s.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
+
s.add_dependency "httparty"
|
|
22
|
+
|
|
21
23
|
s.add_development_dependency "yard"
|
|
22
24
|
s.add_development_dependency "rdiscount"
|
|
25
|
+
s.add_development_dependency "rspec"
|
|
26
|
+
s.add_development_dependency "ZenTest"
|
|
27
|
+
s.add_development_dependency "vcr"
|
|
28
|
+
s.add_development_dependency "webmock"
|
|
23
29
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
3
|
+
request: !ruby/struct:VCR::Request
|
|
4
|
+
method: :get
|
|
5
|
+
uri: https://secure.mollie.nl:443/xml/ideal?a=banklist
|
|
6
|
+
body: !!null
|
|
7
|
+
headers: !!null
|
|
8
|
+
response: !ruby/struct:VCR::Response
|
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
10
|
+
code: 200
|
|
11
|
+
message: OK
|
|
12
|
+
headers:
|
|
13
|
+
server:
|
|
14
|
+
- nginx/0.7.67
|
|
15
|
+
date:
|
|
16
|
+
- Thu, 01 Dec 2011 15:41:34 GMT
|
|
17
|
+
content-type:
|
|
18
|
+
- text/xml
|
|
19
|
+
connection:
|
|
20
|
+
- keep-alive
|
|
21
|
+
content-location:
|
|
22
|
+
- ideal.php
|
|
23
|
+
vary:
|
|
24
|
+
- negotiate
|
|
25
|
+
tcn:
|
|
26
|
+
- choice
|
|
27
|
+
x-powered-by:
|
|
28
|
+
- PHP/5.2.6-1+lenny13
|
|
29
|
+
content-length:
|
|
30
|
+
- '854'
|
|
31
|
+
body: ! "<?xml version=\"1.0\" ?>\n<response>\n\t<bank>\n\t\t<bank_id>0031</bank_id>\n\t\t<bank_name>ABN
|
|
32
|
+
AMRO</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0761</bank_id>\n\t\t<bank_name>ASN
|
|
33
|
+
Bank</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0091</bank_id>\n\t\t<bank_name>Friesland
|
|
34
|
+
Bank</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0721</bank_id>\n\t\t<bank_name>ING</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0021</bank_id>\n\t\t<bank_name>Rabobank</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0771</bank_id>\n\t\t<bank_name>RegioBank</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0751</bank_id>\n\t\t<bank_name>SNS
|
|
35
|
+
Bank</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0511</bank_id>\n\t\t<bank_name>Triodos
|
|
36
|
+
Bank</bank_name>\n\t</bank>\n\t<bank>\n\t\t<bank_id>0161</bank_id>\n\t\t<bank_name>van
|
|
37
|
+
Lanschot</bank_name>\n\t</bank>\n<message>This is the current list of banks
|
|
38
|
+
and their ID's that currently support iDEAL-payments</message>\n</response>"
|
|
39
|
+
http_version: '1.1'
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
3
|
+
request: !ruby/struct:VCR::Request
|
|
4
|
+
method: :get
|
|
5
|
+
uri: https://secure.mollie.nl:443/xml/ideal?a=fetch&amount=12345&bank_id=0031&description=description%20goes%20here&partnerid=123456&reporturl=http://example.org/report&returnurl=http://example.org/return&testmode=true
|
|
6
|
+
body: !!null
|
|
7
|
+
headers: !!null
|
|
8
|
+
response: !ruby/struct:VCR::Response
|
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
10
|
+
code: 200
|
|
11
|
+
message: OK
|
|
12
|
+
headers:
|
|
13
|
+
server:
|
|
14
|
+
- nginx/0.7.67
|
|
15
|
+
date:
|
|
16
|
+
- Thu, 01 Dec 2011 20:45:53 GMT
|
|
17
|
+
content-type:
|
|
18
|
+
- text/xml
|
|
19
|
+
connection:
|
|
20
|
+
- keep-alive
|
|
21
|
+
content-location:
|
|
22
|
+
- ideal.php
|
|
23
|
+
vary:
|
|
24
|
+
- negotiate
|
|
25
|
+
tcn:
|
|
26
|
+
- choice
|
|
27
|
+
x-powered-by:
|
|
28
|
+
- PHP/5.2.6-1+lenny13
|
|
29
|
+
content-length:
|
|
30
|
+
- '430'
|
|
31
|
+
body: ! "<?xml version=\"1.0\" ?>\n<response>\n\t<order>\n\t\t<transaction_id>e0be830d5e46289e7da9636beb84729e</transaction_id>\n\t\t<amount>12345</amount>\n\t\t<currency>EUR</currency>\n\t\t<URL>https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=4164247836&trxid=30000182948803</URL>\n\t\t<message>Your
|
|
32
|
+
iDEAL-payment has successfully been setup. Your customer should visit the given
|
|
33
|
+
URL to make the payment</message>\n\t</order>\n</response>"
|
|
34
|
+
http_version: '1.1'
|
|
35
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
36
|
+
request: !ruby/struct:VCR::Request
|
|
37
|
+
method: :get
|
|
38
|
+
uri: https://secure.mollie.nl:443/xml/ideal?a=fetch&amount=&bank_id=&description=&partnerid=123456&reporturl=&returnurl=&testmode=true
|
|
39
|
+
body: !!null
|
|
40
|
+
headers: !!null
|
|
41
|
+
response: !ruby/struct:VCR::Response
|
|
42
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
43
|
+
code: 200
|
|
44
|
+
message: OK
|
|
45
|
+
headers:
|
|
46
|
+
server:
|
|
47
|
+
- nginx/0.7.67
|
|
48
|
+
date:
|
|
49
|
+
- Thu, 01 Dec 2011 20:45:53 GMT
|
|
50
|
+
content-type:
|
|
51
|
+
- text/html
|
|
52
|
+
connection:
|
|
53
|
+
- keep-alive
|
|
54
|
+
content-location:
|
|
55
|
+
- ideal.php
|
|
56
|
+
vary:
|
|
57
|
+
- negotiate
|
|
58
|
+
tcn:
|
|
59
|
+
- choice
|
|
60
|
+
x-powered-by:
|
|
61
|
+
- PHP/5.2.6-1+lenny13
|
|
62
|
+
content-length:
|
|
63
|
+
- '189'
|
|
64
|
+
body: ! "<?xml version=\"1.0\" ?>\n<response>\n\t<item type=\"error\">\n\t\t<errorcode>-3</errorcode>\n\t\t<message>A
|
|
65
|
+
fetch was issued without (proper) specification of 'reporturl'</message>\n\t</item>\n</response>"
|
|
66
|
+
http_version: '1.1'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
3
|
+
request: !ruby/struct:VCR::Request
|
|
4
|
+
method: :get
|
|
5
|
+
uri: https://secure.mollie.nl:443/xml/ideal?a=check&partnerid=123456&testmode=true&transaction_id=e0be830d5e46289e7da9636beb84729e
|
|
6
|
+
body: !!null
|
|
7
|
+
headers: !!null
|
|
8
|
+
response: !ruby/struct:VCR::Response
|
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
10
|
+
code: 200
|
|
11
|
+
message: OK
|
|
12
|
+
headers:
|
|
13
|
+
server:
|
|
14
|
+
- nginx/0.7.67
|
|
15
|
+
date:
|
|
16
|
+
- Fri, 02 Dec 2011 11:49:35 GMT
|
|
17
|
+
content-type:
|
|
18
|
+
- text/xml
|
|
19
|
+
connection:
|
|
20
|
+
- keep-alive
|
|
21
|
+
content-location:
|
|
22
|
+
- ideal.php
|
|
23
|
+
vary:
|
|
24
|
+
- negotiate
|
|
25
|
+
tcn:
|
|
26
|
+
- choice
|
|
27
|
+
x-powered-by:
|
|
28
|
+
- PHP/5.2.6-1+lenny13
|
|
29
|
+
content-length:
|
|
30
|
+
- '380'
|
|
31
|
+
body: ! "<?xml version=\"1.0\" ?>\n<response>\n\t<order>\n\t\t<transaction_id>e0be830d5e46289e7da9636beb84729e</transaction_id>\n\t\t<amount>12345</amount>\n\t\t<currency>EUR</currency>\n\t\t<payed>false</payed>\n\t\t<message>This
|
|
32
|
+
iDEAL-order wasn't payed for, or was already checked by you. (We give payed=true
|
|
33
|
+
only once, for your protection)</message>\n\t\t<status>CheckedBefore</status>\n\t</order>\n\n</response>"
|
|
34
|
+
http_version: '1.1'
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Mollie::Ideal do
|
|
4
|
+
context "#banks" do
|
|
5
|
+
it "returns an array with hashes containing keys :id and :name" do
|
|
6
|
+
VCR.use_cassette('banks') do
|
|
7
|
+
banks = described_class.banks
|
|
8
|
+
banks.class.should == Array
|
|
9
|
+
banks.first.keys.should =~ [:id, :name]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "#request_transaction" do
|
|
15
|
+
subject{ Mollie::Ideal.new('123456')}
|
|
16
|
+
|
|
17
|
+
it "should return a hash with the correct keys and values" do
|
|
18
|
+
VCR.use_cassette('request_transaction') do
|
|
19
|
+
t = subject.request_transaction(:amount => 12345,
|
|
20
|
+
:bank_id => '0031',
|
|
21
|
+
:description => 'description goes here',
|
|
22
|
+
:report_url => 'http://example.org/report',
|
|
23
|
+
:return_url => 'http://example.org/return')
|
|
24
|
+
t.class.should == Hash
|
|
25
|
+
expected_keys_with_values = {:transaction_id => nil, :amount => 12345, :currency => 'EUR', :url => nil}
|
|
26
|
+
check_hash_keys_and_values(t, expected_keys_with_values)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "#verify_transaction" do
|
|
32
|
+
subject{ Mollie::Ideal.new('123456')}
|
|
33
|
+
|
|
34
|
+
it "should return a hash with the correct keys and values" do
|
|
35
|
+
VCR.use_cassette('verify_transaction') do
|
|
36
|
+
t = subject.verify_transaction(:transaction_id => 'e0be830d5e46289e7da9636beb84729e')
|
|
37
|
+
|
|
38
|
+
t.class.should == Hash
|
|
39
|
+
expected_keys_with_values = {:transaction_id => 'e0be830d5e46289e7da9636beb84729e',
|
|
40
|
+
:amount => 12345,
|
|
41
|
+
:currency => 'EUR',
|
|
42
|
+
:payed => false,
|
|
43
|
+
:status => 'CheckedBefore'}
|
|
44
|
+
check_hash_keys_and_values(t, expected_keys_with_values)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
protected
|
|
50
|
+
# Checks target for:
|
|
51
|
+
# - existance of supplied keys
|
|
52
|
+
# - value for given key if supplied
|
|
53
|
+
#
|
|
54
|
+
# @example passing example
|
|
55
|
+
# check_hash_keys_and_values({:a => 1, :b => 'anything'}, {:a => 1, :b => nil})
|
|
56
|
+
def check_hash_keys_and_values(target, keys_and_values)
|
|
57
|
+
keys_and_values.each do |key, value|
|
|
58
|
+
if value
|
|
59
|
+
target[key].should == value
|
|
60
|
+
else
|
|
61
|
+
target.keys.should include(key)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
data/spec/spec.opts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "bundler"
|
|
3
|
+
Bundler.setup
|
|
4
|
+
|
|
5
|
+
$:.unshift File.expand_path("../../lib", __FILE__)
|
|
6
|
+
require "mollie-ideal"
|
|
7
|
+
|
|
8
|
+
Bundler.require(:test)
|
|
9
|
+
require 'vcr'
|
|
10
|
+
|
|
11
|
+
VCR.config do |c|
|
|
12
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
|
13
|
+
c.stub_with :webmock
|
|
14
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mollie-payment
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,22 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-12-
|
|
12
|
+
date: 2011-12-02 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: httparty
|
|
16
|
+
requirement: &70206244600140 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70206244600140
|
|
14
25
|
- !ruby/object:Gem::Dependency
|
|
15
26
|
name: yard
|
|
16
|
-
requirement: &
|
|
27
|
+
requirement: &70206244599500 !ruby/object:Gem::Requirement
|
|
17
28
|
none: false
|
|
18
29
|
requirements:
|
|
19
30
|
- - ! '>='
|
|
@@ -21,10 +32,54 @@ dependencies:
|
|
|
21
32
|
version: '0'
|
|
22
33
|
type: :development
|
|
23
34
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *70206244599500
|
|
25
36
|
- !ruby/object:Gem::Dependency
|
|
26
37
|
name: rdiscount
|
|
27
|
-
requirement: &
|
|
38
|
+
requirement: &70206244598920 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ! '>='
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
type: :development
|
|
45
|
+
prerelease: false
|
|
46
|
+
version_requirements: *70206244598920
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: rspec
|
|
49
|
+
requirement: &70206244598340 !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
type: :development
|
|
56
|
+
prerelease: false
|
|
57
|
+
version_requirements: *70206244598340
|
|
58
|
+
- !ruby/object:Gem::Dependency
|
|
59
|
+
name: ZenTest
|
|
60
|
+
requirement: &70206244597780 !ruby/object:Gem::Requirement
|
|
61
|
+
none: false
|
|
62
|
+
requirements:
|
|
63
|
+
- - ! '>='
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '0'
|
|
66
|
+
type: :development
|
|
67
|
+
prerelease: false
|
|
68
|
+
version_requirements: *70206244597780
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: vcr
|
|
71
|
+
requirement: &70206244597020 !ruby/object:Gem::Requirement
|
|
72
|
+
none: false
|
|
73
|
+
requirements:
|
|
74
|
+
- - ! '>='
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: *70206244597020
|
|
80
|
+
- !ruby/object:Gem::Dependency
|
|
81
|
+
name: webmock
|
|
82
|
+
requirement: &70206244596440 !ruby/object:Gem::Requirement
|
|
28
83
|
none: false
|
|
29
84
|
requirements:
|
|
30
85
|
- - ! '>='
|
|
@@ -32,8 +87,8 @@ dependencies:
|
|
|
32
87
|
version: '0'
|
|
33
88
|
type: :development
|
|
34
89
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
36
|
-
description:
|
|
90
|
+
version_requirements: *70206244596440
|
|
91
|
+
description: Client for the Mollie API (currently iDEAL only
|
|
37
92
|
email:
|
|
38
93
|
- gert@thinkcreate.nl
|
|
39
94
|
executables: []
|
|
@@ -41,13 +96,20 @@ extensions: []
|
|
|
41
96
|
extra_rdoc_files: []
|
|
42
97
|
files:
|
|
43
98
|
- .gitignore
|
|
99
|
+
- .rspec
|
|
44
100
|
- Gemfile
|
|
45
101
|
- README.md
|
|
46
102
|
- Rakefile
|
|
47
|
-
- lib/mollie-
|
|
103
|
+
- lib/mollie-payment.rb
|
|
48
104
|
- lib/mollie/ideal.rb
|
|
49
|
-
- lib/mollie/
|
|
105
|
+
- lib/mollie/payment/version.rb
|
|
50
106
|
- mollie-ideal.gemspec
|
|
107
|
+
- spec/fixtures/vcr_cassettes/banks.yml
|
|
108
|
+
- spec/fixtures/vcr_cassettes/request_transaction.yml
|
|
109
|
+
- spec/fixtures/vcr_cassettes/verify_transaction.yml
|
|
110
|
+
- spec/mollie/ideal_spec.rb
|
|
111
|
+
- spec/spec.opts
|
|
112
|
+
- spec/spec_helper.rb
|
|
51
113
|
homepage: https://github.com/eval/mollie-payment
|
|
52
114
|
licenses: []
|
|
53
115
|
post_install_message:
|
|
@@ -71,6 +133,12 @@ rubyforge_project: mollie-payment
|
|
|
71
133
|
rubygems_version: 1.8.10
|
|
72
134
|
signing_key:
|
|
73
135
|
specification_version: 3
|
|
74
|
-
summary:
|
|
75
|
-
test_files:
|
|
136
|
+
summary: Client for the Mollie API (currently iDEAL only
|
|
137
|
+
test_files:
|
|
138
|
+
- spec/fixtures/vcr_cassettes/banks.yml
|
|
139
|
+
- spec/fixtures/vcr_cassettes/request_transaction.yml
|
|
140
|
+
- spec/fixtures/vcr_cassettes/verify_transaction.yml
|
|
141
|
+
- spec/mollie/ideal_spec.rb
|
|
142
|
+
- spec/spec.opts
|
|
143
|
+
- spec/spec_helper.rb
|
|
76
144
|
has_rdoc:
|