Skip to content

Commit 3d18bf6

Browse files
author
Priit Haamer
committed
Implement ipizza:init generator to copy initial ipizza.yml file and test certificates.
1 parent 3ee8648 commit 3d18bf6

14 files changed

+243
-4
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
pkg/*
2+
.DS_Store
23
*.gem
34
.bundle
5+
Gemfile.lock

README.markdown

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1-
See also:
1+
Adds iPizza support to Rails 3 applications. Provides rails generators and easy configuration loading.
22

3-
[[ipizza|https://github.com/priithaamer/ipizza]]
3+
Installation
4+
------------
5+
6+
In your Gemfile add ipizza-rails gem:
7+
8+
gem ipizza-rails
9+
10+
Usage
11+
-----
12+
13+
To start using iPizza in your rails application, you need to run the **init** generator first:
14+
15+
rails generate ipizza:init
16+
17+
This will create an example configuration file to `config/ipizza.yml` and create `config/certificates` directory and
18+
puts some test certificates into it.
19+
20+
TODO:
21+
-----
22+
23+
* Implement form helpers

ipizza-rails.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
1717
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
1818
s.require_paths = ['lib']
1919

20-
s.add_dependency(%q<ipizza>, ['= 0.4.4'])
20+
s.add_dependency(%q<ipizza>, ['= 0.5.1'])
2121

2222
s.add_development_dependency('rspec', ['= 2.5.0'])
2323
end

lib/ipizza-rails.rb

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ module Ipizza
22
module Rails
33
end
44
end
5+
6+
require 'ipizza-rails/railtie' if defined?(::Rails) && ::Rails::VERSION::MAJOR >= 3

lib/ipizza-rails/generator/init.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'rails/generators'
2+
3+
class Ipizza::InitGenerator < Rails::Generators::Base
4+
5+
def self.source_root
6+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
7+
end
8+
9+
def create_configuration_file
10+
template 'ipizza.yml', 'config/ipizza.yml'
11+
end
12+
13+
def copy_test_certificates
14+
%w(nordea_test_priv seb_test_priv.pem seb_test_pub.pem).each { |f| copy_file "certificates/#{f}", "config/certificates/#{f}" }
15+
end
16+
end
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'rails/generators'
2+
require 'rails/generators/migration'
3+
4+
class Ipizza::NotificationGenerator < Rails::Generators::Base
5+
include Rails::Generators::Migration
6+
7+
def self.source_root
8+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
9+
end
10+
11+
# Implement the required interface for Rails::Generators::Migration.
12+
# taken from https://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
13+
def self.next_migration_number(dirname)
14+
if ActiveRecord::Base.timestamped_migrations
15+
Time.now.utc.strftime("%Y%m%d%H%M%S")
16+
else
17+
"%.3d" % (current_migration_number(dirname) + 1)
18+
end
19+
end
20+
21+
# Create a migration file for the adyen_notifications table
22+
def create_migration_file
23+
migration_template 'notification_migration.rb', 'db/migrate/create_ipizza_notifications.rb'
24+
end
25+
26+
def create_model_file
27+
template 'notification_model.rb', 'app/models/ipizza_notification.rb'
28+
end
29+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--PUT YOUR NORDEA SECRET HERE--
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
MIICXAIBAAKBgQC+AROlXiRvi1T7Q9fAh0Lw73szAn26mqfKDqd6Bdplq3v+gVWC
3+
3v0+bgtfNakRE/UVYOxEA0z0viqRpKzPuNy8OstTMe8fFKs19NW8lBYik6NzJ4Bk
4+
+B6VmovOm0nJLQJytXKiJyuHP9DqPOVmP8S+azzX7Uqzov1nxo9fvH7y2QIDAQAB
5+
AoGAFhbD9O6r57fYCloJxB01gBMnTHfWrBH8vbXUbJAvorA7+wuIKG3KHS7n7Yqs
6+
fArI7FJXRVTo5m8RPdtaJ9ADAT9rjAi3A17TaEueyJl+B/hjHYhsd8MeFhTb2fh0
7+
rY3F6diL8U/YDbiAIegnKO0zcc6ynJrsQZvzb6DlY/CLPe0CQQD3KXJzw1ZfJ1ts
8+
c370b/ZC1YrRURw41Q0I8ljYJ8EJw/ngVxrnCIsd43bRnOVp9guJrjTQRkhDC3Gn
9+
J2Y0+42LAkEAxMxmh7QY4nItBTS0fe1KCat4VDxhyxYEhZKlGDhxW75vNROrripB
10+
1ZfBsq5xkY2MM9R7WKmL7SpStrUPIvEVqwJBAOXA4ISd61cupbytrDEbNscv7Afh
11+
pyNpYOGVLmNYqQgj5c7WCcsD1RYmkRgPCe8y6czFZJDLFHdGVxLz+/16bTsCQC9J
12+
Ob2TnYMTkhO1JUU4tdh69e+vjoPgp3d80+Rs83fq2wey0UaI6saqryUC21Dw5OYz
13+
QOv92RxEVhmGibuIl/8CQCiYrzwlZJDlsKrWPZT0E8rzNmLZkhNHzYJP9S7x+FKk
14+
m3gFeXEBgzGn9UOd6xIAp0p7A1XVBN8XzDMa09gSOks=
15+
-----END RSA PRIVATE KEY-----
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDRTCCAq6gAwIBAgIBADANBgkqhkiG9w0BAQQFADB7MQswCQYDVQQGEwJFRTEO
3+
MAwGA1UECBMFSGFyanUxEDAOBgNVBAcTB1RhbGxpbm4xDDAKBgNVBAoTA0VZUDEL
4+
MAkGA1UECxMCSVQxDDAKBgNVBAMTA2EuYTEhMB8GCSqGSIb3DQEJARYSYWxsYXIu
5+
YWxsYXNAZXlwLmVlMB4XDTk5MTExNTA4MTAzM1oXDTk5MTIxNTA4MTAzM1owezEL
6+
MAkGA1UEBhMCRUUxDjAMBgNVBAgTBUhhcmp1MRAwDgYDVQQHEwdUYWxsaW5uMQww
7+
CgYDVQQKEwNFWVAxCzAJBgNVBAsTAklUMQwwCgYDVQQDEwNhLmExITAfBgkqhkiG
8+
9w0BCQEWEmFsbGFyLmFsbGFzQGV5cC5lZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
9+
gYkCgYEAvgETpV4kb4tU+0PXwIdC8O97MwJ9upqnyg6negXaZat7/oFVgt79Pm4L
10+
XzWpERP1FWDsRANM9L4qkaSsz7jcvDrLUzHvHxSrNfTVvJQWIpOjcyeAZPgelZqL
11+
zptJyS0CcrVyoicrhz/Q6jzlZj/Evms81+1Ks6L9Z8aPX7x+8tkCAwEAAaOB2DCB
12+
1TAdBgNVHQ4EFgQUFivCzZNmegEoOxYtg20YMMRB98gwgaUGA1UdIwSBnTCBmoAU
13+
FivCzZNmegEoOxYtg20YMMRB98ihf6R9MHsxCzAJBgNVBAYTAkVFMQ4wDAYDVQQI
14+
EwVIYXJqdTEQMA4GA1UEBxMHVGFsbGlubjEMMAoGA1UEChMDRVlQMQswCQYDVQQL
15+
EwJJVDEMMAoGA1UEAxMDYS5hMSEwHwYJKoZIhvcNAQkBFhJhbGxhci5hbGxhc0Bl
16+
eXAuZWWCAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBfkayuot+e
17+
fwW8QmPwpWF5AY3oMT/fTncjCljDBOg39IQv4PjnpTdDfwwl3lUIZHHTLM2i0L/c
18+
eD4D1UFM1qdp2VZzhBd1eeMjxYjCP8qL2v2MfLkCYcP30Sl6ISSkFjFc5qbGXZOc
19+
C82uR/wUZJDw9kj+R1O46/byG8yA+S9FVw==
20+
-----END CERTIFICATE-----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
development:
2+
swedbank:
3+
service_url: https://www.swedbank.ee/banklink
4+
return_url: http://localhost:3000/swedbank/return
5+
cancel_url: http://localhost:3000/swedbank/cancel
6+
login: dealer
7+
file_cert: seb_test_pub.pem
8+
file_key: seb_test_priv.pem
9+
key_secret: foobar
10+
encoding: UTF-8
11+
snd_id: sender
12+
13+
seb:
14+
service_url: https://www.seb.ee/cgi-bin/dv.sh/un3min.r
15+
return_url: http://localhost:3000/seb/return
16+
cancel_url: http://localhost:3000/seb/cancel
17+
login: dealer
18+
file_cert: seb_test_pub.pem
19+
file_key: seb_test_priv.pem
20+
encoding: UTF-8
21+
snd_id: sender
22+
23+
nordea:
24+
auth_service_url: https://netbank.nordea.com/pnbeidtest/eidn.jsp
25+
auth_return_url: http://localhost:3000/nordea/return
26+
auth_reject_url: http://localhost:3000/nordea/reject
27+
auth_cancel_url: http://localhost:3000/nordea/cancel
28+
auth_language: 'ET'
29+
auth_rcv_id: '12345678'
30+
confirm: 'YES'
31+
keyvers: '0001'
32+
file_key: nordea_test_priv
33+
34+
test:
35+
swedbank:
36+
service_url: https://www.swedbank.ee/banklink
37+
return_url: http://test.host/swedbank/return
38+
cancel_url: http://test.host/swedbank/cancel
39+
login: dealer
40+
file_cert: seb_test_pub.pem
41+
file_key: seb_test_priv.pem
42+
key_secret: foobar
43+
encoding: UTF-8
44+
snd_id: sender
45+
46+
seb:
47+
service_url: https://www.seb.ee/cgi-bin/dv.sh/un3min.r
48+
return_url: http://test.host/seb/return
49+
cancel_url: http://test.host/seb/cancel
50+
login: dealer
51+
file_cert: seb_test_pub.pem
52+
file_key: seb_test_priv.pem
53+
encoding: UTF-8
54+
snd_id: sender
55+
56+
nordea:
57+
auth_service_url: https://netbank.nordea.com/pnbeidtest/eidn.jsp
58+
auth_return_url: http://test.host/nordea/return
59+
auth_reject_url: http://test.host/nordea/reject
60+
auth_cancel_url: http://test.host/nordea/cancel
61+
auth_language: 'ET'
62+
auth_rcv_id: '12345678'
63+
confirm: 'YES'
64+
keyvers: '0001'
65+
file_key: nordea_test_priv
66+
67+
production:
68+
swedbank:
69+
service_url: https://www.swedbank.ee/banklink
70+
return_url: http://myapp.host/swedbank/return
71+
cancel_url: http://myapp.host/swedbank/cancel
72+
login: dealer
73+
file_cert: seb_test_pub.pem
74+
file_key: seb_test_priv.pem
75+
key_secret: foobar
76+
encoding: UTF-8
77+
snd_id: sender
78+
79+
seb:
80+
service_url: https://www.seb.ee/cgi-bin/unet3.sh/un3min.r
81+
return_url: http://myapp.host/seb/return
82+
cancel_url: http://myapp.host/seb/cancel
83+
login: dealer
84+
file_cert: seb_test_pub.pem
85+
file_key: seb_test_priv.pem
86+
encoding: UTF-8
87+
snd_id: sender
88+
89+
nordea:
90+
auth_service_url: https://netbank.nordea.com/pnbeid/eidn.jsp
91+
auth_return_url: http://myapp.host/nordea/return
92+
auth_reject_url: http://myapp.host/nordea/reject
93+
auth_cancel_url: http://myapp.host/nordea/cancel
94+
auth_language: 'ET'
95+
auth_rcv_id: '12345678'
96+
confirm: 'YES'
97+
keyvers: '0001'
98+
file_key: nordea_test_priv
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class CreateIpizzaNotifications < ActiveRecord::Migration
2+
3+
def self.up
4+
create_table :ipizza_notifications do |t|
5+
t.timestamps
6+
end
7+
8+
# add_index :ipizza_notifications, [:vk_date]
9+
end
10+
11+
def self.down
12+
drop_table :ipizza_notifications
13+
end
14+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class IpizzaNotification < ActiveRecord::Base
2+
end

lib/ipizza-rails/railtie.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'ipizza'
2+
require 'rails'
3+
4+
class Ipizza::Rails::Railtie < ::Rails::Railtie
5+
6+
generators do
7+
require 'ipizza-rails/generator/notification'
8+
require 'ipizza-rails/generator/init'
9+
end
10+
11+
config.before_configuration do
12+
if File.exist?(Rails.root.join('config', 'ipizza.yml'))
13+
Ipizza::Config.configure do |c|
14+
c.certs_root = Rails.root.join('config', 'certificates')
15+
c.load_from_hash(YAML::load_file(Rails.root.join('config', 'ipizza.yml')).fetch(Rails.env))
16+
end
17+
end
18+
end
19+
end

lib/ipizza-rails/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Ipizza
22
module Rails
3-
VERSION = '0.1.0'
3+
VERSION = '0.0.2'
44
end
55
end

0 commit comments

Comments
 (0)