ogone-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.1.3"
12
+ gem "jeweler", "~> 1.8.3"
13
+ gem "rcov", ">= 0"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,25 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.3)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.6.6)
11
+ rake (0.9.2.2)
12
+ rcov (0.9.11)
13
+ rdoc (3.12)
14
+ json (~> 1.4)
15
+ shoulda (2.11.3)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bundler (~> 1.1.3)
22
+ jeweler (~> 1.8.3)
23
+ rcov
24
+ rdoc (~> 3.12)
25
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Robin Houdmeyers
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.md ADDED
@@ -0,0 +1,4 @@
1
+ ogone-rails
2
+ ===========
3
+
4
+ Add Ogone payments functionality to a Rails application
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = ogone-rails
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to ogone-rails
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Robin Houdmeyers. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "ogone-rails"
18
+ gem.homepage = "http://github.com/robinhoudmeyers/ogone-rails"
19
+ gem.license = "MIT"
20
+ gem.summary = "Ogone usable in Rails"
21
+ gem.description = "Add Ogone payments functionality to your Rails application"
22
+ gem.email = "houdmeyers@gmail.com"
23
+ gem.authors = ["Robin Houdmeyers"]
24
+ # dependencies defined in Gemfile
25
+
26
+ gem.files.include 'lib/**/*'
27
+ end
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ require 'rake/testtask'
31
+ Rake::TestTask.new(:test) do |test|
32
+ test.libs << 'lib' << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |test|
39
+ test.libs << 'test'
40
+ test.pattern = 'test/**/test_*.rb'
41
+ test.verbose = true
42
+ test.rcov_opts << '--exclude "gems/*"'
43
+ end
44
+
45
+ task :default => :test
46
+
47
+ require 'rdoc/task'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "ogone-rails #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,65 @@
1
+ module OgoneRails
2
+
3
+ module Config
4
+
5
+ TEST_SERVICE_URL = 'https://secure.ogone.com/ncol/test/orderstandard.asp'
6
+ LIVE_SERVICE_URL = 'https://secure.ogone.com/ncol/prod/orderstandard.asp'
7
+
8
+ # sha_in
9
+ def self.sha_in= sha
10
+ @sha_in = sha
11
+ end
12
+
13
+ def self.sha_in
14
+ @sha_in
15
+ end
16
+
17
+ # sha_out
18
+ def self.sha_out= sha
19
+ @sha_out = sha
20
+ end
21
+
22
+ def self.sha_out
23
+ @sha_out
24
+ end
25
+
26
+
27
+ # PSPID
28
+ def self.pspid= id
29
+ @pspid = id
30
+ end
31
+
32
+ def self.pspid
33
+ @pspid
34
+ end
35
+
36
+
37
+ # currency
38
+ def self.currency= currency
39
+ @currency = currency
40
+ end
41
+
42
+ def self.currency
43
+ @currency
44
+ end
45
+
46
+
47
+ # language
48
+ def self.language= language
49
+ @language = language
50
+ end
51
+
52
+ def self.language
53
+ @language
54
+ end
55
+
56
+ # debug
57
+ def self.debug= bool = false # default to production url
58
+ @test = bool
59
+ end
60
+
61
+ def self.debug
62
+ @test
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,76 @@
1
+ module OgoneRails
2
+ module Helpers
3
+ extend self
4
+
5
+ def ogone_form options={}
6
+ form = ""
7
+
8
+ if OgoneRails::Config.debug
9
+ form = "<form method='post' action='#{OgoneRails::Config::TEST_SERVICE_URL}'>\n"
10
+ else
11
+ form = "<form method='post' action='#{OgoneRails::Config::LIVE_SERVICE_URL}'>\n"
12
+ end
13
+
14
+ # REQUIRED VALUES
15
+ StringToHash::reset
16
+ # pspid
17
+ form << "\t<input type='hidden' name='PSPID' value='#{OgoneRails::Config.pspid}'>\n"
18
+ StringToHash::add_parameter 'PSPID', OgoneRails::Config.pspid
19
+ # currency
20
+ form << "\t<input type='hidden' name='currency' value='#{OgoneRails::Config.currency}'>\n"
21
+ StringToHash::add_parameter 'currency', OgoneRails::Config.currency
22
+ # language
23
+ form << "\t<input type='hidden' name='language' value='#{OgoneRails::Config.language}'>\n"
24
+ StringToHash::add_parameter 'language', OgoneRails::Config.language
25
+
26
+
27
+
28
+ # OPTIONAL VALUES
29
+ options.each do |option, value|
30
+ case option
31
+ when :order_id
32
+ form << "\t<input type='hidden' name='orderID' value='#{value}'>\n"
33
+ StringToHash::add_parameter 'orderID', value
34
+ when :amount
35
+ #amount 15.00 -> 1500
36
+ value = (value.to_f * 100).to_i
37
+ form << "\t<input type='hidden' name='amount' value='#{value}'>\n"
38
+ StringToHash::add_parameter 'amount', value
39
+ when :customer_name
40
+ form << "\t<input type='hidden' name='CN' value='#{value}'>\n"
41
+ StringToHash::add_parameter 'CN', value
42
+ when :customer_email
43
+ form << "\t<input type='hidden' name='EMAIL' value='#{value}'>\n"
44
+ StringToHash::add_parameter 'EMAIL', value
45
+ when :customer_address
46
+ form << "\t<input type='hidden' name='owneraddress' value='#{value}'>\n"
47
+ StringToHash::add_parameter 'owneraddress', value
48
+ when :customer_zip
49
+ form << "\t<input type='hidden' name='ownerZIP' value='#{value}'>\n"
50
+ StringToHash::add_parameter 'ownerZIP', value
51
+ when :customer_city
52
+ form << "\t<input type='hidden' name='ownertown' value='#{value}'>\n"
53
+ StringToHash::add_parameter 'ownertown', value
54
+ when :customer_country
55
+ form << "\t<input type='hidden' name='ownercty' value='#{value}'>\n"
56
+ StringToHash::add_parameter 'ownercty', value
57
+ when :customer_phone
58
+ form << "\t<input type='hidden' name='ownertelno' value='#{value}'>\n"
59
+ StringToHash::add_parameter 'ownertelno', value
60
+ else
61
+ form << "\t<input type='hidden' name='#{option}' value='#{value}'>\n"
62
+ end
63
+ end
64
+
65
+ # shasign
66
+ sha_in = StringToHash.generate_sha_in
67
+ form << "\t<input type='hidden' name='SHASign' value='#{sha_in}'>\n"
68
+
69
+ #submit
70
+ form << "\t<input type='submit' value='ga verder naar ogone' id='submit2' name='submit2'>\n"
71
+
72
+ form << "</form>"
73
+ form.html_safe
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ require File.join(File.dirname(__FILE__), 'helpers')
2
+
3
+ ActionView::Base.send(:include, OgoneRails::Helpers) if defined? ActionView
@@ -0,0 +1,36 @@
1
+ module OgoneRails
2
+ module StringToHash
3
+ extend self
4
+ @params = {}
5
+ @sha_in_phrase = ""
6
+
7
+ def add_parameter key, value
8
+ @params[key.upcase] = value
9
+ end
10
+
11
+ def generate_sha_in
12
+ @params.sort.each do |key, value|
13
+ @sha_in_phrase << "#{key.upcase}=#{value}#{OgoneRails::Config.sha_in}"
14
+ end
15
+
16
+ Digest::SHA1.hexdigest(@sha_in_phrase).upcase
17
+ end
18
+
19
+ def generate_sha_out
20
+
21
+ end
22
+
23
+ def self.params
24
+ @params
25
+ end
26
+
27
+ def self.sha_in_phrase
28
+ @sha_in_phrase
29
+ end
30
+
31
+ def reset
32
+ @sha_in_phrase = ""
33
+ @params = {}
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,53 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ require 'digest'
4
+
5
+ require 'ogone-rails/config'
6
+ require 'ogone-rails/rails'
7
+ require 'ogone-rails/string_to_hash'
8
+ require 'ogone-rails/helpers'
9
+
10
+
11
+ module OgoneRails
12
+ extend self
13
+
14
+ def check_auth feedback
15
+ sha_sign = feedback['SHASIGN']
16
+
17
+ params = {}
18
+
19
+ # upcase and sort paramaters to params
20
+ # exclude SHASIGN
21
+ feedback.each do |key, value|
22
+ params[key.upcase] = value unless key == 'SHASIGN'
23
+ end
24
+
25
+
26
+ sha_out_phrase = ""
27
+ # generate sha_out_hash
28
+ params.sort.each do |key, value|
29
+ sha_out_phrase << "#{key.upcase}=#{value}#{OgoneRails::Config.sha_out}"
30
+ end
31
+
32
+ sha_check = Digest::SHA1.hexdigest(sha_out_phrase).upcase
33
+
34
+ if sha_check == sha_sign
35
+ # return values in readable format
36
+ {
37
+ 'order_id' => feedback['orderID'],
38
+ 'amount' => feedback['amount'],
39
+ 'currency' => feedback['currency'],
40
+ 'payment_method' => feedback['PM'],
41
+ 'acceptance' => feedback['ACCEPTANCE'],
42
+ 'status' => feedback['STATUS'],
43
+ 'card_number' => feedback['CARDNO'],
44
+ 'pay_id' => feedback['PAYID'],
45
+ 'error' => feedback['NC ERROR'],
46
+ 'brand' => feedback['BRAND'],
47
+ 'sha_sign' => feedback['SHASIGN']
48
+ }
49
+ else
50
+ false
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,68 @@
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
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "ogone-rails"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Robin Houdmeyers"]
12
+ s.date = "2012-05-10"
13
+ s.description = "Add Ogone payments functionality to your Rails application"
14
+ s.email = "houdmeyers@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/ogone-rails.rb",
30
+ "lib/ogone-rails/config.rb",
31
+ "lib/ogone-rails/helpers.rb",
32
+ "lib/ogone-rails/rails.rb",
33
+ "lib/ogone-rails/string_to_hash.rb",
34
+ "ogone-rails.gemspec",
35
+ "test/helper.rb",
36
+ "test/test_ogone-rails.rb"
37
+ ]
38
+ s.homepage = "http://github.com/robinhoudmeyers/ogone-rails"
39
+ s.licenses = ["MIT"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = "1.8.17"
42
+ s.summary = "Ogone usable in Rails"
43
+
44
+ if s.respond_to? :specification_version then
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
52
+ s.add_development_dependency(%q<rcov>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
58
+ s.add_dependency(%q<rcov>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<shoulda>, [">= 0"])
62
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.1.3"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
65
+ s.add_dependency(%q<rcov>, [">= 0"])
66
+ end
67
+ end
68
+
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'ogone-rails'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestOgoneRails < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ogone-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robin Houdmeyers
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: &70279657186260 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70279657186260
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &70279657183380 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.12'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70279657183380
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &70279657182660 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.3
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70279657182660
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &70279657181700 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.3
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70279657181700
58
+ - !ruby/object:Gem::Dependency
59
+ name: rcov
60
+ requirement: &70279657180860 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70279657180860
69
+ description: Add Ogone payments functionality to your Rails application
70
+ email: houdmeyers@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files:
74
+ - LICENSE.txt
75
+ - README.md
76
+ - README.rdoc
77
+ files:
78
+ - .document
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - README.rdoc
84
+ - Rakefile
85
+ - VERSION
86
+ - lib/ogone-rails.rb
87
+ - lib/ogone-rails/config.rb
88
+ - lib/ogone-rails/helpers.rb
89
+ - lib/ogone-rails/rails.rb
90
+ - lib/ogone-rails/string_to_hash.rb
91
+ - ogone-rails.gemspec
92
+ - test/helper.rb
93
+ - test/test_ogone-rails.rb
94
+ homepage: http://github.com/robinhoudmeyers/ogone-rails
95
+ licenses:
96
+ - MIT
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ segments:
108
+ - 0
109
+ hash: -2064012355136434449
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 1.8.17
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: Ogone usable in Rails
122
+ test_files: []