sage_pay 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/LICENSE +21 -0
  2. data/README.md +39 -0
  3. data/Rakefile +146 -0
  4. data/lib/sage_pay.rb +3 -0
  5. data/sage_pay.gemspec +62 -0
  6. metadata +70 -0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Graeme Mathieson.
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ SagePay
2
+ =======
3
+
4
+ # Description
5
+
6
+ This is a Ruby library for integrating with SagePay. SagePay is a payment
7
+ gateway for accepting credit card payments through your web app. It offers
8
+ three different integration modes:
9
+
10
+ * Form, which is the simplest, and just involves crafting an HTML form that
11
+ submits information to SagePay. This is not something you're going to need
12
+ much help with, so this gem currently doesn't help you out there.
13
+
14
+ * Server, which is the sweet spot: you can do most of the transaction types
15
+ that you'd want to do, but you don't have to take/store credit card numbers,
16
+ so you don't have to worry too much about PCI compliance.
17
+
18
+ * Direct, the full-on integration where you take the credit card numbers
19
+ directly on your app and the client need never know you're talking to
20
+ SagePay to do the payment.
21
+
22
+ The current client app I'm writing is using SagePay Server, so that's where
23
+ the current implementation will be focused. Direct will follow when I (or
24
+ somebody else) has the impetus to do so.
25
+
26
+ # Installation
27
+
28
+ You should be able to install the gem directly from Gemcutter, the newly
29
+ default Rubygems repository. Simply do:
30
+
31
+ (sudo) gem install sage_pay
32
+
33
+ and you're good to go.
34
+
35
+ # Assumptions
36
+
37
+ This gem currently implements SagePay protocol version 2.23. The client app
38
+ I'm writing is in Rails, so there are probably some assumptions around that,
39
+ too.
@@ -0,0 +1,146 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ #############################################################################
6
+ #
7
+ # Helper functions
8
+ #
9
+ #############################################################################
10
+
11
+ def name
12
+ @name ||= Dir['*.gemspec'].first.split('.').first
13
+ end
14
+
15
+ def version
16
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
+ end
19
+
20
+ def date
21
+ Date.today.to_s
22
+ end
23
+
24
+ def rubyforge_project
25
+ name
26
+ end
27
+
28
+ def gemspec_file
29
+ "#{name}.gemspec"
30
+ end
31
+
32
+ def gem_file
33
+ "#{name}-#{version}.gem"
34
+ end
35
+
36
+ def replace_header(head, header_name)
37
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
+ end
39
+
40
+ #############################################################################
41
+ #
42
+ # Standard tasks
43
+ #
44
+ #############################################################################
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/testtask'
49
+ Rake::TestTask.new(:test) do |test|
50
+ test.libs << 'lib' << 'test'
51
+ test.pattern = 'test/**/test_*.rb'
52
+ test.verbose = true
53
+ end
54
+
55
+ desc "Generate RCov test coverage and open in your browser"
56
+ task :coverage do
57
+ require 'rcov'
58
+ sh "rm -fr coverage"
59
+ sh "rcov test/test_*.rb"
60
+ sh "open coverage/index.html"
61
+ end
62
+
63
+ require 'rake/rdoctask'
64
+ Rake::RDocTask.new do |rdoc|
65
+ rdoc.rdoc_dir = 'rdoc'
66
+ rdoc.title = "#{name} #{version}"
67
+ rdoc.rdoc_files.include('README*')
68
+ rdoc.rdoc_files.include('lib/**/*.rb')
69
+ end
70
+
71
+ desc "Open an irb session preloaded with this library"
72
+ task :console do
73
+ sh "irb -rubygems -r ./lib/#{name}.rb"
74
+ end
75
+
76
+ #############################################################################
77
+ #
78
+ # Custom tasks (add your own tasks here)
79
+ #
80
+ #############################################################################
81
+
82
+
83
+
84
+ #############################################################################
85
+ #
86
+ # Packaging tasks
87
+ #
88
+ #############################################################################
89
+
90
+ task :release => :build do
91
+ unless `git branch` =~ /^\* master$/
92
+ puts "You must be on the master branch to release!"
93
+ exit!
94
+ end
95
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
96
+ sh "git tag v#{version}"
97
+ sh "git push origin master"
98
+ sh "git push origin v#{version}"
99
+ sh "gem push pkg/#{name}-#{version}.gem"
100
+ end
101
+
102
+ task :build => :gemspec do
103
+ sh "mkdir -p pkg"
104
+ sh "gem build #{gemspec_file}"
105
+ sh "mv #{gem_file} pkg"
106
+ end
107
+
108
+ task :gemspec => :validate do
109
+ # read spec file and split out manifest section
110
+ spec = File.read(gemspec_file)
111
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
112
+
113
+ # replace name version and date
114
+ replace_header(head, :name)
115
+ replace_header(head, :version)
116
+ replace_header(head, :date)
117
+ #comment this out if your rubyforge_project has a different name
118
+ replace_header(head, :rubyforge_project)
119
+
120
+ # determine file list from git ls-files
121
+ files = `git ls-files`.
122
+ split("\n").
123
+ sort.
124
+ reject { |file| file =~ /^\./ }.
125
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
126
+ map { |file| " #{file}" }.
127
+ join("\n")
128
+
129
+ # piece file back together and write
130
+ manifest = " s.files = %w[\n#{files}\n ]\n"
131
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
132
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
133
+ puts "Updated #{gemspec_file}"
134
+ end
135
+
136
+ task :validate do
137
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
138
+ unless libfiles.empty?
139
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
140
+ exit!
141
+ end
142
+ unless Dir['VERSION*'].empty?
143
+ puts "A `VERSION` file at root level violates Gem best practices."
144
+ exit!
145
+ end
146
+ end
@@ -0,0 +1,3 @@
1
+ class SagePay
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,62 @@
1
+ Gem::Specification.new do |s|
2
+ s.specification_version = 2 if s.respond_to? :specification_version=
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+ s.rubygems_version = '1.3.6'
5
+
6
+ ## Leave these as is they will be modified for you by the rake gemspec task.
7
+ ## If your rubyforge_project name is different, then edit it and comment out
8
+ ## the sub! line in the Rakefile
9
+ s.name = 'sage_pay'
10
+ s.version = '0.1.0'
11
+ s.date = '2010-04-07'
12
+ s.rubyforge_project = 'sage_pay'
13
+
14
+ ## Make sure your summary is short. The description may be as long
15
+ ## as you like.
16
+ s.summary = "Ruby implementation of the SagePay payment gateway protocol."
17
+ s.description = <<-DESCRIPTION
18
+ This is a Ruby library for integrating with SagePay. SagePay is a payment
19
+ gateway for accepting credit card payments through your web app.
20
+ DESCRIPTION
21
+
22
+ ## List the primary authors. If there are a bunch of authors, it's probably
23
+ ## better to set the email to an email list or something. If you don't have
24
+ ## a custom homepage, consider using your GitHub URL or the like.
25
+ s.authors = ["Graeme Mathieson"]
26
+ s.email = 'mathie@woss.name'
27
+ s.homepage = 'http://github.com/mathie/sage_pay'
28
+
29
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
30
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
31
+ s.require_paths = %w[lib]
32
+
33
+ ## Specify any RDoc options here. You'll want to add your README and
34
+ ## LICENSE files to the extra_rdoc_files list.
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.extra_rdoc_files = %w[README.md LICENSE]
37
+
38
+ ## List your runtime dependencies here. Runtime dependencies are those
39
+ ## that are needed for an end user to actually USE your code.
40
+ # s.add_dependency('DEPNAME', [">= 1.1.0", "< 2.0.0"])
41
+
42
+ ## List your development dependencies here. Development dependencies are
43
+ ## those that are only needed during development
44
+ # s.add_development_dependency('DEVDEPNAME', [">= 1.1.0", "< 2.0.0"])
45
+
46
+ ## Leave this section as-is. It will be automatically generated from the
47
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
48
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
49
+ # = MANIFEST =
50
+ s.files = %w[
51
+ LICENSE
52
+ README.md
53
+ Rakefile
54
+ lib/sage_pay.rb
55
+ sage_pay.gemspec
56
+ ]
57
+ # = MANIFEST =
58
+
59
+ ## Test files will be grabbed from the file list. Make sure the path glob
60
+ ## matches what you actually use.
61
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
62
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sage_pay
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Graeme Mathieson
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-07 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: |
22
+ This is a Ruby library for integrating with SagePay. SagePay is a payment
23
+ gateway for accepting credit card payments through your web app.
24
+
25
+ email: mathie@woss.name
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README.md
32
+ - LICENSE
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - lib/sage_pay.rb
38
+ - sage_pay.gemspec
39
+ has_rdoc: true
40
+ homepage: http://github.com/mathie/sage_pay
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --charset=UTF-8
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project: sage_pay
65
+ rubygems_version: 1.3.6
66
+ signing_key:
67
+ specification_version: 2
68
+ summary: Ruby implementation of the SagePay payment gateway protocol.
69
+ test_files: []
70
+