killbill 3.2.2 → 3.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/Jarfile +7 -7
  4. data/README.md +16 -4
  5. data/VERSION +1 -1
  6. data/gen_config/api.conf +48 -47
  7. data/gen_config/plugin_api.conf +17 -16
  8. data/generators/active_merchant/templates/.gitignore.rb +2 -2
  9. data/generators/active_merchant/templates/lib/api.rb +8 -0
  10. data/generators/active_merchant/templates/plugin.gemspec.rb +1 -0
  11. data/generators/active_merchant/templates/spec/base_plugin_spec.rb +1 -0
  12. data/generators/active_merchant/templates/spec/integration_spec.rb +5 -1
  13. data/killbill.gemspec +1 -0
  14. data/lib/killbill/creator.rb +9 -0
  15. data/lib/killbill/currency.rb +6 -0
  16. data/lib/killbill/gen/api/account_audit_logs_for_object_type.rb +9 -7
  17. data/lib/killbill/gen/api/catalog_user_api.rb +37 -4
  18. data/lib/killbill/gen/api/payment_api.rb +104 -0
  19. data/lib/killbill/gen/api/payment_gateway_api.rb +6 -3
  20. data/lib/killbill/gen/api/plan_phase.rb +1 -8
  21. data/lib/killbill/gen/api/price_list_set.rb +9 -7
  22. data/lib/killbill/gen/api/subscription.rb +20 -1
  23. data/lib/killbill/gen/api/tenant_user_api.rb +3 -3
  24. data/lib/killbill/gen/plugin-api/currency_plugin_with_events_api.rb +207 -0
  25. data/lib/killbill/gen/plugin-api/ext_bus_event.rb +7 -1
  26. data/lib/killbill/gen/plugin-api/invoice_plugin_with_events_api.rb +103 -0
  27. data/lib/killbill/gen/plugin-api/payment_plugin_with_events_api.rb +782 -0
  28. data/lib/killbill/gen/plugin-api/require_gen.rb +3 -0
  29. data/lib/killbill/helpers/active_merchant/configuration.rb +116 -46
  30. data/lib/killbill/helpers/active_merchant/killbill_spec_helper.rb +49 -32
  31. data/lib/killbill/helpers/active_merchant/payment_plugin.rb +18 -6
  32. data/lib/killbill/helpers/active_merchant/private_payment_plugin.rb +3 -3
  33. data/lib/killbill/helpers/active_merchant/utils.rb +37 -70
  34. data/lib/killbill/invoice.rb +6 -0
  35. data/lib/killbill/payment.rb +6 -0
  36. data/lib/killbill/plugin.rb +1 -1
  37. data/lib/killbill/rake_task.rb +1 -1
  38. data/spec/killbill/helpers/configuration_spec.rb +41 -5
  39. data/spec/killbill/helpers/payment_plugin_spec.rb +4 -1
  40. data/spec/killbill/helpers/private_payment_plugin_spec.rb +4 -2
  41. data/spec/killbill/helpers/utils_spec.rb +6 -6
  42. data/spec/killbill/invoice_plugin_api_spec.rb +1 -1
  43. data/spec/killbill/notification_plugin_api_spec.rb +1 -1
  44. data/spec/killbill/payment_plugin_api_spec.rb +1 -1
  45. metadata +19 -3
  46. data/lib/killbill/jnotification.rb +0 -31
@@ -9,6 +9,12 @@ module Killbill
9
9
  []
10
10
  end
11
11
 
12
+ # Override this method in your plugin to act upon received events
13
+ def on_event(event)
14
+ # No-op by default
15
+ end
16
+
17
+
12
18
  # Helper method to build a new item from an existing one
13
19
  def build_item(item_model, amount, description = nil, type = :EXTERNAL_CHARGE)
14
20
  item = Model::InvoiceItem.new
@@ -74,6 +74,12 @@ module Killbill
74
74
  def process_notification(notification, properties, context)
75
75
  raise OperationUnsupportedByGatewayError
76
76
  end
77
+
78
+ # Override this method in your plugin to act upon received events
79
+ def on_event(event)
80
+ # No-op by default
81
+ end
82
+
77
83
  end
