ipizza-rails 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -17,6 +17,23 @@ To start using iPizza in your rails application, you need to run the **init** ge
17
17
  This will create an example configuration file to `config/ipizza.yml` and create `config/certificates` directory and
18
18
  puts some test certificates into it.
19
19
 
20
+ View helpers
21
+ ------------
22
+
23
+ It is very convenient to put together form that will be submitted for payment request to payment provider with allthemighty `ipizza_form_for` view helper.
24
+
25
+ In your controller, perhaps, declare payment object:
26
+
27
+ @payment = Ipizza::Payment.new(
28
+ :stamp => 123456, :amount => '15.00', :refnum => 1, :message => 'For all the candy', :currency => 'EUR'
29
+ )
30
+
31
+ And in view file, generate form for Swedbank, for example:
32
+
33
+ <%= ipizza_payment_form_tag @payment, :service => :swedbank do %>
34
+ <%= submit_tag 'Pay some moneys' %>
35
+ <% end %>
36
+
20
37
  TODO:
21
38
  -----
22
39
 
@@ -0,0 +1,26 @@
1
+ module Ipizza
2
+ module Rails
3
+ module FormHelpers
4
+ def ipizza_payment_form_tag(payment, options = {}, &block)
5
+ request = case options.delete(:service).to_sym
6
+ when :swedbank
7
+ Ipizza::Provider::Swedbank.new.payment_request(payment)
8
+ when :seb
9
+ Ipizza::Provider::Seb.new.payment_request(payment)
10
+ when :sampo
11
+ Ipizza::Provider::Sampo.new.payment_request(payment)
12
+ when :nordea
13
+ Ipizza::Provider::Nordea.new.payment_request(payment)
14
+ end
15
+
16
+ form_tag(request.service_url, options) do
17
+ request.request_params.each do |name, value|
18
+ concat(hidden_field_tag(name, value))
19
+ end
20
+
21
+ yield if block_given?
22
+ end if request
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,8 @@
1
1
  require 'ipizza'
2
2
  require 'rails'
3
3
 
4
+ require 'ipizza-rails/form_helpers'
5
+
4
6
  class Ipizza::Rails::Railtie < ::Rails::Railtie
5
7
 
6
8
  generators do
@@ -16,4 +18,8 @@ class Ipizza::Rails::Railtie < ::Rails::Railtie
16
18
  end
17
19
  end
18
20
  end
21
+
22
+ initializer 'ipizza-rails.view_helpers' do
23
+ ActionView::Base.send :include, Ipizza::Rails::FormHelpers
24
+ end
19
25
  end
@@ -1,5 +1,5 @@
1
1
  module Ipizza
2
2
  module Rails
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipizza-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Priit Haamer
@@ -64,9 +64,9 @@ files:
64
64
  - Gemfile
65
65
  - README.markdown
66
66
  - Rakefile
67
- - VERSION
68
67
  - ipizza-rails.gemspec
69
68
  - lib/ipizza-rails.rb
69
+ - lib/ipizza-rails/form_helpers.rb
70
70
  - lib/ipizza-rails/generator/init.rb
71
71
  - lib/ipizza-rails/generator/notification.rb
72
72
  - lib/ipizza-rails/generator/templates/certificates/nordea_test_priv
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.0