rails-przelewy24 0.0.1 → 0.0.2
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/README +4 -3
- data/Rakefile +1 -1
- data/generators/przelewy24/przelewy24_generator.rb +4 -1
- data/generators/przelewy24/templates/INSTALL +14 -0
- data/generators/przelewy24/templates/controller.rb +9 -7
- data/generators/przelewy24/templates/model.rb +3 -0
- data/generators/przelewy24/templates/view_confirm.html.erb +12 -4
- data/generators/przelewy24/templates/view_error.html.erb +2 -1
- data/generators/przelewy24/templates/view_index.html.erb +2 -0
- data/generators/przelewy24/templates/view_ok.html.erb +2 -0
- metadata +19 -6
- data/generators/przelewy24/templates/view_verified.html.erb +0 -1
data/README
CHANGED
@@ -13,17 +13,18 @@ Example
|
|
13
13
|
Application that have products to sell finally sends the form to Przelewy24.
|
14
14
|
All transaction security and verification is held by this plugin and Przelewy24 site.
|
15
15
|
|
16
|
-
|
16
|
+
Install:
|
17
|
+
sudo gem install przelewy24
|
17
18
|
|
19
|
+
cd yourapp/
|
18
20
|
script/generate przelewy24 payment
|
19
21
|
rake db:migrate
|
20
22
|
|
21
|
-
copy
|
23
|
+
copy and paste to config/routes.rb:
|
22
24
|
map.confirm_payment 'confirmation', :controller => :payments, :action => :confirm
|
23
25
|
map.ok_payments 'verification-successful', :controller => :payments, :action => :ok, :conditions => { :method => :post }
|
24
26
|
map.error_payments 'error-in-transaction', :controller => :payments, :action => :error
|
25
27
|
|
26
|
-
|
27
28
|
and you are free to connect your shop with Przelewy24 payment service.
|
28
29
|
|
29
30
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ PKG_FILES = FileList[
|
|
8
8
|
|
9
9
|
spec = Gem::Specification.new do |s|
|
10
10
|
s.name = "rails-przelewy24"
|
11
|
-
s.version = "0.0.
|
11
|
+
s.version = "0.0.2"
|
12
12
|
s.author = "Jakub Godawa, Łukasz Krystkowiak"
|
13
13
|
s.email = "jakub.godawa@gmail.com"
|
14
14
|
s.homepage = "http://github.com/vysogot/przelewy24"
|
@@ -86,7 +86,10 @@ class Przelewy24Generator < Rails::Generator::NamedBase
|
|
86
86
|
'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
87
87
|
)
|
88
88
|
|
89
|
+
m.readme "INSTALL"
|
90
|
+
|
89
91
|
end
|
92
|
+
|
90
93
|
end
|
91
94
|
|
92
95
|
protected
|
@@ -101,7 +104,7 @@ class Przelewy24Generator < Rails::Generator::NamedBase
|
|
101
104
|
end
|
102
105
|
|
103
106
|
def p24_views
|
104
|
-
%w( new index _form show
|
107
|
+
%w( new index _form show ok error confirm )
|
105
108
|
|
106
109
|
end
|
107
110
|
end
|
@@ -0,0 +1,14 @@
|
|
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
|
+
|
@@ -48,20 +48,22 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
48
48
|
|
49
49
|
# first verification from Przelewy24.pl
|
50
50
|
def ok
|
51
|
-
@<%= file_name %> = <%= class_name %>.find_by_session_id(params[
|
52
|
-
if @<%= file_name %> && @<%= file_name %>.
|
51
|
+
@<%= file_name %> = <%= class_name %>.find_by_session_id(params[:p24_session_id])
|
52
|
+
if @<%= file_name %> && @<%= file_name %>.update_attributes(:order_id => params[:p24_order_id],
|
53
|
+
:metoda => params[:p24_karta],
|
54
|
+
:order_id_full => params[:p24_order_id_full])
|
53
55
|
|
54
56
|
# verification with service - name in polish to be consistent with current PHP spec
|
55
57
|
przelewy24_weryfikuj
|
58
|
+
else
|
59
|
+
flash[:error] = 'Transaction not found'
|
60
|
+
redirect_to <%= table_name %>_url
|
56
61
|
end
|
57
62
|
end
|
58
63
|
|
59
64
|
def error
|
60
65
|
end
|
61
66
|
|
62
|
-
def verified
|
63
|
-
end
|
64
|
-
|
65
67
|
private
|
66
68
|
|
67
69
|
# Przelewy24.pl final verification process
|
@@ -88,8 +90,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
88
90
|
|
89
91
|
# check if transaction is not already used
|
90
92
|
unless @<%= file_name %>.is_verified
|
91
|
-
|
92
|
-
redirect_to accounts_url
|
93
|
+
@<%= file_name %>.update_attribute(:is_verified, true)
|
93
94
|
return
|
94
95
|
else
|
95
96
|
error_desc = t('transaction_already_used')
|
@@ -101,6 +102,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
101
102
|
error_desc = t('connection_error')
|
102
103
|
end
|
103
104
|
|
105
|
+
@<%= file_name %>.update_attribute(:error_code, results[2])
|
104
106
|
# display error flash and redirect to error action
|
105
107
|
flash[:error] = error_desc
|
106
108
|
redirect_to :action => :error
|
@@ -63,6 +63,9 @@ class <%= class_name %> < ActiveRecord::Base
|
|
63
63
|
# setting session id for connection with przelewy24
|
64
64
|
def set_session_id
|
65
65
|
self.session_id = <%= class_name %>.generate_session_id
|
66
|
+
self.id_sprzedawcy = SELLER_ID
|
67
|
+
self.kraj = COUNTRY
|
68
|
+
self.language = LANGUAGE
|
66
69
|
end
|
67
70
|
|
68
71
|
class <%= class_name %>Tools
|
@@ -1,11 +1,19 @@
|
|
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') %>
|
4
|
+
|
1
5
|
<%% form_tag 'https://secure.przelewy24.pl/index.php' do %>
|
2
6
|
|
3
|
-
<%%
|
4
|
-
|
7
|
+
<%% @payment.attributes_for_p24.each do |key, value| %>
|
8
|
+
<%% if key == 'p24_opis' %>
|
9
|
+
<%%= hidden_field_tag key, params[:test] || value %>
|
10
|
+
<%% else %>
|
11
|
+
<%%= hidden_field_tag key, value %>
|
12
|
+
<%% end %>
|
5
13
|
<%% end %>
|
6
14
|
|
7
|
-
<%%= hidden_field_tag
|
8
|
-
<%%= hidden_field_tag
|
15
|
+
<%%= hidden_field_tag :p24_return_url_ok, ok_<%= plural_name %>_url %>
|
16
|
+
<%%= hidden_field_tag :p24_return_url_error, error_<%= plural_name %>_url %>
|
9
17
|
|
10
18
|
<div id="confirm">
|
11
19
|
<p>
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
Transaction verification failed<br />
|
2
|
+
<%%= link_to t('transaction'), <%= plural_name %>_url %>
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-przelewy24
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- "Jakub Godawa, \xC5\x81ukasz Krystkowiak"
|
@@ -9,7 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-08 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -28,12 +34,13 @@ files:
|
|
28
34
|
- generators/przelewy24/USAGE
|
29
35
|
- generators/przelewy24/templates/model.rb
|
30
36
|
- generators/przelewy24/templates/view__form.html.erb
|
31
|
-
- generators/przelewy24/templates/view_verified.html.erb
|
32
37
|
- generators/przelewy24/templates/view_error.html.erb
|
33
38
|
- generators/przelewy24/templates/helper.rb
|
39
|
+
- generators/przelewy24/templates/INSTALL
|
34
40
|
- generators/przelewy24/templates/view_confirm.html.erb
|
35
41
|
- generators/przelewy24/templates/view_new.html.erb
|
36
42
|
- generators/przelewy24/templates/migration.rb
|
43
|
+
- generators/przelewy24/templates/view_ok.html.erb
|
37
44
|
- generators/przelewy24/templates/view_index.html.erb
|
38
45
|
- generators/przelewy24/templates/controller.rb
|
39
46
|
- generators/przelewy24/templates/view_show.html.erb
|
@@ -48,21 +55,27 @@ rdoc_options: []
|
|
48
55
|
require_paths:
|
49
56
|
- lib
|
50
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
51
59
|
requirements:
|
52
60
|
- - ">="
|
53
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
54
65
|
version: "0"
|
55
|
-
version:
|
56
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
57
68
|
requirements:
|
58
69
|
- - ">="
|
59
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
60
74
|
version: "0"
|
61
|
-
version:
|
62
75
|
requirements: []
|
63
76
|
|
64
77
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.3.
|
78
|
+
rubygems_version: 1.3.7
|
66
79
|
signing_key:
|
67
80
|
specification_version: 3
|
68
81
|
summary: Tool to deal with Przelewy24.pl payment service
|
@@ -1 +0,0 @@
|
|
1
|
-
|