rails-ogone 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b1960fe7e81dd13b9a8a2f0caecb7f16614f23d
4
+ data.tar.gz: d7de644e0f9e33d67f625523fb462091f55d29cd
5
+ SHA512:
6
+ metadata.gz: df13d902db0cfe4f5a01f9e5ad549048462a973fdd40c4b50c0ef3437c276f63c28d2a746815f393cd5f7445cf2451a49ca99c7f07aa0c77c12a58fb50783c5c
7
+ data.tar.gz: c2dc59dc5b2c84d8fd800206290d2fa1062bbcb89e6c071afbf065e3d100990810ab9072e7e5035adf85853055734b0b2a1479f7e77ddc5afb07920495aba914
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'activesupport', '~> 4.1'
4
+ gem 'actionview', '~> 4.1'
5
+
6
+ group :development do
7
+ gem 'rspec', '~> 3.1'
8
+ gem 'rspec-mocks', '~> 3.1'
9
+ gem 'guard', '~> 2.6'
10
+ gem 'guard-rspec', '~> 4.3'
11
+ gem 'rdoc', '~> 4.1'
12
+ gem 'bundler', '~> 1.6'
13
+ gem 'jeweler', '~> 2.0'
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,122 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionview (4.1.6)
5
+ activesupport (= 4.1.6)
6
+ builder (~> 3.1)
7
+ erubis (~> 2.7.0)
8
+ activesupport (4.1.6)
9
+ i18n (~> 0.6, >= 0.6.9)
10
+ json (~> 1.7, >= 1.7.7)
11
+ minitest (~> 5.1)
12
+ thread_safe (~> 0.1)
13
+ tzinfo (~> 1.1)
14
+ addressable (2.3.6)
15
+ builder (3.2.2)
16
+ celluloid (0.16.0)
17
+ timers (~> 4.0.0)
18
+ coderay (1.1.0)
19
+ descendants_tracker (0.0.4)
20
+ thread_safe (~> 0.3, >= 0.3.1)
21
+ diff-lcs (1.2.5)
22
+ erubis (2.7.0)
23
+ faraday (0.9.0)
24
+ multipart-post (>= 1.2, < 3)
25
+ ffi (1.9.5)
26
+ formatador (0.2.5)
27
+ git (1.2.8)
28
+ github_api (0.12.1)
29
+ addressable (~> 2.3)
30
+ descendants_tracker (~> 0.0.4)
31
+ faraday (~> 0.8, < 0.10)
32
+ hashie (>= 3.2)
33
+ multi_json (>= 1.7.5, < 2.0)
34
+ nokogiri (~> 1.6.3)
35
+ oauth2
36
+ guard (2.6.1)
37
+ formatador (>= 0.2.4)
38
+ listen (~> 2.7)
39
+ lumberjack (~> 1.0)
40
+ pry (>= 0.9.12)
41
+ thor (>= 0.18.1)
42
+ guard-rspec (4.3.1)
43
+ guard (~> 2.1)
44
+ rspec (>= 2.14, < 4.0)
45
+ hashie (3.3.1)
46
+ highline (1.6.21)
47
+ hitimes (1.2.2)
48
+ i18n (0.6.11)
49
+ jeweler (2.0.1)
50
+ builder
51
+ bundler (>= 1.0)
52
+ git (>= 1.2.5)
53
+ github_api
54
+ highline (>= 1.6.15)
55
+ nokogiri (>= 1.5.10)
56
+ rake
57
+ rdoc
58
+ json (1.8.1)
59
+ jwt (1.0.0)
60
+ listen (2.7.11)
61
+ celluloid (>= 0.15.2)
62
+ rb-fsevent (>= 0.9.3)
63
+ rb-inotify (>= 0.9)
64
+ lumberjack (1.0.9)
65
+ method_source (0.8.2)
66
+ mini_portile (0.6.0)
67
+ minitest (5.4.2)
68
+ multi_json (1.10.1)
69
+ multi_xml (0.5.5)
70
+ multipart-post (2.0.0)
71
+ nokogiri (1.6.3.1)
72
+ mini_portile (= 0.6.0)
73
+ oauth2 (1.0.0)
74
+ faraday (>= 0.8, < 0.10)
75
+ jwt (~> 1.0)
76
+ multi_json (~> 1.3)
77
+ multi_xml (~> 0.5)
78
+ rack (~> 1.2)
79
+ pry (0.10.1)
80
+ coderay (~> 1.1.0)
81
+ method_source (~> 0.8.1)
82
+ slop (~> 3.4)
83
+ rack (1.5.2)
84
+ rake (10.3.2)
85
+ rb-fsevent (0.9.4)
86
+ rb-inotify (0.9.5)
87
+ ffi (>= 0.5.0)
88
+ rdoc (4.1.2)
89
+ json (~> 1.4)
90
+ rspec (3.1.0)
91
+ rspec-core (~> 3.1.0)
92
+ rspec-expectations (~> 3.1.0)
93
+ rspec-mocks (~> 3.1.0)
94
+ rspec-core (3.1.7)
95
+ rspec-support (~> 3.1.0)
96
+ rspec-expectations (3.1.2)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.1.0)
99
+ rspec-mocks (3.1.3)
100
+ rspec-support (~> 3.1.0)
101
+ rspec-support (3.1.2)
102
+ slop (3.6.0)
103
+ thor (0.19.1)
104
+ thread_safe (0.3.4)
105
+ timers (4.0.1)
106
+ hitimes
107
+ tzinfo (1.2.2)
108
+ thread_safe (~> 0.1)
109
+
110
+ PLATFORMS
111
+ ruby
112
+
113
+ DEPENDENCIES
114
+ actionview (~> 4.1)
115
+ activesupport (~> 4.1)
116
+ bundler (~> 1.6)
117
+ guard (~> 2.6)
118
+ guard-rspec (~> 4.3)
119
+ jeweler (~> 2.0)
120
+ rdoc (~> 4.1)
121
+ rspec (~> 3.1)
122
+ rspec-mocks (~> 3.1)
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Dave Lens
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # RailsOgone
2
+ ## Description
3
+ This gem provides the bare minimum to integrate simple Ogone payments into your Rails app. It assumes basic knowledge of how Ogone works, and how it is configured for your project.
4
+
5
+ ## Installation
6
+ In your Gemfile:
7
+ ```
8
+ gem 'rails-ogone'
9
+ ```
10
+ Or, from the commandline:
11
+ ```
12
+ gem install rails-ogone
13
+ ```
14
+ Once the gem is installed, in your Rails root dir:
15
+ ```
16
+ rails g ogone:config
17
+ ```
18
+ ## Configuration
19
+ The generator should have created the ```config/ogone.yml``` configuration file. In it, you need to define your Ogone PSPID, and the configured SHA-in/out strings for each corresponding Rails environment:
20
+ ```YAML
21
+ development: &development
22
+ pspid: 'CHANGEME'
23
+ sha_in: ''
24
+ sha_out: ''
25
+
26
+ test:
27
+ <<: *development
28
+
29
+ production:
30
+ pspid: 'CHANGEME'
31
+ sha_in: ''
32
+ sha_out: ''
33
+ ```
34
+
35
+ ## Implementation in Rails
36
+ All you need to do is use the ```ogone_form_tag``` helper method in your Rails view, at the point where you implement your payment step:
37
+ ```ERB
38
+ <%= ogone_form_tag do |f| %>
39
+ <%= f.input 'ORDERID', 'BOGUS001' %>
40
+ <%= f.input 'CURRENCY', 'EUR' %>
41
+ <%= f.input 'LANGUAGE', 'nl_BE' %>
42
+ <%= f.input 'ACCEPTURL', '' %>
43
+ <%= f.input 'CANCELURL', '' %>
44
+ <%= f.input 'DECLINEURL', '' %>
45
+ <%= f.input 'EXCEPTIONURL', '' %>
46
+ <%# AMOUNT can be a decimal value. This gem converts it accordingly to an int as per Ogone's requirements. %>
47
+ <%= f.input 'AMOUNT', '37.99' %>
48
+ <%= f.input 'CN', 'Dave Lens' %>
49
+ <%= f.input 'EMAIL', 'customer@example.com' %>
50
+ <%= f.input 'OWNERCTY', 'BE' %>
51
+ <%= f.input 'ECOM_SHIPTO_POSTAL_NAME_FIRST', 'Dave' %>
52
+ <%= f.input 'ECOM_SHIPTO_POSTAL_NAME_LAST', 'Lens' %>
53
+ <%= f.input 'ECOM_SHIPTO_POSTAL_COUNTRYCODE', 'BE' %>
54
+ <%# ... %>
55
+ <% end %>
56
+ ```
57
+ There is, purposefully, very little magic going on here. The SHASIGN and PSPID parameters are automatically added to your Ogone form as hidden fields. All other desired parameters must be added manually.
58
+
59
+ This will generate the following form markup in your development environment:
60
+ ```html
61
+ <form action="https://secure.ogone.com/ncol/test/orderstandard.asp" method="post">
62
+ <input type="hidden" value="CHANGEME" name="PSPID">
63
+ <input type="hidden" value="BOGUS001" name="ORDERID">
64
+ <input type="hidden" value="EUR" name="CURRENCY">
65
+ <input type="hidden" value="nl_BE" name="LANGUAGE">
66
+ <input type="hidden" value="" name="ACCEPTURL">
67
+ <input type="hidden" value="" name="CANCELURL">
68
+ <input type="hidden" value="" name="DECLINEURL">
69
+ <input type="hidden" value="" name="EXCEPTIONURL">
70
+ <input type="hidden" value="3799" name="AMOUNT">
71
+ <input type="hidden" value="Dave Lens" name="CN">
72
+ <input type="hidden" value="customer@example.com" name="EMAIL">
73
+ <input type="hidden" value="BE" name="OWNERCTY">
74
+ <input type="hidden" value="Dave" name="ECOM_SHIPTO_POSTAL_NAME_FIRST">
75
+ <input type="hidden" value="Lens" name="ECOM_SHIPTO_POSTAL_NAME_LAST">
76
+ <input type="hidden" value="BE" name="ECOM_SHIPTO_POSTAL_COUNTRYCODE">
77
+ <input type="hidden" value="61573629B6A26EB3BA5E799BA0984EAB5787D27B" name="SHASIGN">
78
+ ...
79
+ </form>
80
+ ```
81
+ ## Running tests
82
+ This gem uses RSpec (and optionally Guard) for its tests. So in your CLI, run the magic word to get them to run:
83
+ ```bash
84
+ $ rspec
85
+ ```
86
+ ## What about non-Rails apps?
87
+ It's possible this gem will work in non-Rails apps, assuming you have the ```config/ogone.yml``` file in place that the Rails generator would normally create for you. Though, this is untested at the moment of writing. If you want to give it a go, look at [lib/rails-ogone/helper.rb](https://github.com/davelens/rails-ogone/blob/master/lib/rails-ogone/helper.rb) to get you started.
88
+
89
+ ## Copyright
90
+ Copyright (c) 2015 Dave Lens, released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ require 'rake'
13
+ require 'jeweler'
14
+
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = 'rails-ogone'
17
+ gem.homepage = 'https://github.com/davelens/rails-ogone'
18
+ gem.license = 'MIT'
19
+ gem.summary = 'Ogone functionality for Rails.'
20
+ gem.description = 'Rails gem to facilitate simple payments with Ogone.'
21
+ gem.email = 'github@davelens.be'
22
+ gem.authors = ['Dave Lens']
23
+
24
+ gem.files.include 'lib/**/*'
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rdoc/task'
29
+ Rake::RDocTask.new do |rdoc|
30
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
31
+
32
+ rdoc.rdoc_dir = 'rdoc'
33
+ rdoc.title = "rails-ogone #{version}"
34
+ rdoc.rdoc_files.include('README*')
35
+ rdoc.rdoc_files.include('lib/**/*.rb')
36
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,20 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Ogone
4
+ class ConfigGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ desc 'Generates config files for rails-ogone.'
8
+ def copy_files
9
+ say_status 'OK', 'Copying to config/ogone.yml', :yellow
10
+ copy_file 'ogone.yml', 'config/ogone.yml'
11
+ say_status 'OK', 'Copying to config/initializers/ogone.rb', :yellow
12
+ copy_file 'ogone.rb', 'config/initializers/ogone.rb'
13
+ end
14
+
15
+ def print_manual
16
+ say_status 'OK', 'Done.', :green
17
+ say "\nRemember to set your PSPID and SHA-IN/OUT vars in config/ogone.yml.", :bold
18
+ end
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ ActionView::Base.send(:include, RailsOgone::Helper) if defined? ActionView
@@ -0,0 +1,12 @@
1
+ development: &development
2
+ pspid: 'CHANGEME'
3
+ sha_in: ''
4
+ sha_out: ''
5
+
6
+ test:
7
+ <<: *development
8
+
9
+ production:
10
+ pspid: 'CHANGEME'
11
+ sha_in: ''
12
+ sha_out: ''
@@ -0,0 +1,34 @@
1
+ module RailsOgone
2
+ class Form
3
+ attr_reader :hash
4
+
5
+ def initialize(environment = 'test')
6
+ @environment = environment == 'production' ? 'prod' : 'test'
7
+ @form_fields = {}
8
+ @hash = RailsOgone::Hash.new
9
+ end
10
+
11
+ def action_url
12
+ "https://secure.ogone.com/ncol/#{@environment}/orderstandard.asp"
13
+ end
14
+
15
+ def input(name, value)
16
+ value = (value.to_f * 100).to_i if name.downcase == 'amount'
17
+ @form_fields[name] = value
18
+ @hash.add_parameter name, value
19
+ html_string = "<input type=\"hidden\" name=\"%s\" value=\"%s\" />" % [name.upcase, value]
20
+ ActiveSupport::SafeBuffer.new html_string
21
+ end
22
+
23
+ def tag(options = {})
24
+ options[:action] = action_url
25
+
26
+ form_attributes = options.inject('') do |attributes, pair|
27
+ attributes << " #{pair[0]}=\"#{pair[1]}\""
28
+ end
29
+
30
+ output = "<form method=\"post\"#{form_attributes}>"
31
+ ActiveSupport::SafeBuffer.new output
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ module RailsOgone
2
+ class Hash
3
+ attr_accessor :params, :sha_in_phrase
4
+
5
+ def initialize
6
+ @params = {}
7
+ @sha_in_phrase = ""
8
+ end
9
+
10
+ def add_parameter(key, value)
11
+ @params[key.upcase] = value
12
+ end
13
+
14
+ def generate
15
+ @params.sort.each do |key, value|
16
+ @sha_in_phrase << "#{key.upcase}=#{value}#{RailsOgone.sha_in}"
17
+ end
18
+
19
+ Digest::SHA1.hexdigest(@sha_in_phrase).upcase
20
+ end
21
+
22
+ def raw
23
+ @params.inject('') do |result,pair|
24
+ result << "#{pair[0]}=#{pair[1]}"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ module RailsOgone
2
+ module Helper
3
+ def ogone_form_tag(options = {}, &block)
4
+ @ogone_form = RailsOgone::Form.new Rails.env
5
+ output = @ogone_form.tag options
6
+ output << @ogone_form.input('PSPID', RailsOgone.pspid)
7
+ output << capture(@ogone_form, &block)
8
+ output << @ogone_form.input('SHASIGN', @ogone_form.hash.generate)
9
+ output << "\n</form>".html_safe
10
+ output.html_safe
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ require 'rails-ogone/helper'
2
+ require 'rails-ogone/form'
3
+ require 'rails-ogone/hash'
4
+ require 'active_support/all'
5
+
6
+ module RailsOgone
7
+ attr_reader :config
8
+
9
+ ROOT = File.expand_path((defined?(Rails) && Rails.root.to_s.length > 0) ? Rails.root : ENV['RAILS_ROOT'] || '.') unless defined?(ROOT)
10
+
11
+ def self.load!
12
+ config_file = File.join(ROOT, 'config/ogone.yml')
13
+
14
+ if File.exists?(config_file)
15
+ @config ||= YAML.load_file(config_file)[Rails.env].symbolize_keys
16
+
17
+ @config.each do |k,v|
18
+ self.class.send(:define_method, k) { v }
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ RailsOgone.load! if defined?(Rails) && Rails.env != 'test'
@@ -0,0 +1,82 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: rails-ogone 0.1.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "rails-ogone"
9
+ s.version = "0.1.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Dave Lens"]
14
+ s.date = "2015-01-06"
15
+ s.description = "Rails gem to facilitate simple payments with Ogone."
16
+ s.email = "github@davelens.be"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "Guardfile",
25
+ "LICENSE",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/generators/ogone/config_generator.rb",
30
+ "lib/generators/ogone/templates/ogone.rb",
31
+ "lib/generators/ogone/templates/ogone.yml",
32
+ "lib/rails-ogone.rb",
33
+ "lib/rails-ogone/form.rb",
34
+ "lib/rails-ogone/hash.rb",
35
+ "lib/rails-ogone/helper.rb",
36
+ "rails-ogone.gemspec",
37
+ "spec/lib/rails-ogone/form_spec.rb",
38
+ "spec/lib/rails-ogone/hash_spec.rb",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+ s.homepage = "https://github.com/davelens/rails-ogone"
42
+ s.licenses = ["MIT"]
43
+ s.rubygems_version = "2.2.2"
44
+ s.summary = "Ogone functionality for Rails."
45
+
46
+ if s.respond_to? :specification_version then
47
+ s.specification_version = 4
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<activesupport>, ["~> 4.1"])
51
+ s.add_runtime_dependency(%q<actionview>, ["~> 4.1"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 3.1"])
53
+ s.add_development_dependency(%q<rspec-mocks>, ["~> 3.1"])
54
+ s.add_development_dependency(%q<guard>, ["~> 2.6"])
55
+ s.add_development_dependency(%q<guard-rspec>, ["~> 4.3"])
56
+ s.add_development_dependency(%q<rdoc>, ["~> 4.1"])
57
+ s.add_development_dependency(%q<bundler>, ["~> 1.6"])
58
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
59
+ else
60
+ s.add_dependency(%q<activesupport>, ["~> 4.1"])
61
+ s.add_dependency(%q<actionview>, ["~> 4.1"])
62
+ s.add_dependency(%q<rspec>, ["~> 3.1"])
63
+ s.add_dependency(%q<rspec-mocks>, ["~> 3.1"])
64
+ s.add_dependency(%q<guard>, ["~> 2.6"])
65
+ s.add_dependency(%q<guard-rspec>, ["~> 4.3"])
66
+ s.add_dependency(%q<rdoc>, ["~> 4.1"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
68
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<activesupport>, ["~> 4.1"])
72
+ s.add_dependency(%q<actionview>, ["~> 4.1"])
73
+ s.add_dependency(%q<rspec>, ["~> 3.1"])
74
+ s.add_dependency(%q<rspec-mocks>, ["~> 3.1"])
75
+ s.add_dependency(%q<guard>, ["~> 2.6"])
76
+ s.add_dependency(%q<guard-rspec>, ["~> 4.3"])
77
+ s.add_dependency(%q<rdoc>, ["~> 4.1"])
78
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
79
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
80
+ end
81
+ end
82
+
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsOgone::Form do
4
+ let(:instance) { described_class.new }
5
+
6
+ it '#input' do
7
+ expect(instance.input('foo', 'bar')).to eq '<input type="hidden" name="FOO" value="bar" />'
8
+ end
9
+
10
+ describe '#action_url' do
11
+ it :prod do
12
+ instance = described_class.new 'production'
13
+ expect(instance.action_url).to eq 'https://secure.ogone.com/ncol/prod/orderstandard.asp'
14
+ end
15
+
16
+ it :test do
17
+ expect(instance.action_url).to eq 'https://secure.ogone.com/ncol/test/orderstandard.asp'
18
+ end
19
+ end
20
+
21
+ describe '#tag' do
22
+ it :prod do
23
+ instance = described_class.new 'production'
24
+ expect(instance.tag).to eq '<form method="post" action="https://secure.ogone.com/ncol/prod/orderstandard.asp">'
25
+ end
26
+
27
+ it :test do
28
+ expect(instance.tag).to eq '<form method="post" action="https://secure.ogone.com/ncol/test/orderstandard.asp">'
29
+ end
30
+
31
+ it :parameters do
32
+ expect(instance.tag(class: 'test')).to eq '<form method="post" class="test" action="https://secure.ogone.com/ncol/test/orderstandard.asp">'
33
+ end
34
+ end
35
+
36
+ it '#respond_to?' do
37
+ expect(instance).to respond_to(:input, :action_url, :tag)
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsOgone::Hash do
4
+ let(:instance) { described_class.new }
5
+
6
+ it '#add_parameter' do
7
+ instance.add_parameter 'foo', 'bar'
8
+ expect(instance.params).to eq({ 'FOO' => 'bar' })
9
+ end
10
+
11
+ it '#generate' do
12
+ allow(RailsOgone).to receive(:sha_in) { 'this is the sha-in' }
13
+ instance.add_parameter 'foo', 'bar'
14
+ instance.add_parameter 'bar', 'baz'
15
+ expect(instance.generate).to eq '33800C8F9902DD147EBBFD5DB86E96F3FE754173'
16
+ end
17
+
18
+ it '#raw' do
19
+ instance.add_parameter 'foo', 'bar'
20
+ instance.add_parameter 'bar', 'baz'
21
+ expect(instance.raw).to eq 'FOO=barBAR=baz'
22
+ end
23
+
24
+ it '#respond_to?' do
25
+ expect(instance).to respond_to(:add_parameter, :generate, :raw)
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require 'rspec'
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'templates'))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ $LOAD_PATH.unshift(File.expand_path('../lib/generators/ogone/templates', __FILE__))
7
+
8
+ require 'rails-ogone'
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-ogone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dave Lens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionview
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-mocks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rdoc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: bundler
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.6'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.6'
125
+ - !ruby/object:Gem::Dependency
126
+ name: jeweler
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.0'
139
+ description: Rails gem to facilitate simple payments with Ogone.
140
+ email: github@davelens.be
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files:
144
+ - LICENSE
145
+ - README.md
146
+ files:
147
+ - Gemfile
148
+ - Gemfile.lock
149
+ - Guardfile
150
+ - LICENSE
151
+ - README.md
152
+ - Rakefile
153
+ - VERSION
154
+ - lib/generators/ogone/config_generator.rb
155
+ - lib/generators/ogone/templates/ogone.rb
156
+ - lib/generators/ogone/templates/ogone.yml
157
+ - lib/rails-ogone.rb
158
+ - lib/rails-ogone/form.rb
159
+ - lib/rails-ogone/hash.rb
160
+ - lib/rails-ogone/helper.rb
161
+ - rails-ogone.gemspec
162
+ - spec/lib/rails-ogone/form_spec.rb
163
+ - spec/lib/rails-ogone/hash_spec.rb
164
+ - spec/spec_helper.rb
165
+ homepage: https://github.com/davelens/rails-ogone
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.2.2
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Ogone functionality for Rails.
189
+ test_files: []