payments-pl 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Michał Młoźniak
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.rdoc ADDED
@@ -0,0 +1,94 @@
1
+ = payments-pl
2
+
3
+ Simple library for handling payments via platnosci.pl
4
+
5
+ == Features
6
+
7
+ * Simple configuration (multiple POS-es)
8
+ * Transactions: create, get state, confirm, cancel
9
+ * View helper for generating payment form
10
+
11
+ == Installation
12
+
13
+ Install gem:
14
+
15
+ sudo gem install payments-pl
16
+
17
+ And add it n your environment.rb file:
18
+
19
+ config.gem 'payments-pl', :lib => 'payments_pl'
20
+
21
+ == Configuration
22
+
23
+ First add POS informations in config/payments.yml file:
24
+
25
+ bank:
26
+ pos_id: XXX
27
+ pos_auth_key: XXX
28
+ key1: XXX
29
+ key2: XXX
30
+ type: express_gateway
31
+
32
+ sms:
33
+ pos_id: XXX
34
+ pos_auth_key: XXX
35
+ key1: XXX
36
+ key2: XXX
37
+ type: sms_premium
38
+
39
+ Next add some routes so platnosci.pl can send messages to your application:
40
+
41
+ map.connect '/payments/ok', :controller => 'payments', :action => 'ok'
42
+ map.connect '/payments/error', :controller => 'payments', :action => 'error'
43
+ map.connect '/payments/report', :controller => 'payments', :action => 'report'
44
+
45
+ These urls must be the same as those you entered on platnosci.pl site.
46
+
47
+ == Usage
48
+
49
+ Creating new transaction in controller:
50
+
51
+ def some_action
52
+ @transaction = Payments['bank'].new_transaction(:amount => 100, :desc => 'Abonament', :client_ip => request.remote_addr, :js => '0')
53
+ end
54
+
55
+ Rendering payment form:
56
+
57
+ - form_tag @transaction.new_url do
58
+ = transaction_hidden_fields @transaction
59
+ = submit_tag 'Pay'
60
+
61
+ Controller for receiving messages from platnosci.pl:
62
+
63
+ class PaymentsController < ApplicationController
64
+ skip_before_filter :verify_authenticity_token
65
+
66
+ def error
67
+ render :text => Payments.error_text(params[:error])
68
+ end
69
+
70
+ def ok
71
+ render :text => 'Payment OK'
72
+ end
73
+
74
+ def report
75
+ status, transaction = Payments[params[:pos_id]].get params[:session_id]
76
+ if status == 'OK'
77
+ if transaction.trans_status == '99'
78
+ # paid, money received
79
+ else
80
+ # other stuff
81
+ end
82
+ end
83
+ render :text => 'OK'
84
+ end
85
+ end
86
+
87
+ Cancelling and confirming transaction is similar to getting transaction state:
88
+
89
+ status, transaction = Payments[params[:pos_id]].cancel params[:session_id]
90
+ status, transaction = Payments[params[:pos_id]].confirm params[:session_id]
91
+
92
+ == Copyright
93
+
94
+ Copyright (c) 2010 Michał Młoźniak. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "payments-pl"
8
+ gem.summary = %Q{Simple gem for payments via platnosci.pl}
9
+ gem.description = %Q{Simple gem for payments via platnosci.pl}
10
+ gem.email = "m.mlozniak@gmail.com"
11
+ gem.homepage = "http://github.com/ronin/payments-pl"
12
+ gem.authors = ["Michał Młoźniak"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'yard'
46
+ require 'yard/rake/yardoc_task'
47
+
48
+ YARD::Rake::YardocTask.new do |t|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ''
50
+
51
+ t.options += ['--title', "payments-pl #{version}"]
52
+ end
53
+
54
+ #require 'rake/rdoctask'
55
+ #Rake::RDocTask.new do |rdoc|
56
+ # version = File.exist?('VERSION') ? File.read('VERSION') : ""
57
+
58
+ # rdoc.rdoc_dir = 'rdoc'
59
+ # rdoc.title = "payments-pl #{version}"
60
+ # rdoc.rdoc_files.include('README*')
61
+ # rdoc.rdoc_files.include('lib/**/*.rb')
62
+ #end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.0