rails-przelewy24 0.0.2 → 0.0.4

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.
Files changed (26) hide show
  1. data/README.textile +34 -0
  2. data/{generators → lib/generators}/przelewy24/USAGE +4 -2
  3. data/lib/generators/przelewy24/przelewy24_generator.rb +76 -0
  4. data/{generators → lib/generators}/przelewy24/templates/controller.rb +4 -1
  5. data/{generators → lib/generators}/przelewy24/templates/helper.rb +0 -0
  6. data/{generators → lib/generators}/przelewy24/templates/migration.rb +0 -0
  7. data/{generators → lib/generators}/przelewy24/templates/model.rb +1 -1
  8. data/lib/generators/przelewy24/templates/przelewy24.yml +51 -0
  9. data/{generators/przelewy24/templates/view__form.html.erb → lib/generators/przelewy24/templates/views/_form.html.erb} +9 -10
  10. data/{generators/przelewy24/templates/view_confirm.html.erb → lib/generators/przelewy24/templates/views/confirm.html.erb} +15 -13
  11. data/lib/generators/przelewy24/templates/views/error.html.erb +2 -0
  12. data/lib/generators/przelewy24/templates/views/index.html.erb +32 -0
  13. data/{generators/przelewy24/templates/view_new.html.erb → lib/generators/przelewy24/templates/views/new.html.erb} +0 -0
  14. data/lib/generators/przelewy24/templates/views/ok.html.erb +2 -0
  15. data/{generators/przelewy24/templates/view_show.html.erb → lib/generators/przelewy24/templates/views/show.html.erb} +3 -3
  16. data/test/test_helper.rb +16 -0
  17. data/test/unit/widget_test.rb +5 -0
  18. metadata +28 -30
  19. data/MIT-LICENSE +0 -20
  20. data/README +0 -31
  21. data/Rakefile +0 -28
  22. data/generators/przelewy24/przelewy24_generator.rb +0 -110
  23. data/generators/przelewy24/templates/INSTALL +0 -14
  24. data/generators/przelewy24/templates/view_error.html.erb +0 -2
  25. data/generators/przelewy24/templates/view_index.html.erb +0 -32
  26. data/generators/przelewy24/templates/view_ok.html.erb +0 -2
