killbill-payment-test 0.0.1 → 1.0.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/.gitignore +23 -0
- data/Gemfile +5 -0
- data/Jarfile +3 -0
- data/README.md +5 -0
- data/Rakefile +12 -32
- data/VERSION +1 -0
- data/killbill-payment-test.gemspec +32 -0
- data/killbill.properties +3 -0
- data/lib/payment_test/api.rb +92 -0
- data/lib/payment_test.rb +1 -23
- data/spec/payment_test/base_plugin_spec.rb +30 -0
- data/spec/spec_helper.rb +15 -0
- metadata +78 -350
- checksums.yaml +0 -7
- data/MIT-LICENSE +0 -20
- data/app/assets/javascripts/application.js +0 -24
- data/app/assets/javascripts/payment_test/payment_test.js +0 -7
- data/app/assets/stylesheets/application.css +0 -20
- data/app/assets/stylesheets/bootstrap_and_overrides.css +0 -17
- data/app/assets/stylesheets/payment_test/payment_test.css +0 -6
- data/app/controllers/payment_test/engine_controller.rb +0 -29
- data/app/controllers/payment_test/payments_controller.rb +0 -66
- data/app/helpers/payment_test/application_helper.rb +0 -4
- data/app/views/payment_test/layouts/payment_test_application.html.erb +0 -31
- data/app/views/payment_test/payments/index.html.erb +0 -45
- data/config/routes.rb +0 -12
- data/lib/payment_test/client.rb +0 -74
- data/lib/payment_test/engine.rb +0 -24
- data/lib/payment_test/version.rb +0 -3
- data/lib/tasks/payment_test_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -29
- data/test/dummy/config/application.rb +0 -32
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -23
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/killbill_client.rb +0 -3
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/config.ru +0 -4
- data/test/integration/navigation_test.rb +0 -8
- data/test/payment_test_test.rb +0 -7
- data/test/test_helper.rb +0 -21
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
InstalledFiles
|
7
|
+
lib/bundler/man
|
8
|
+
pkg
|
9
|
+
rdoc
|
10
|
+
spec/reports
|
11
|
+
test/tmp
|
12
|
+
test/version_tmp
|
13
|
+
tmp
|
14
|
+
build
|
15
|
+
# YARD artifacts
|
16
|
+
.yardoc
|
17
|
+
_yardoc
|
18
|
+
doc/
|
19
|
+
|
20
|
+
.jbundler
|
21
|
+
Jarfile.lock
|
22
|
+
Gemfile.lock
|
23
|
+
*.swp
|
data/Gemfile
ADDED
data/Jarfile
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,37 +1,17 @@
|
|
1
|
-
|
2
|
-
require 'bundler/setup'
|
3
|
-
rescue LoadError
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'PaymentTest'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
-
load 'rails/tasks/engine.rake'
|
19
|
-
|
20
|
-
|
21
|
-
load 'rails/tasks/statistics.rake'
|
22
|
-
|
23
|
-
|
1
|
+
#!/usr/bin/env rake
|
24
2
|
|
3
|
+
# Install tasks to build and release the plugin
|
4
|
+
require 'bundler/setup'
|
25
5
|
Bundler::GemHelper.install_tasks
|
26
6
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
t.libs << 'test'
|
32
|
-
t.pattern = 'test/**/*_test.rb'
|
33
|
-
t.verbose = false
|
34
|
-
end
|
7
|
+
# Install test tasks
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
desc "Run RSpec"
|
10
|
+
RSpec::Core::RakeTask.new
|
35
11
|
|
12
|
+
# Install tasks to package the plugin for Killbill
|
13
|
+
require 'killbill/rake_task'
|
14
|
+
Killbill::PluginHelper.install_tasks
|
36
15
|
|
37
|
-
|
16
|
+
# Run tests by default
|
17
|
+
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,32 @@
|
|
1
|
+
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'killbill-payment-test'
|
5
|
+
s.version = version
|
6
|
+
s.summary = 'Plugin to test payment plugin api'
|
7
|
+
s.description = 'Killbill Plugin to test payment plugin api'
|
8
|
+
|
9
|
+
s.required_ruby_version = '>= 1.9.3'
|
10
|
+
|
11
|
+
s.license = 'Apache License (2.0)'
|
12
|
+
|
13
|
+
s.author = 'Killbill core team'
|
14
|
+
s.email = 'killbilling-users@googlegroups.com'
|
15
|
+
s.homepage = 'http://www.killbilling.org'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.bindir = 'bin'
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.rdoc_options << '--exclude' << '.'
|
24
|
+
|
25
|
+
s.add_dependency 'killbill', '~> 1.0.1'
|
26
|
+
s.add_dependency 'activemerchant', '~> 1.29.3'
|
27
|
+
s.add_dependency 'sinatra', '~> 1.3.4'
|
28
|
+
|
29
|
+
s.add_development_dependency 'jbundler', '~> 0.4.1'
|
30
|
+
s.add_development_dependency 'rake', '>= 10.0.0'
|
31
|
+
s.add_development_dependency 'rspec', '~> 2.12.0'
|
32
|
+
end
|
data/killbill.properties
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
require 'killbill/payment'
|
4
|
+
|
5
|
+
module PaymentTest
|
6
|
+
class PaymentPlugin < Killbill::Plugin::Payment
|
7
|
+
|
8
|
+
def start_plugin
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
@raise_exception = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_name
|
17
|
+
end
|
18
|
+
|
19
|
+
def charge(kb_payment_id, kb_payment_method_id, amount_in_cents, options = {})
|
20
|
+
if @raise_exception
|
21
|
+
raise StandardError.new("Test exception")
|
22
|
+
else
|
23
|
+
Killbill::Plugin::PaymentResponse.new(amount_in_cents, DateTime.now, DateTime.now, Killbill::Plugin::PaymentStatus::SUCCESS, "gateway_error", "gateway_error_code")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_payment_info(kb_payment_id, options = {})
|
28
|
+
if @raise_exception
|
29
|
+
raise StandardError.new("Test exception")
|
30
|
+
else
|
31
|
+
Killbill::Plugin::PaymentResponse.new(0, DateTime.now, DateTime.now, Killbill::Plugin::PaymentStatus::SUCCESS, "gateway_error", "gateway_error_code")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def refund(kb_payment_id, amount_in_cents, options = {})
|
36
|
+
if @raise_exception
|
37
|
+
raise StandardError.new("Test exception")
|
38
|
+
else
|
39
|
+
Killbill::Plugin::RefundResponse.new(amount_in_cents, DateTime.now, DateTime.now, Killbill::Plugin::PaymentStatus::SUCCESS, "gateway_error", "gateway_error_code")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_payment_method(kb_account_id, kb_payment_method_id, payment_method_props, set_default, options = {})
|
44
|
+
if @raise_exception
|
45
|
+
raise StandardError.new("Test exception")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete_payment_method(kb_payment_method_id, options = {})
|
50
|
+
if @raise_exception
|
51
|
+
raise StandardError.new("Test exception")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_payment_method_detail(kb_account_id, kb_payment_method_id, options = {})
|
56
|
+
if @raise_exception
|
57
|
+
raise StandardError.new("Test exception")
|
58
|
+
else
|
59
|
+
Killbill::Plugin::PaymentMethodResponse.new("foo", true, [])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def set_default_payment_method(kb_payment_method_id, options = {})
|
64
|
+
if @raise_exception
|
65
|
+
raise StandardError.new("Test exception")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_payment_methods(kb_account_id, options = {})
|
70
|
+
if @raise_exception
|
71
|
+
raise StandardError.new("Test exception")
|
72
|
+
else
|
73
|
+
[Killbill::Plugin::PaymentMethodResponseInternal.new(kb_account_id, kb_account_id, true, "external_payment_method_id")]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def reset_payment_methods(payment_methods)
|
78
|
+
if @raise_exception
|
79
|
+
raise StandardError.new("Test exception")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def raise_exception_on_next_calls
|
84
|
+
@raise_exception = true
|
85
|
+
end
|
86
|
+
|
87
|
+
def clear_exception_on_next_calls
|
88
|
+
@raise_exception = false
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
data/lib/payment_test.rb
CHANGED
@@ -1,23 +1 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
module PaymentTest
|
4
|
-
|
5
|
-
mattr_accessor :current_tenant_user
|
6
|
-
mattr_accessor :layout
|
7
|
-
|
8
|
-
self.current_tenant_user = lambda { |session, user|
|
9
|
-
{
|
10
|
-
:username => 'admin',
|
11
|
-
:password => 'password',
|
12
|
-
:session_id => nil,
|
13
|
-
:api_key => KillBillClient.api_key,
|
14
|
-
:api_secret => KillBillClient.api_secret
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
def self.config(&block)
|
19
|
-
{
|
20
|
-
:layout => layout || 'payment_test/layouts/payment_test_application',
|
21
|
-
}
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require 'payment_test/api'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'logger'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
require 'payment_test'
|
6
|
+
|
7
|
+
describe PaymentTest::PaymentPlugin do
|
8
|
+
before(:each) do
|
9
|
+
@plugin = PaymentTest::PaymentPlugin.new
|
10
|
+
@plugin.logger = Logger.new(STDOUT)
|
11
|
+
@kb_payment_id = "9f73c8e9-188a-4603-a3ba-2ce684411fb9"
|
12
|
+
@kb_payment_method_id = "b1396a76-b210-4690-a61e-e94c911a2a09"
|
13
|
+
@amount_in_cents = 100
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should start and stop correctly" do
|
17
|
+
@plugin.start_plugin
|
18
|
+
@plugin.stop_plugin
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should should test charge " do
|
22
|
+
|
23
|
+
output = @plugin.charge(@kb_payment_id, @kb_payment_method_id, @amount_in_cents)
|
24
|
+
|
25
|
+
output.should be_an_instance_of Killbill::Plugin::PaymentResponse
|
26
|
+
output.amount_in_cents.should == @amount_in_cents
|
27
|
+
output.status.should == Killbill::Plugin::PaymentStatus::SUCCESS
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED