ideal 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 1.9.2
4
+ - 1.8.7
5
+
6
+ branches:
7
+ only:
8
+ - master
9
+
10
+ script: "bundle exec rake test"
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ideal (0.2.0)
5
+ builder
6
+ nap
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ builder (3.0.0)
12
+ metaclass (0.0.1)
13
+ mocha (0.10.0)
14
+ metaclass (~> 0.0.1)
15
+ nap (0.4)
16
+ rake (0.9.2.2)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ ideal!
23
+ mocha
24
+ rake
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2011
2
+ Manfred Stienstra, Fingertips, manfred@fngtps.com
3
+ Frank Oxener - Agile Dovadi B.V.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,204 @@
1
+ h1. Active_merchant_ideal
2
+
3
+ "!https://secure.travis-ci.org/Fingertips/Ideal.png!":http://travis-ci.org/Fingertips/Ideal
4
+
5
+ h2. ATTENTION: transition period with a new certificate (ING only)
6
+
7
+ Recently ING issued a new iDEAL certificate, which should be in production before May 23 2011. See "Wijzigen van een acquiring certificaat in
8
+ iDEAL Advanced":http://www.ing.nl/Images/Wijzigen_van_een_acquiring_certificaat_in_iDEAL_Advanced_internet_tcm7-82882.pdf. However ING is not able to say exactly when this migration will take place. This means there will be a transition period in which it's uncertain which iDEAL certificate is needed.
9
+
10
+ Luckily Roel van Dijk (Voormedia BV) has written a gem/patch, so you can use the old and the new certificate during this transition period.
11
+
12
+ See "active_merchant_ideal_multicert":https://github.com/rdvdijk/active_merchant_ideal_multicert
13
+
14
+ h2. Description:
15
+
16
+ "iDEAL":http://www.ideal.nl payment gateway for "ActiveMerchant":http://www.activemerchant.org.
17
+
18
+ h2. What is iDEAL?
19
+
20
+ iDEAL is a set of standards developed to facilitate online payments through the online banking applications that most Dutch banks provide.
21
+
22
+ If a consumer already has online banking with ABN AMRO, Fortis, ING/Postbank, Rabobank, or SNS Bank, they can make payments using iDEAL in a way that they are already familiar with.
23
+
24
+ See "http://ideal.nl":http://ideal.nl and "http://idealdesk.com":http://idealdesk.com for more information.
25
+
26
+ h2. Merchant account
27
+
28
+ In order to use iDEAL you will need to get an iDEAL merchant account from your bank. Every bank offers ‘complete payment’ services, which can obfuscate the right choice. The payment product that you will want to get, in order to use this gateway class, is a bare bones iDEAL account.
29
+
30
+ * ING/Postbank: iDEAL Advanced
31
+ * ABN AMRO: iDEAL Zelfbouw
32
+ * Fortis: ? (Unknown)
33
+ * Rabobank: Rabo iDEAL Professional. (Unverified)
34
+ * SNS Bank: "Not yet available":http://www.snsbank.nl/zakelijk/betalingsverkeer/kan-ik-ideal-gebruiken-voor-mijn-webwinkel.html
35
+
36
+ If you implement tests for other banks, if they require such acceptance tests, please do submit a patch or contact me directly: frank@dovadi.com.
37
+
38
+ h2. Install active_merchant_ideal:
39
+
40
+ As a gem:
41
+
42
+ <pre>
43
+ sudo gem install active_merchant_ideal
44
+ </pre>
45
+
46
+ Add the following to your Gemfile:
47
+
48
+ <pre>
49
+ gem 'active_merchant_ideal'
50
+ </pre>
51
+
52
+ As a plugin:
53
+ <pre>
54
+ ./script/plugin install git://github.com/dovadi/active_merchant_ideal.git
55
+ </pre>
56
+
57
+ h2. Generate private keys and certificates
58
+
59
+ Messages to, and from, the acquirer, are all signed in order to prove their authenticity. This means that you will have to have a certificate to sign your messages going to the acquirer _and_ you will need to have the certificate of the acquirer to verify its signed messages.
60
+
61
+ The latter can be downloaded from your acquirer after registration. The former, however, can be a certificate signed by a CA authority or a self-signed certificate.
62
+
63
+ To create a self-signed certificate follow these steps:
64
+
65
+ * /usr/bin/openssl genrsa -des3 -out private_key.pem -passout pass:the_passphrase 1024
66
+ * /usr/bin/openssl req -x509 -new -key private_key.pem -passin pass:the_passphrase -days 3650 -out private_certificate.cer
67
+
68
+ Substitute _the_passphrase__ with your own passphrase.
69
+
70
+ With the ING bank you upload your private certificate with your iDEAL Dashboard. Be aware that there are two dashboards, one "dashboard":https://idealtest.secure-ing.com/ideal/logon_ing.do for the test environment and one "dashboard":https://ideal.secure-ing.com/ideal/logon_ing.do for the production environment!
71
+
72
+ For more information see:
73
+ * "http://en.wikipedia.org/wiki/Certificate_authority":http://en.wikipedia.org/wiki/Certificate_authority
74
+ * "http://en.wikipedia.org/wiki/Self-signed_certificate":http://en.wikipedia.org/wiki/Self-signed_certificate
75
+
76
+ h2. Test
77
+
78
+ h3. Test the gem
79
+
80
+ You can run the tests from this gem with (inside the active_merchant_ideal directory):
81
+
82
+ <pre>
83
+ bundle install
84
+ bundle exec rake test
85
+ </pre>
86
+
87
+ h3. Run the remote tests (For ING BANK and Rabobank only)
88
+
89
+ * Create .active_merchant directory in your own home directory
90
+ * Copy test/fixtures.yml to the .active_merchant directory
91
+ * Fill in your own merchant id, passphrase and the correct locations to your private key and certificates.
92
+ * For running the *seven prescribed remote test transactions* (ING bank and Rabobank) which are needed to activate the iDEAL account use
93
+
94
+ <pre>
95
+ bundle exec rake test:remote
96
+ </pre>
97
+
98
+ h3. Compatibility
99
+
100
+ Active_merchant_ideal is tested with Ruby 1.8.7 and 1.9.2.
101
+
102
+ h2. Example (Rails)
103
+
104
+ h3. First configure the gateway
105
+
106
+ Put the following code in, for instance, an initializer:
107
+
108
+ <pre>
109
+ ActiveMerchant::Billing::IdealGateway.acquirer = :ing # Other banks preloaded are :abnamro and :rabobank
110
+ ActiveMerchant::Billing::IdealGateway.merchant_id = '00123456789'
111
+ ActiveMerchant::Billing::IdealGateway.passphrase = 'the_private_key_passphrase'
112
+
113
+ # CERTIFICATE_ROOT points to a directory where the key and certificates are located
114
+ ActiveMerchant::Billing::IdealGateway.private_key_file = File.join(CERTIFICATE_ROOT, 'private_key.pem')
115
+ ActiveMerchant::Billing::IdealGateway.private_certificate_file = File.join(CERTIFICATE_ROOT, 'private_certificate.cer')
116
+ ActiveMerchant::Billing::IdealGateway.ideal_certificate_file = File.join(CERTIFICATE_ROOT, 'ideal.cer')
117
+ </pre>
118
+
119
+ h3. View
120
+
121
+ Give the consumer a list of available issuer options:
122
+
123
+ <pre>
124
+ gateway = ActiveMerchant::Billing::IdealGateway.new
125
+ issuers = gateway.issuers.list
126
+ sorted_issuers = issuers.sort_by { |issuer| issuer[:name] }
127
+ select('purchase', 'issuer_id', issuers.map { |issuer| [issuer[:name], issuer[:id]] })
128
+ </pre>
129
+
130
+ Could become:
131
+
132
+ <pre>
133
+ <select name="purchase[issuer_id]">
134
+ <option value="1006" selected="selected">ABN AMRO Bank</option>
135
+ <option value="1017">Asr bank</option>
136
+ <option value="1003">Postbank</option>
137
+ <option value="1005">Rabobank</option>
138
+ <option value="1023">Van Lanschot</option>
139
+ </select>
140
+ </pre>
141
+
142
+ h3. Controller
143
+
144
+ First you'll need to setup a transaction and redirect the consumer there so she can make the payment:
145
+
146
+ <pre>
147
+ class PurchasesController < ActionController::Base
148
+ def create
149
+ purchase = @user.purchases.build(:price => 1000) # €10.00 in cents.
150
+ purchase.save(false) # We want an id for the URL.
151
+
152
+ purchase_options = {
153
+ :issuer_id => params[:purchase][:issuer_id],
154
+ :order_id => purchase.id,
155
+ :return_url => purchase_url(purchase),
156
+ :description => 'A Dutch windmill'
157
+ }
158
+
159
+ # Save the purchase instance so that the consumer can return to its resource url to finish the transaction.
160
+ purchase.update_attributes!(purchase_options)
161
+
162
+ gateway = ActiveMerchant::Billing::IdealGateway.new
163
+ transaction_response = gateway.setup_purchase(purchase.price, purchase_options)
164
+ if transaction_response.success?
165
+
166
+ # Store the transaction_id that the acquirer has created to identify the transaction.
167
+ purchase.update_attributes!(:transaction_id => transaction_response.transaction_id)
168
+
169
+ # Redirect the consumer to the issuer’s payment page.
170
+ redirect_to transaction_response.service_url
171
+ end
172
+ end
173
+ end
174
+ </pre>
175
+
176
+ After the consumer is done with the payment she will be redirected to the _:return_url_. It's now _your_ responsibility as merchant to check if the payment has been made:
177
+
178
+ <pre>
179
+ class PurchasesController < ActionController::Base
180
+ def show
181
+ gateway = ActiveMerchant::Billing::IdealGateway.new
182
+ transaction_status = gateway.capture(@purchase.transaction_id)
183
+
184
+ if transaction_status.success?
185
+ @purchase.update_attributes!(:paid => true)
186
+ flash[:notice] = "Congratulations, you are now the proud owner of a Dutch windmill!"
187
+ end
188
+ end
189
+ end
190
+ </pre>
191
+
192
+ h2. History
193
+
194
+ In 2006 an iDEAL payment library was written in Ruby for a web shop build in Rails for selling mobile phone credits. It was basically a translation of the PHP example given by the iDEAL organization (see iDEAL Advanced Integration Manual PHP). Is was released as the ideal-on-rails library (see "http://dev.dovadi.com/projects/ideal":http://dev.dovadi.com/projects/ideal).
195
+
196
+ In 2007 this code was refactored as a patch for the ActiveMerchant library, this was mainly done by "Fingertips":http://www.fngtps.com/ for a client project. This patch was never accepted due to the fact it was too different (and maybe too obscure) from the 'normal' credit card gateways.
197
+
198
+ In 2009 Fingertips forked the ActiveMerchant library and added an iDEAL gateway (presumable based on the first ActiveMerchant patch) to a new ideal branch.
199
+
200
+ In 2010 this code was extracted and converted into a separate gem, so it can be more easily used in combination with the latest version of ActiveMerchant. This library is just an extraction, nothing more and nothing less. There are no fundamental changes between the code from the ideal branch and the code of this gem. Later that year "Sernin van de Krol":http://github.com/paneidos added support for ABN AMRO.
201
+
202
+ h2. Maintainer
203
+
204
+ This gem is maintained by "Agile Dovadi BV":http://dovadi.com, contact "Frank Oxener":mailto:frank@dovadi.com
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'test'
6
+ test.test_files = FileList['test/gateway_test.rb']
7
+ test.verbose = true
8
+ end
9
+
10
+ namespace :test do
11
+ desc "Run the remote tests for iDEAL gateway"
12
+ Rake::TestTask.new(:remote) do |test|
13
+ test.libs << 'test'
14
+ test.test_files = FileList['test/remote_test.rb']
15
+ test.verbose = true
16
+ end
17
+ end
18
+
19
+ task :default => :test
data/ideal.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ideal/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{ideal}
7
+ s.version = Ideal::VERSION
8
+ s.authors = ["Soemirno Kartosoewito", "Matthijs Kadijk", "Eloy Duran", "Manfred Stienstra", "Frank Oxener"]
9
+ s.description = %q{iDEAL payment gateway (see http://www.ideal.nl and http://www.activemerchant.org/)}
10
+ s.summary = %q{iDEAL payment gateway}
11
+ s.email = %q{manfred@fngtps.com}
12
+
13
+ s.homepage = %q{http://github.com/Fingertips/ideal}
14
+
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.textile"
18
+ ]
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+
25
+ s.add_dependency "builder"
26
+ s.add_dependency "nap"
27
+ s.add_development_dependency "mocha"
28
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'ideal'
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ module Ideal
4
+ ACQUIRERS = {
5
+ 'ing' => {
6
+ 'live_url' => 'https://ideal.secure-ing.com/ideal/iDeal',
7
+ 'test_url' => 'https://idealtest.secure-ing.com/ideal/iDeal'
8
+ },
9
+ 'rabobank' => {
10
+ 'live_url' => 'https://ideal.rabobank.nl/ideal/iDeal',
11
+ 'test_url' => 'https://idealtest.rabobank.nl/ideal/iDeal'
12
+ },
13
+ 'abnamro' => {
14
+ 'live_directory_url' => 'https://idealm.abnamro.nl/nl/issuerInformation/getIssuerInformation.xml',
15
+ 'live_transaction_url' => 'https://idealm.abnamro.nl/nl/acquirerTrxRegistration/getAcquirerTrxRegistration.xml',
16
+ 'live_status_url' => 'https://idealm.abnamro.nl/nl/acquirerStatusInquiry/getAcquirerStatusInquiry.xml',
17
+
18
+ 'test_directory_url' => 'https://itt.idealdesk.com/ITTEmulatorAcquirer/Directory.aspx',
19
+ 'test_transaction_url' => 'https://itt.idealdesk.com/ITTEmulatorAcquirer/Transaction.aspx',
20
+ 'test_status_url' => 'https://itt.idealdesk.com/ITTEmulatorAcquirer/Status.aspx'
21
+ }
22
+ }
23
+ end