data/README.textile ADDED
@@ -0,0 +1,34 @@
1
+ h1. przelewy24
2
+
3
+ h2. What it is?
4
+
5
+ * This is the gem that consist of generator, to generate files to play with polish payment service "Przelewy24.pl":http://www.przelewy24.pl
6
+ * Generator creates model, controller and views for dealing with Przelewy24.
7
+
8
+ h2. What for?
9
+
10
+ * Application that have products to sell finally sends the form to Przelewy24 service. All transaction security and verification is held by generated files and Przelewy24 side.
11
+
12
+ h2. Installation on Rails 3 app
13
+
14
+ Add this to your Gemfile
15
+ @gem 'przelewy24'@
16
+
17
+ Then install it
18
+ @bundle install@
19
+
20
+ Generate the files for Przelewy24 with ModelName and Przelewy24 SellerID
21
+ @rails generate przelewy24 payment 1034@
22
+
23
+ and you are free to connect your transactions with Przelewy24 payment service.
24
+
25
+ h2. Contribute
26
+
27
+ Thanks for forking and helping!
28
+
29
+ major issues:
30
+ - rspecs or tests to gem needs to be done
31
+
32
+ h3. License
33
+
34
+ Copyright (c) 2010 ["Jakub Godawa":http://github.com/vysogot], released under the MIT license
@@ -3,10 +3,12 @@ Description:
3
3
  Pass the name of the model you want to be responsible for that.
4
4
 
5
5
  Example:
6
- ./script/generate przelewy24 payment
6
+ rails generate przelewy24 Payment
7
7
 
8
8
  This will create:
9
9
  app/models/payment.rb
10
10
  app/controllers/payments_controller.rb
11
11
  app/views/payments/...
12
- db/migration/create_payments.rb
12
+ db/migration/*_create_payments.rb
13
+ config/locales/przelewy24.yml
14
+ routes...
@@ -0,0 +1,76 @@
1
+ class Przelewy24Generator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ argument :class_name, :type => :string, :default => "Payment"
4
+ argument :seller_id, :type => :string, :default => "1000"
5
+ class_option :migration, :type => :boolean, :default => true, :desc => "Include migration file."
6
+
7
+ def generate_files
8
+
9
+ # Generate views
10
+ views.each do |view|
11
+ template "views/#{view}.html.erb", "app/views/#{plural_name}/#{view}.html.erb"
12
+ end
13
+
14
+ # Copy locales
15
+ copy_file "przelewy24.yml", "config/locales/przelewy24.yml"
16
+
17
+ # Generate controller
18
+ template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
19
+
20
+ # Generate helper
21
+ template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
22
+
23
+ # Generate model
24
+ template 'model.rb', "app/models/#{singular_name}.rb"
25
+
26
+ # Generate routes
27
+ routes_string=<<FINITO
28
+ resources :#{plural_name} do
29
+ collection do
30
+ get 'confirm'
31
+ get 'error'
32
+ post 'ok'
33
+ end
34
+ end
35
+ FINITO
36
+
37
+ route(routes_string)
38
+
39
+ # Generate migration
40
+ if options.migration?
41
+ # #{Time.now.utc.strftime("%Y%m%d%H%M%S")}_
42
+ migration_file_name = "#{Time.now.utc.strftime("%Y%m%d")}_create_#{table_name}"
43
+ template 'migration.rb', "db/migrate/#{migration_file_name}.rb"
44
+
45
+ # migrate
46
+ rake("db:migrate", :env => :development)
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ def views
53
+ %w(new index _form show ok error confirm)
54
+ end
55
+
56
+
57
+ # imagine model: SuperService
58
+ def controller_class_name
59
+ class_name.pluralize # SuperServices
60
+ end
61
+
62
+ def singular_name
63
+ class_name.underscore # super_service
64
+ end
65
+
66
+ def migration_name
67
+ "Create#{controller_class_name}" # CreateSuperServices
68
+ end
69
+
70
+ def plural_name
71
+ singular_name.pluralize # super_services
72
+ end
73
+
74
+ alias table_name plural_name # super_services
75
+ alias file_name singular_name # super_service
76
+ end
@@ -28,7 +28,7 @@ class <%= controller_class_name %>Controller < ApplicationController
28
28
  flash[:notice] = t('transaction_created')
29
29
  session[:<%= file_name %>_id] = @<%= file_name %>.id
30
30
 
31
- redirect_to confirm_<%= file_name %>_url
31
+ redirect_to confirm_<%= plural_name %>_url
32
32
  else
33
33
  render :action => 'new'
34
34
  end
@@ -79,6 +79,9 @@ class <%= controller_class_name %>Controller < ApplicationController
79
79
  # create new http object with ssl usage
80
80
  http = Net::HTTP.new(url.host, url.port)
81
81
  http.use_ssl = true
82
+
83
+ # UNCOMMENT THAT IF OpenSSL throws unwanted errors
84
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
82
85
 
83
86
  # get the response from Przelewy24.pl
84
87
  res = http.start {|http| http.request(req) }
@@ -3,7 +3,7 @@ class <%= class_name %> < ActiveRecord::Base
3
3
 
4
4
  before_create :set_session_id
5
5
 
6
- SELLER_ID = 1000 # Put here you account login on przelewy24
6
+ SELLER_ID = <%= seller_id %> # Put here you account login on przelewy24
7
7
  COUNTRY = 'PL'
8
8
  LANGUAGE = 'pl'
9
9
 
@@ -0,0 +1,51 @@
1
+ en:
2
+ przelewy24:
3
+ new: "New transaction"
4
+ show: "Details"
5
+ are_you_sure: "Are you sure you want to delete this transaction?"
6
+ destroy: "Delete"
7
+ view_all: "List of transactions"
8
+ submit: "Create transaction"
9
+ submit_to_p24: "Go to Przelewy24.pl"
10
+ no_transactions: "No transactions to list"
11
+ success: "Verification success"
12
+ failure: "Verification failure"
13
+
14
+ # attributes
15
+ order: "Order"
16
+ klient: "Client"
17
+ kwota: "Value"
18
+ email: "Email"
19
+ adres: "Address"
20
+ kod: "Post code"
21
+ miasto: "City"
22
+ opis: "Descripiton"
23
+ metoda: "Payment method"
24
+ is_verified: "Verified?"
25
+
26
+ pl:
27
+ przelewy24:
28
+ new: "Nowa transakcja"
29
+ show: "Szczegóły"
30
+ are_you_sure: "Czy na pewno chcesz usunąć tę transakcję?"
31
+ destroy: "Usuń"
32
+ view_all: "Lista transakcji"
33
+ submit: "Nowa transakcja"
34
+ submit_to_p24: "Wyślij do Przelewy24.pl"
35
+ no_transactions: "Brak transakcji"
36
+ success: "Weryfikacja zakończona sukcesem"
37
+ failure: "Błąd weryfikacji"
38
+
39
+ # attributes
40
+ order: "Zamówienie"
41
+ klient: "Klient"
42
+ kwota: "Wartość"
43
+ email: "Email"
44
+ adres: "Adres"
45
+ kod: "Kod pocztowy"
46
+ miasto: "Miasto"
47
+ opis: "Opis"
48
+ metoda: "Metoda płatności"
49
+ is_verified: "Zweryfikowana?"
50
+
51
+
@@ -1,32 +1,31 @@
1
- <%% form_for @<%= singular_name %> do |f| %>
2
- <%%= f.error_messages %>
1
+ <%%= form_for @<%= singular_name %> do |f| %>
3
2
  <p>
4
- <%%= f.label :email %><br />
3
+ <%%= label_tag t('przelewy24.email') %><br />
5
4
  <%%= f.text_field :email, :value => @<%= singular_name %>.email %>
6
5
  </p>
7
6
  <p>
8
- <%%= f.label :klient %><br />
7
+ <%%= label_tag t('przelewy24.klient') %><br />
9
8
  <%%= f.text_field :klient, :value => @<%= singular_name %>.klient %>
10
9
  </p>
11
10
  <p>
12
- <%%= f.label :adres %><br />
11
+ <%%= label_tag t('przelewy24.adres') %><br />
13
12
  <%%= f.text_field :adres, :value => @<%= singular_name %>.adres %>
14
13
  </p>
15
14
  <p>
16
- <%%= f.label :kod %><br />
15
+ <%%= label_tag t('przelewy24.kod') %><br />
17
16
  <%%= f.text_field :kod, :value => @<%= singular_name %>.kod %>
18
17
  </p>
19
18
  <p>
20
- <%%= f.label :miasto %><br />
19
+ <%%= label_tag t('przelewy24.miasto') %><br />
21
20
  <%%= f.text_field :miasto, :value => @<%= singular_name %>.miasto %>
22
21
  </p>
23
22
  <p>
24
- <%%= f.label :opis %><br />
23
+ <%%= label_tag t('przelewy24.opis') %><br />
25
24
  <%%= f.text_field :opis, :value => @<%= singular_name %>.opis %>
26
25
  </p>
27
26
  <p>
28
- <%%= f.label :kwota %><br />
27
+ <%%= label_tag t('przelewy24.kwota') %><br />
29
28
  <%%= f.text_field :kwota, :value => @<%= singular_name %>.kwota %>
30
29
  </p>
31
- <p><%%= f.submit t('submit') %></p>
30
+ <p><%%= f.submit t('przelewy24.submit') %></p>
32
31
  <%% end %>
@@ -1,10 +1,12 @@
1
- <%%= link_to 'normal payment', confirm_<%= singular_name %>_url %>
2
- <%%= link_to 'test ok payment', confirm_<%= singular_name %>_url(:test => 'TEST_OK') %>
3
- <%%= link_to 'test error payment', confirm_<%= singular_name %>_url(:test => 'TEST_ERR') %>
1
+ <%% if Rails.env.eql?('development') %>
2
+ <%%= link_to 'normal payment', confirm_<%= plural_name %>_url %>
3
+ <%%= link_to 'test ok payment', confirm_<%= plural_name %>_url(:test => 'TEST_OK') %>
4
+ <%%= link_to 'test error payment', confirm_<%= plural_name %>_url(:test => 'TEST_ERR') %>
5
+ <%% end %>
4
6
 
5
- <%% form_tag 'https://secure.przelewy24.pl/index.php' do %>
7
+ <%%= form_tag 'https://secure.przelewy24.pl/index.php' do %>
6
8
 
7
- <%% @payment.attributes_for_p24.each do |key, value| %>
9
+ <%% @<%= singular_name %>.attributes_for_p24.each do |key, value| %>
8
10
  <%% if key == 'p24_opis' %>
9
11
  <%%= hidden_field_tag key, params[:test] || value %>
10
12
  <%% else %>
@@ -17,33 +19,33 @@
17
19
 
18
20
  <div id="confirm">
19
21
  <p>
20
- <strong>Email:</strong>
22
+ <strong><%%= t('przelewy24.email') %>:</strong>
21
23
  <%%=h @<%= singular_name %>.email %>
22
24
  </p>
23
25
  <p>
24
- <strong>Klient:</strong>
26
+ <strong><%%= t('przelewy24.klient') %>:</strong>
25
27
  <%%=h @<%= singular_name %>.klient %>
26
28
  </p>
27
29
  <p>
28
- <strong>Adres:</strong>
30
+ <strong><%%= t('przelewy24.adres') %>:</strong>
29
31
  <%%=h @<%= singular_name %>.adres %>
30
32
  </p>
31
33
  <p>
32
- <strong>Kod:</strong>
34
+ <strong><%%= t('przelewy24.kod') %>:</strong>
33
35
  <%%=h @<%= singular_name %>.kod %>
34
36
  </p>
35
37
  <p>
36
- <strong>Miasto:</strong>
38
+ <strong><%%= t('przelewy24.miasto') %>:</strong>
37
39
  <%%=h @<%= singular_name %>.miasto %>
38
40
  </p>
39
41
  <p>
40
- <strong>Opis:</strong>
42
+ <strong><%%= t('przelewy24.opis') %>:</strong>
41
43
  <%%=h @<%= singular_name %>.opis %>
42
44
  </p>
43
45
  <p>
44
- <strong>Kwota:</strong>
46
+ <strong><%%= t('przelewy24.kwota') %>:</strong>
45
47
  <%%=h @<%= singular_name %>.kwota %>
46
48
  </p>
47
49
  </div>
48
- <p><%%= submit_tag t('submit_to_p24') %></p>
50
+ <p><%%= submit_tag t('przelewy24.submit_to_p24') %></p>
49
51
  <%% end %>
@@ -0,0 +1,2 @@
1
+ <%%= t('przelewy24.failure') %><br />
2
+ <%%= link_to t('przelewy24.view_all'), <%= plural_name %>_url %>
@@ -0,0 +1,32 @@
1
+ <%% t('przelewy24.view_all') %>
2
+
3
+ <%% if @<%= plural_name %>.present? %>
4
+ <table>
5
+ <tr>
6
+ <th><%%= t('przelewy24.order') %></th>
7
+ <th><%%= t('przelewy24.klient') %></th>
8
+ <th><%%= t('przelewy24.kwota') %></th>
9
+ <th><%%= t('przelewy24.email') %></th>
10
+ <th><%%= t('przelewy24.opis') %></th>
11
+ <th><%%= t('przelewy24.metoda') %></th>
12
+ <th><%%= t('przelewy24.is_verified') %></th>
13
+ </tr>
14
+ <%% for <%= singular_name %> in @<%= plural_name %> %>
15
+ <tr>
16
+ <td><%%=h <%= singular_name %>.order_id %></td>
17
+ <td><%%=h <%= singular_name %>.klient %></td>
18
+ <td><%%=h number_to_currency(<%= singular_name %>.kwota_pln) %></td>
19
+ <td><%%=h <%= singular_name %>.email %></td>
20
+ <td><%%=h <%= singular_name %>.opis %></td>
21
+ <td><%%=h <%= singular_name %>.metoda %></td>
22
+ <td><%%=h <%= singular_name %>.is_verified %></td>
23
+ <td><%%= link_to t('przelewy24.show'), <%= singular_name %> %></td>
24
+ <td><%%= link_to t('przelewy24.destroy'), <%= singular_name %>, :confirm => t('przelewy24.are_you_sure'), :method => :delete %></td>
25
+ </tr>
26
+ <%% end %>
27
+ </table>
28
+ <%% else %>
29
+ <p><%%= t('przelewy24.no_transactions') %></p>
30
+ <%% end %>
31
+
32
+ <%%= link_to t('przelewy24.new'), new_<%= singular_name %>_path %>
@@ -0,0 +1,2 @@
1
+ <%%= t('przelewy24.success') %><br />
2
+ <%%= link_to t('przelewy24.view_all'), <%= plural_name %>_url %>
@@ -1,4 +1,4 @@
1
- <%% t('transaction') %>
1
+ <%% t('przelewy24.show') %>
2
2
 
3
3
  <p>
4
4
  <strong>Session:</strong>
@@ -62,6 +62,6 @@
62
62
  </p>
63
63
 
64
64
  <p>
65
- <%%= link_to t('destroy'), @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %> |
66
- <%%= link_to t('view_all'), <%= singular_name %>s_path %>
65
+ <%%= link_to t('przelewy24.destroy'), @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %> |
66
+ <%%= link_to t('przelewy24.view_all'), <%= singular_name %>s_path %>
67
67
  </p>
@@ -0,0 +1,16 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'yaml'
6
+ require 'active_record'
7
+ require 'sqlite3'
8
+
9
+ require File.dirname(__FILE__) + '/../app/models/cheese/widget.rb'
10
+
11
+ def load_schema
12
+ config = YAML::load( IO.read( File.dirname(__FILE__) + '/database.yml') )
13
+
14
+ # Manually initialize the database
15
+ SQLite3::Database.new(File.dirname(__FILE__) + '/' + config['test']['database'])
16
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class WidgetTest < Test::Unit::TestCase
4
+ load_schema
5
+ end
metadata CHANGED
@@ -1,50 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-przelewy24
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 2
10
- version: 0.0.2
8
+ - 4
9
+ version: 0.0.4
11
10
  platform: ruby
12
11
  authors:
13
- - "Jakub Godawa, \xC5\x81ukasz Krystkowiak"
12
+ - Jakub Godawa
14
13
  autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-06-08 00:00:00 +02:00
17
+ date: 2010-12-18 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
22
- description: Gem that can generate files necesary to be able to use Przelewy24.pl as your payment service.
21
+ description: Gem consist of a generator 'przelewy24'. Application that have products for sale finally sends the form to Przelewy24 service. All transaction security and verification is held by generated files and Przelewy24 side. For Rails 2.x use version 0.0.2
23
22
  email: jakub.godawa@gmail.com
24
23
  executables: []
25
24
 
26
25
  extensions: []
27
26
 
28
27
  extra_rdoc_files:
29
- - README
28
+ - README.textile
30
29
  files:
31
- - Rakefile
32
- - MIT-LICENSE
33
- - README
34
- - generators/przelewy24/USAGE
35
- - generators/przelewy24/templates/model.rb
36
- - generators/przelewy24/templates/view__form.html.erb
37
- - generators/przelewy24/templates/view_error.html.erb
38
- - generators/przelewy24/templates/helper.rb
39
- - generators/przelewy24/templates/INSTALL
40
- - generators/przelewy24/templates/view_confirm.html.erb
41
- - generators/przelewy24/templates/view_new.html.erb
42
- - generators/przelewy24/templates/migration.rb
43
- - generators/przelewy24/templates/view_ok.html.erb
44
- - generators/przelewy24/templates/view_index.html.erb
45
- - generators/przelewy24/templates/controller.rb
46
- - generators/przelewy24/templates/view_show.html.erb
47
- - generators/przelewy24/przelewy24_generator.rb
30
+ - lib/generators/przelewy24/USAGE
31
+ - lib/generators/przelewy24/przelewy24_generator.rb
32
+ - lib/generators/przelewy24/templates/controller.rb
33
+ - lib/generators/przelewy24/templates/helper.rb
34
+ - lib/generators/przelewy24/templates/migration.rb
35
+ - lib/generators/przelewy24/templates/model.rb
36
+ - lib/generators/przelewy24/templates/przelewy24.yml
37
+ - lib/generators/przelewy24/templates/views/_form.html.erb
38
+ - lib/generators/przelewy24/templates/views/confirm.html.erb
39
+ - lib/generators/przelewy24/templates/views/error.html.erb
40
+ - lib/generators/przelewy24/templates/views/index.html.erb
41
+ - lib/generators/przelewy24/templates/views/new.html.erb
42
+ - lib/generators/przelewy24/templates/views/ok.html.erb
43
+ - lib/generators/przelewy24/templates/views/show.html.erb
44
+ - README.textile
45
+ - test/test_helper.rb
46
+ - test/unit/widget_test.rb
48
47
  has_rdoc: true
49
48
  homepage: http://github.com/vysogot/przelewy24
50
49
  licenses: []
@@ -59,7 +58,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
62
- hash: 3
63
61
  segments:
64
62
  - 0
65
63
  version: "0"
@@ -68,16 +66,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
66
  requirements:
69
67
  - - ">="
70
68
  - !ruby/object:Gem::Version
71
- hash: 3
72
69
  segments:
73
70
  - 0
74
71
  version: "0"
75
72
  requirements: []
76
73
 
77
- rubyforge_project:
74
+ rubyforge_project: rails-p24
78
75
  rubygems_version: 1.3.7
79
76
  signing_key:
80
77
  specification_version: 3
81
- summary: Tool to deal with Przelewy24.pl payment service
82
- test_files: []
83
-
78
+ summary: This is a Rails engine to play with Polish payment service Przelewy24.pl
79
+ test_files:
80
+ - test/test_helper.rb
81
+ - test/unit/widget_test.rb
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 [Jakub Godawa, Łukasz Krystkowiak]
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README DELETED
@@ -1,31 +0,0 @@
1
- rails-przelewy24
2
- ==========
3
-
4
- No yet finished.
5
- This is the plugin for polish payment service Przelewy24.pl
6
-
7
- It consist of a generator of model, controller and views for dealing with Przelewy24.
8
-
9
-
10
- Example
11
- =======
12
-
13
- Application that have products to sell finally sends the form to Przelewy24.
14
- All transaction security and verification is held by this plugin and Przelewy24 site.
15
-
16
- Install:
17
- sudo gem install przelewy24
18
-
19
- cd yourapp/
20
- script/generate przelewy24 payment
21
- rake db:migrate
22
-
23
- copy and paste to config/routes.rb:
24
- map.confirm_payment 'confirmation', :controller => :payments, :action => :confirm
25
- map.ok_payments 'verification-successful', :controller => :payments, :action => :ok, :conditions => { :method => :post }
26
- map.error_payments 'error-in-transaction', :controller => :payments, :action => :error
27
-
28
- and you are free to connect your shop with Przelewy24 payment service.
29
-
30
-
31
- Copyright (c) 2010 [Jakub Godawa, Łukasz Krystkowiak], released under the MIT license
data/Rakefile DELETED
@@ -1,28 +0,0 @@
1
- require 'rubygems'
2
- require 'rubygems/package_task'
3
-
4
- PKG_FILES = FileList[
5
- '[a-zA-Z]*',
6
- 'generators/**/*'
7
- ]
8
-
9
- spec = Gem::Specification.new do |s|
10
- s.name = "rails-przelewy24"
11
- s.version = "0.0.2"
12
- s.author = "Jakub Godawa, Łukasz Krystkowiak"
13
- s.email = "jakub.godawa@gmail.com"
14
- s.homepage = "http://github.com/vysogot/przelewy24"
15
- s.platform = Gem::Platform::RUBY
16
- s.summary = "Tool to deal with Przelewy24.pl payment service"
17
- s.description = "Gem that can generate files necesary to be able to use Przelewy24.pl as your payment service."
18
- s.files = PKG_FILES.to_a
19
- s.has_rdoc = false
20
- s.extra_rdoc_files = ["README"]
21
- end
22
-
23
- desc 'Turn this plugin into a gem.'
24
- Gem::PackageTask.new(spec) do |pkg|
25
- pkg.gem_spec = spec
26
- pkg.need_zip = true
27
- pkg.need_tar = true
28
- end
@@ -1,110 +0,0 @@
1
- class Przelewy24Generator < Rails::Generator::NamedBase
2
- default_options :skip_migration => false
3
-
4
- # from rails/scaffold_generator
5
- attr_reader :controller_name,
6
- :controller_class_path,
7
- :controller_file_path,
8
- :controller_class_nesting,
9
- :controller_class_nesting_depth,
10
- :controller_class_name,
11
- :controller_underscore_name,
12
- :controller_singular_name,
13
- :controller_plural_name
14
- alias_method :controller_file_name, :controller_underscore_name
15
- alias_method :controller_table_name, :controller_plural_name
16
-
17
- def initialize(runtime_args, runtime_options = {})
18
- super
19
-
20
- if @name == @name.pluralize && !options[:force_plural]
21
- logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural."
22
- @name = @name.singularize
23
- assign_names!(@name)
24
- end
25
-
26
- @controller_name = @name.pluralize
27
-
28
- base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
29
- @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
30
- @controller_singular_name=base_name.singularize
31
- if @controller_class_nesting.empty?
32
- @controller_class_name = @controller_class_name_without_nesting
33
- else
34
- @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
35
- end
36
- end
37
-
38
- def manifest
39
- record do |m|
40
- # Check for class naming collisions
41
- m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper")
42
- m.class_collisions(class_name)
43
-
44
- # Model, controller, helpers and views directories
45
- m.directory File.join('app/models', class_path)
46
- m.directory File.join('app/controllers', controller_class_path)
47
- m.directory File.join('app/helpers', controller_class_path)
48
- m.directory File.join('app/views', controller_class_path, controller_file_name)
49
-
50
- # Generate views
51
- for action in p24_views
52
- m.template(
53
- "view_#{action}.html.erb",
54
- File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb")
55
- )
56
- end
57
-
58
- # Generate controller
59
- m.template(
60
- 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
61
- )
62
-
63
- # Generate helper
64
- m.template(
65
- 'helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")
66
- )
67
-
68
- # Route
69
- m.route_resources controller_file_name
70
-
71
- migration_file_path = file_path.gsub(/\//, '_')
72
- migration_name = class_name
73
- if ActiveRecord::Base.pluralize_table_names
74
- migration_name = migration_name.pluralize
75
- migration_file_path = migration_file_path.pluralize
76
- end
77
-
78
- unless options[:skip_migration]
79
- m.migration_template 'migration.rb', 'db/migrate', :assigns => {
80
- :migration_name => "Create#{migration_name.gsub(/::/, '')}"
81
- }, :migration_file_name => "create_#{migration_file_path}"
82
- end
83
-
84
- # Generate model
85
- m.template(
86
- 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
87
- )
88
-
89
- m.readme "INSTALL"
90
-
91
- end
92
-
93
- end
94
-
95
- protected
96
-
97
- def banner
98
- "Usage: #{$0} #{spec.name} ModelName"
99
- end
100
-
101
- def add_options!(opt)
102
- opt.separator("Options: ")
103
- opt.on("--skip-migration", "Don't generate migration for Przelewy24")
104
- end
105
-
106
- def p24_views
107
- %w( new index _form show ok error confirm )
108
-
109
- end
110
- end
@@ -1,14 +0,0 @@
1
-
2
- ======
3
- do it by yourself
4
- ======
5
-
6
- run: rake db:migrate
7
-
8
- now copy paste that to you config/routes.rb file (example for ModelName 'payment'):
9
-
10
- map.confirm_payment 'confirmation', :controller => :payments, :action => :confirm
11
- map.ok_payments 'verification-successful', :controller => :payments, :action => :ok, :conditions => { :method => :post }
12
- map.error_payments 'error-in-transaction', :controller => :payments, :action => :error
13
-
14
-
@@ -1,2 +0,0 @@
1
- Transaction verification failed<br />
2
- <%%= link_to t('transaction'), <%= plural_name %>_url %>
@@ -1,32 +0,0 @@
1
- <%% t('transactions') %>
2
-
3
- <%% if @<%= plural_name %>.present? %>
4
- <table>
5
- <tr>
6
- <th><%= singular_name %> id</th>
7
- <th>Klient</th>
8
- <th>Kwota</th>
9
- <th>Email</th>
10
- <th>Opis</th>
11
- <th>Metoda</th>
12
- <th>Verified</th>
13
- </tr>
14
- <%% for <%= singular_name %> in @<%= plural_name %> %>
15
- <tr>
16
- <td><%%=h <%= singular_name %>.order_id %></td>
17
- <td><%%=h <%= singular_name %>.klient %></td>
18
- <td><%%=h number_to_currency(<%= singular_name %>.kwota_pln) %></td>
19
- <td><%%=h <%= singular_name %>.email %></td>
20
- <td><%%=h <%= singular_name %>.opis %></td>
21
- <td><%%=h <%= singular_name %>.metoda %></td>
22
- <td><%%=h <%= singular_name %>.is_verified %></td>
23
- <td><%%= link_to t('show'), <%= singular_name %> %></td>
24
- <td><%%= link_to t('destroy'), <%= singular_name %>, :confirm => t('are_you_sure'), :method => :delete %></td>
25
- </tr>
26
- <%% end %>
27
- </table>
28
- <%% else %>
29
- <p><%%= t('no_transactions') %></p>
30
- <%% end %>
31
-
32
- <%%= link_to t('new'), new_<%= singular_name %>_path %>
@@ -1,2 +0,0 @@
1
- Successfully verified<br />
2
- <%%= link_to t('transactions'), <%= plural_name %>_url %>