epay_tools 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e0100543f3eec103be865666ec628acb20c1f366
4
+ data.tar.gz: a9c15ea0e85a6af239e0beb3489c7562ae16a4e8
5
+ SHA512:
6
+ metadata.gz: d008febfe28466ed72b3fc69ec8d62eb142650764102e81902ac847ba8543fbc2715a7ab525cd8c544d920973593a4037b942b6cb8d372b1add0177691c39bb5
7
+ data.tar.gz: c9692d6a863186ca8b43bf43d5dc550843941aac968a304ca75316bc4b494fe9f8255b2a6641a3ec23b4c978c9f46729b6ebcfb06de26aa1237f7aee6c4a1336
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "auto_autoloader", ">= 0.0.5"
7
+ gem "service_pattern", ">= 0.0.3"
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "rspec", "~> 3.5.0"
13
+ gem "rdoc", "~> 3.12"
14
+ gem "bundler", "~> 1.0"
15
+ gem "jeweler", "2.3.7"
16
+ gem "simplecov", ">= 0"
17
+ end
@@ -0,0 +1,91 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ auto_autoloader (0.0.5)
6
+ string-cases
7
+ builder (3.2.3)
8
+ descendants_tracker (0.0.4)
9
+ thread_safe (~> 0.3, >= 0.3.1)
10
+ diff-lcs (1.3)
11
+ docile (1.1.5)
12
+ faraday (0.9.2)
13
+ multipart-post (>= 1.2, < 3)
14
+ git (1.3.0)
15
+ github_api (0.16.0)
16
+ addressable (~> 2.4.0)
17
+ descendants_tracker (~> 0.0.4)
18
+ faraday (~> 0.8, < 0.10)
19
+ hashie (>= 3.4)
20
+ mime-types (>= 1.16, < 3.0)
21
+ oauth2 (~> 1.0)
22
+ hashie (3.5.6)
23
+ highline (1.7.10)
24
+ jeweler (2.3.7)
25
+ builder
26
+ bundler (>= 1)
27
+ git (>= 1.2.5)
28
+ github_api (~> 0.16.0)
29
+ highline (>= 1.6.15)
30
+ nokogiri (>= 1.5.10)
31
+ psych (~> 2.2)
32
+ rake
33
+ rdoc
34
+ semver2
35
+ json (1.8.6)
36
+ jwt (1.5.6)
37
+ mime-types (2.99.3)
38
+ mini_portile2 (2.3.0)
39
+ multi_json (1.12.2)
40
+ multi_xml (0.6.0)
41
+ multipart-post (2.0.0)
42
+ nokogiri (1.8.1)
43
+ mini_portile2 (~> 2.3.0)
44
+ oauth2 (1.4.0)
45
+ faraday (>= 0.8, < 0.13)
46
+ jwt (~> 1.0)
47
+ multi_json (~> 1.3)
48
+ multi_xml (~> 0.5)
49
+ rack (>= 1.2, < 3)
50
+ psych (2.2.2)
51
+ rack (2.0.3)
52
+ rake (12.3.0)
53
+ rdoc (3.12.2)
54
+ json (~> 1.4)
55
+ rspec (3.5.0)
56
+ rspec-core (~> 3.5.0)
57
+ rspec-expectations (~> 3.5.0)
58
+ rspec-mocks (~> 3.5.0)
59
+ rspec-core (3.5.4)
60
+ rspec-support (~> 3.5.0)
61
+ rspec-expectations (3.5.0)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.5.0)
64
+ rspec-mocks (3.5.0)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.5.0)
67
+ rspec-support (3.5.0)
68
+ semver2 (3.4.2)
69
+ service_pattern (0.0.3)
70
+ simplecov (0.15.1)
71
+ docile (~> 1.1.0)
72
+ json (>= 1.8, < 3)
73
+ simplecov-html (~> 0.10.0)
74
+ simplecov-html (0.10.2)
75
+ string-cases (0.0.4)
76
+ thread_safe (0.3.6)
77
+
78
+ PLATFORMS
79
+ ruby
80
+
81
+ DEPENDENCIES
82
+ auto_autoloader (>= 0.0.5)
83
+ bundler (~> 1.0)
84
+ jeweler (= 2.3.7)
85
+ rdoc (~> 3.12)
86
+ rspec (~> 3.5.0)
87
+ service_pattern (>= 0.0.3)
88
+ simplecov
89
+
90
+ BUNDLED WITH
91
+ 1.15.4
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017 kaspernj
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.
@@ -0,0 +1,19 @@
1
+ = epay_tools
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to epay_tools
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) 2017 kaspernj. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,50 @@
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://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "epay_tools"
18
+ gem.homepage = "http://github.com/kaspernj/epay_tools"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Tools to implement the ePay payment gateway}
21
+ gem.description = %Q{Tools to implement the ePay payment gateway}
22
+ gem.email = "kaspernj@gmail.com"
23
+ gem.authors = ["kaspernj"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = "true"
37
+ Rake::Task['spec'].execute
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "epay_tools #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,73 @@
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: epay_tools 0.0.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "epay_tools".freeze
9
+ s.version = "0.0.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["kaspernj".freeze]
14
+ s.date = "2017-12-02"
15
+ s.description = "Tools to implement the ePay payment gateway".freeze
16
+ s.email = "kaspernj@gmail.com".freeze
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "epay_tools.gemspec",
31
+ "lib/epay_tools.rb",
32
+ "lib/epay_tools/hash_calculator_service.rb",
33
+ "lib/epay_tools/ordered_parameters.rb",
34
+ "lib/epay_tools/params_generator_service.rb",
35
+ "spec/epay_tools_spec.rb",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ s.homepage = "http://github.com/kaspernj/epay_tools".freeze
39
+ s.licenses = ["MIT".freeze]
40
+ s.rubygems_version = "2.6.11".freeze
41
+ s.summary = "Tools to implement the ePay payment gateway".freeze
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 4
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<auto_autoloader>.freeze, [">= 0.0.5"])
48
+ s.add_runtime_dependency(%q<service_pattern>.freeze, [">= 0.0.3"])
49
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
50
+ s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
51
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
52
+ s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.7"])
53
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<auto_autoloader>.freeze, [">= 0.0.5"])
56
+ s.add_dependency(%q<service_pattern>.freeze, [">= 0.0.3"])
57
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
58
+ s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
59
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
60
+ s.add_dependency(%q<jeweler>.freeze, ["= 2.3.7"])
61
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<auto_autoloader>.freeze, [">= 0.0.5"])
65
+ s.add_dependency(%q<service_pattern>.freeze, [">= 0.0.3"])
66
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
67
+ s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
68
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
69
+ s.add_dependency(%q<jeweler>.freeze, ["= 2.3.7"])
70
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
71
+ end
72
+ end
73
+
@@ -0,0 +1,6 @@
1
+ require "auto_autoloader"
2
+ require "service_pattern"
3
+
4
+ class EpayTools
5
+ AutoAutoloader.autoload_sub_classes(self, __FILE__)
6
+ end
@@ -0,0 +1,54 @@
1
+ class EpayTools::HashCalculatorService < ServicePattern::Service
2
+ DEFAULT_PARAMETERS = {
3
+ "merchantnumber" => nil,
4
+ "accepturl" => nil,
5
+ "callbackurl" => nil,
6
+ "orderid" => nil,
7
+ "amount" => nil,
8
+ "currency" => "DKK",
9
+ "ownreceipt" => "1",
10
+ "windowstate" => "2",
11
+ "instantcapture" => "1",
12
+ "paymentcollection" => "1",
13
+ "lockpaymentcollection" => "1",
14
+ "subscription" => "0"
15
+ }.freeze
16
+
17
+ attr_reader :query_parameters, :epay_md5_key
18
+
19
+ def initialize(query_parameters:, epay_md5_key:)
20
+ @query_parameters = query_parameters
21
+ @epay_md5_key = epay_md5_key
22
+ end
23
+
24
+ def execute!
25
+ ServicePattern::Response.new(
26
+ result: {
27
+ calculated_hash: calculated_hash,
28
+ validated: validated?
29
+ }
30
+ )
31
+ end
32
+
33
+ private
34
+
35
+ def calculated_hash
36
+ @_calculated_hash ||= Digest::MD5.hexdigest("#{parameters_to_use.values.join}#{epay_md5_key}")
37
+ end
38
+
39
+ def parameters_to_use
40
+ parameters = {}
41
+
42
+ EpayTools::OrderedParameters::ORDERED_PARAMETERS.each do |ordered_parameter|
43
+ parameters[selected_parameter] = query_parameters.fetch(ordered_parameter)
44
+ end
45
+
46
+ parameters
47
+ end
48
+
49
+ def validated?
50
+ return false unless query_parameters.key?("hash")
51
+ return true if calculated_hash == query_parameters.fetch("hash")
52
+ false
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ class EpayTools::OrderedParameters
2
+ ORDERED_PARAMETERS = [
3
+ "merchantnumber", "accepturl", "callbackurl", "orderid",
4
+ "amount", "currency", "ownreceipt", "windowstate",
5
+ "instantcapture", "paymentcollection", "lockpaymentcollection",
6
+ "subscription"
7
+ ].freeze
8
+ end
@@ -0,0 +1,26 @@
1
+ class EpayTools::ParamsGeneratorService < ServicePattern::Service
2
+ attr_reader :epay_merchant_number, :epay_md5_key, :params
3
+
4
+ def initialize(epay_md5_key:, params:)
5
+ @epay_md5_key = epay_md5_key
6
+ @params = params
7
+ end
8
+
9
+ def execute!
10
+ epay_params = {}
11
+ EpayTools::OrderedParameters::ORDERED_PARAMETERS.each do |ordered_parameter|
12
+ epay_params[ordered_parameter] = params.fetch(ordered_parameter)
13
+ end
14
+
15
+ epay_hash = Digest::MD5.hexdigest("#{epay_params.values.join}#{epay_md5_key}")
16
+ epay_params_with_hash = epay_params.merge("hash" => epay_hash)
17
+
18
+ ServicePattern::Response.new(
19
+ result: {
20
+ epay_params: epay_params,
21
+ epay_hash: epay_hash,
22
+ epay_params_with_hash: epay_params_with_hash
23
+ }
24
+ )
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe 'EpayTools' do
4
+ it 'fails' do
5
+ fail 'hey buddy, you should probably rename this file and start specing for real'
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
+
20
+ require 'rspec'
21
+ require 'epay_tools'
22
+
23
+ # Requires supporting files with custom matchers and macros, etc,
24
+ # in ./support/ and its subdirectories.
25
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
26
+
27
+ RSpec.configure do |config|
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: epay_tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - kaspernj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: auto_autoloader
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: service_pattern
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.3
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.5.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.5.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jeweler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.3.7
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.3.7
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Tools to implement the ePay payment gateway
112
+ email: kaspernj@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files:
116
+ - LICENSE.txt
117
+ - README.rdoc
118
+ files:
119
+ - ".document"
120
+ - ".rspec"
121
+ - Gemfile
122
+ - Gemfile.lock
123
+ - LICENSE.txt
124
+ - README.rdoc
125
+ - Rakefile
126
+ - VERSION
127
+ - epay_tools.gemspec
128
+ - lib/epay_tools.rb
129
+ - lib/epay_tools/hash_calculator_service.rb
130
+ - lib/epay_tools/ordered_parameters.rb
131
+ - lib/epay_tools/params_generator_service.rb
132
+ - spec/epay_tools_spec.rb
133
+ - spec/spec_helper.rb
134
+ homepage: http://github.com/kaspernj/epay_tools
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.6.11
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Tools to implement the ePay payment gateway
158
+ test_files: []