78
84
  end
79
85
  end
@@ -22,6 +22,7 @@ module Killbill
22
22
 
23
23
  # Extra services
24
24
  attr_accessor :root,
25
+ :plugin_name,
25
26
  :logger,
26
27
  :conf_dir,
27
28
  :kb_apis
@@ -45,7 +46,6 @@ module Killbill
45
46
  # Will be called by each thread before returning to Killbill
46
47
  def after_request
47
48
  end
48
-
49
49
  end
50
50
  end
51
51
  end
@@ -220,7 +220,7 @@ module Killbill
220
220
  end
221
221
 
222
222
  def do_install_gem(path, name, version)
223
- gem_installer = Gem::Installer.new(path,
223
+ gem_installer = Gem::Installer.new(path.to_s,
224
224
  {
225
225
  :force => true,
226
226
  :install_dir => @target_dir,
@@ -5,6 +5,29 @@ describe Killbill::Plugin::ActiveMerchant do
5
5
  before(:all) do
6
6
  @logger = Logger.new(STDOUT)
7
7
  @logger.level = Logger::INFO
8
+
9
+ @call_context = Killbill::Plugin::Model::CallContext.new
10
+ @call_context.tenant_id = '00001011-a022-b033-0055-aa0000000066'
11
+ @call_context = @call_context.to_ruby(@call_context)
12
+
13
+ end
14
+
15
+
16
+ it 'should support multi-tenancy configurations' do
17
+ do_initialize!(<<-eos)
18
+ :login: admin
19
+ :password: password
20
+ :test: true
21
+ eos
22
+
23
+ do_common_checks
24
+
25
+ gw = ::Killbill::Plugin::ActiveMerchant.gateways(@call_context.tenant_id)
26
+ gw.size.should == 1
27
+ gw[:default][:login].should == 'admin2'
28
+ gw[:default][:password].should == 'password2'
29
+
30
+ ::Killbill::Plugin::ActiveMerchant.config_key_name.should == :KEY
8
31
  end
9
32
 
10
33
  it 'should support a configuration for a single gateway' do
@@ -105,11 +128,24 @@ describe Killbill::Plugin::ActiveMerchant do
105
128
  eos
106
129
  file.close
107
130
 
108
- ::Killbill::Plugin::ActiveMerchant.initialize! Proc.new { |config| config },
109
- :test,
110
- @logger,
111
- file.path,
112
- ::Killbill::Plugin::KillbillApi.new('test', {})
131
+ per_tenant_config =<<-oes
132
+ :test:
133
+ :login: admin2
134
+ :password: password2
135
+ :database:
136
+ :adapter: 'sqlite3'
137
+ :database: 'test.db'
138
+ oes
139
+
140
+ @tenant_api = ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaTenantUserApi.new({@call_context.tenant_id => per_tenant_config})
141
+ svcs = {:tenant_user_api => @tenant_api}
142
+
143
+ ::Killbill::Plugin::ActiveMerchant.initialize! Proc.new { |config| config },
144
+ :test,
145
+ @logger,
146
+ :KEY,
147
+ file.path,
148
+ ::Killbill::Plugin::KillbillApi.new('test', svcs)
113
149
  end
114
150
  end
115
151
  end
@@ -28,10 +28,13 @@ describe Killbill::Plugin::ActiveMerchant::PaymentPlugin do
28
28
  ::Killbill::Test::TestTransaction,
29
29
  ::Killbill::Test::TestResponse)
30
30
  @payment_api = ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaPaymentApi.new
31
- @plugin.kb_apis = ::Killbill::Plugin::KillbillApi.new('test', {:payment_api => @payment_api})
31
+ @tenant_api = ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaTenantUserApi.new({})
32
+
33
+ @plugin.kb_apis = ::Killbill::Plugin::KillbillApi.new('test', {:payment_api => @payment_api, :tenant_user_api => @tenant_api})
32
34
  @plugin.logger = Logger.new(STDOUT)
33
35
  @plugin.logger.level = Logger::INFO
34
36
  @plugin.conf_dir = File.dirname(file)
37
+ @plugin.root = File.dirname(file)
35
38
 
36
39
  # Start the plugin here - since the config file will be deleted
37
40
  @plugin.start_plugin
@@ -72,10 +72,12 @@ Pay!
72
72
  ::Killbill::Test::TestTransaction,
73
73
  ::Killbill::Test::TestResponse)
74
74
  payment_api = ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaPaymentApi.new
75
- plugin.kb_apis = ::Killbill::Plugin::KillbillApi.new('test', {:payment_api => payment_api})
75
+ tenant_api = ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaTenantUserApi.new({})
76
+
77
+ plugin.kb_apis = ::Killbill::Plugin::KillbillApi.new('test', {:payment_api => payment_api, :tenant_user_api => tenant_api})
76
78
  plugin.logger = Logger.new(STDOUT)
77
79
  plugin.conf_dir = File.dirname(file)
78
-
80
+ plugin.root = File.dirname(file)
79
81
  # Start the plugin here - since the config file will be deleted
80
82
  plugin.start_plugin
81
83
  end
@@ -41,11 +41,11 @@ describe Killbill::Plugin::ActiveMerchant::Utils do
41
41
 
42
42
  runs = 2
43
43
  cache_size = 50
44
- nb_threads = 200
44
+ nb_threads = (ENV['NB_THREADS'] || 200).to_i
45
45
  keys_per_thread = 1000
46
46
 
47
47
  cache = nil
48
- bm = Benchmark.bm do |x|
48
+ Benchmark.bm do |x|
49
49
  runs.times do |n|
50
50
  x.report("run ##{n}:") do
51
51
  cache = ::Killbill::Plugin::ActiveMerchant::Utils::BoundedLRUCache.new(Proc.new { |value| -1 }, cache_size)
@@ -66,14 +66,14 @@ describe Killbill::Plugin::ActiveMerchant::Utils do
66
66
  end
67
67
  end
68
68
 
69
- last_keys = cache.keys_to_a
70
- last_values = cache.values_to_a
69
+ last_keys = cache.keys
70
+ last_values = cache.values
71
71
  0.upto(cache_size - 1) do |i|
72
72
  # No overlap with test keys or values above
73
73
  cache[-1 * i - 1] = -2
74
74
 
75
- new_keys = cache.keys_to_a
76
- new_values = cache.values_to_a
75
+ new_keys = cache.keys
76
+ new_values = cache.values
77
77
 
78
78
  # Verify the changes we made
79
79
  0.upto(i) do |j|
@@ -4,7 +4,7 @@ describe Killbill::Plugin::Api::InvoicePluginApi do
4
4
 
5
5
  before(:all) do
6
6
  logger = ::Logger.new(STDOUT)
7
- @invoicePluginApi = Killbill::Plugin::Api::InvoicePluginApi.new('Killbill::Plugin::InvoiceTest', {'logger' => logger})
7
+ @invoicePluginApi = Killbill::Plugin::Api::InvoicePluginApi.new('Killbill::Plugin::InvoiceTest', {'logger' => logger, "root" => "/a/b/plugin_name/1.2.3"})
8
8
  end
9
9
 
10
10
  it 'should add items' do
@@ -5,7 +5,7 @@ describe Killbill::Plugin::Api::NotificationPluginApi do
5
5
 
6
6
  before(:all) do
7
7
  logger = ::Logger.new(STDOUT)
8
- @notificationPluginApi = Killbill::Plugin::Api::NotificationPluginApi.new("Killbill::Plugin::NotificationTest", { "logger" => logger })
8
+ @notificationPluginApi = Killbill::Plugin::Api::NotificationPluginApi.new("Killbill::Plugin::NotificationTest", { "logger" => logger, "root" => "/a/b/plugin_name/1.2.3" })
9
9
  end
10
10
 
11
11
 
@@ -6,7 +6,7 @@ describe Killbill::Plugin::Api::PaymentPluginApi do
6
6
  before(:all) do
7
7
  @call_context = Killbill::Plugin::Model::CallContext.new
8
8
  logger = ::Logger.new(STDOUT)
9
- @paymentPluginApi = Killbill::Plugin::Api::PaymentPluginApi.new("Killbill::Plugin::PaymentTest", {"logger" => logger})
9
+ @paymentPluginApi = Killbill::Plugin::Api::PaymentPluginApi.new("Killbill::Plugin::PaymentTest", {"logger" => logger, "root" => "/a/b/plugin_name/1.2.3"})
10
10
  @kb_account_id = java.util.UUID.fromString("aa5c926e-3d9d-4435-b44b-719d7b583256")
11
11
  @kb_payment_id = java.util.UUID.fromString("bf5c926e-3d9c-470e-b34b-719d7b58323a")
12
12
  @kb_payment_method_id = java.util.UUID.fromString("bf5c926e-3d9c-470e-b34b-719d7b58323a")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-13 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -52,6 +52,20 @@ dependencies:
52
52
  version: 1.1.0
53
53
  prerelease: false
54
54
  type: :runtime
55
+ - !ruby/object:Gem::Dependency
56
+ name: thread_safe
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.4
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 0.3.4
67
+ prerelease: false
68
+ type: :runtime
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: activerecord
57
71
  version_requirements: !ruby/object:Gem::Requirement
@@ -411,14 +425,17 @@ files:
411
425
  - lib/killbill/gen/api/usage_record.rb
412
426
  - lib/killbill/gen/api/usage_user_api.rb
413
427
  - lib/killbill/gen/plugin-api/currency_plugin_api.rb
428
+ - lib/killbill/gen/plugin-api/currency_plugin_with_events_api.rb
414
429
  - lib/killbill/gen/plugin-api/ext_bus_event.rb
415
430
  - lib/killbill/gen/plugin-api/gateway_notification.rb
416
431
  - lib/killbill/gen/plugin-api/hosted_payment_page_form_descriptor.rb
417
432
  - lib/killbill/gen/plugin-api/invoice_plugin_api.rb
433
+ - lib/killbill/gen/plugin-api/invoice_plugin_with_events_api.rb
418
434
  - lib/killbill/gen/plugin-api/notification_plugin_api.rb
419
435
  - lib/killbill/gen/plugin-api/payment_method_info_plugin.rb
420
436
  - lib/killbill/gen/plugin-api/payment_plugin_api.rb
421
437
  - lib/killbill/gen/plugin-api/payment_plugin_api_exception.rb
438
+ - lib/killbill/gen/plugin-api/payment_plugin_with_events_api.rb
422
439
  - lib/killbill/gen/plugin-api/payment_transaction_info_plugin.rb
423
440
  - lib/killbill/gen/plugin-api/require_gen.rb
424
441
  - lib/killbill/helpers/active_merchant.rb
@@ -439,7 +456,6 @@ files:
439
456
  - lib/killbill/helpers/active_merchant/utils.rb
440
457
  - lib/killbill/http_servlet.rb
441
458
  - lib/killbill/invoice.rb
442
- - lib/killbill/jnotification.rb
443
459
  - lib/killbill/jplugin.rb
444
460
  - lib/killbill/killbill_api.rb
445
461
  - lib/killbill/killbill_logger.rb
@@ -1,31 +0,0 @@
1
- require 'java'
2
-
3
- require 'singleton'
4
-
5
- require 'killbill/creator'
6
- require 'killbill/plugin'
7
-
8
- include Java
9
-
10
- module Killbill
11
- module Plugin
12
-
13
- java_package 'org.killbill.billing.notification.plugin.api'
14
- class JNotification < JPlugin
15
-
16
- include org.killbill.billing.notification.plugin.api.NotificationPluginApi
17
-
18
- def initialize(real_class_name, services = {})
19
- super(real_class_name, services)
20
- end
21
-
22
- java_signature 'void onEvent(Java::org.killbill.billing.notification.plugin.api.ExtBusEvent)'
23
- def on_event(*args)
24
- do_call_handle_exception(__method__, *args) do |res|
25
- return nil
26
- end
27
- end
28
-
29
- end
30
- end
31
- end