killbill 3.2.1 → 3.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3336dc6cd112f6b516306599a87b91a0e40ad173
4
- data.tar.gz: 03519858360b4d15c0e31150839e9bf552404428
3
+ metadata.gz: 78a98058965b5bbd7559afd32426452aa08fcd0c
4
+ data.tar.gz: 33b92e5f2629345f60769ed4b4c076982a474daf
5
5
  SHA512:
6
- metadata.gz: 478800fd4c8c6cdd40e4df01c8f3ed93c5de4280a2a7103d03872f9d7d362152b5847ee2189f7ddb7447102f6fe0d00f535793b7bcb9df33bf1e4a368bfa0981
7
- data.tar.gz: 8d36533b6e1bcdf452fd9571e8fd6250b3025df5d872939a65b17213ec9df94d8ca1e9d657c1d8cade011de1b1aa14b16614d9f56234ae3cddf9b4579d332241
6
+ metadata.gz: 7e49b1e770ff125e918d2d58aa1a4a204e87c3a13b71c2b738a8e8ea902a160d069e6b4b777a9ddfc55d92ecb7d04c141145dabd1c48776f3ee4daac229a1f63
7
+ data.tar.gz: 9274aa2930d128170b6939c9e73e72bb075ddf26d79e49056aa18adbb8bfc01e2a0924a1323c885545248844e3721860b4463f1908c6814cb0b3607ea4ea8132
data/Jarfile CHANGED
@@ -5,4 +5,5 @@ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-currency', '0.8.2'
5
5
  jar 'org.kill-bill.billing.plugin:killbill-plugin-api-retry', '0.8.1'
6
6
  jar 'org.kill-bill.billing.plugin:killbill-plugin-api-invoice', '0.8.2'
7
7
  jar 'org.kill-bill.billing:killbill-util:tests', '0.12.0'
8
+ jar 'org.mockito:mockito-all', '1.9.0'
8
9
  jar 'javax.servlet:javax.servlet-api', '3.0.1'
data/NEWS CHANGED
@@ -1,3 +1,7 @@
1
+ 3.2.2
2
+ Logger performance improvement
3
+ Initial support for invoice plugins
4
+
1
5
  3.2.1
2
6
  Regenerate models
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.2.2
@@ -1,6 +1,7 @@
1
1
  -i
2
2
  file:///PATH_TO_REPO/killbill-plugin-api/payment/src/main/java,
3
3
  file:///PATH_TO_REPO/killbill-plugin-api/notification/src/main/java,
4
+ file:///PATH_TO_REPO/killbill-plugin-api/invoice/src/main/java,
4
5
  file:///PATH_TO_REPO/killbill-plugin-api/currency/src/main/java,
5
6
  file:///PATH_TO_REPO/killbill-api/src/main/java/
6
7
  -o
@@ -10,6 +11,7 @@ JRUBY_PLUGIN
10
11
  -q
11
12
  org.killbill.billing.payment.plugin.api,
12
13
  org.killbill.billing.notification.plugin.api,
14
+ org.killbill.billing.invoice.plugin.api
13
15
  org.killbill.billing.currency.plugin.api
14
16
  -m
15
17
  JRUBY_PLUGIN_API
data/lib/killbill.rb CHANGED
@@ -63,4 +63,5 @@ require 'killbill/gen/api/require_gen'
63
63
  require 'killbill/gen/plugin-api/require_gen'
64
64
  require 'killbill/notification'
65
65
  require 'killbill/payment'
66
+ require 'killbill/invoice'
66
67
  require 'killbill/currency'
@@ -0,0 +1,84 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module Killbill
29
+ module Plugin
30
+ module Api
31
+
32
+ java_package 'org.killbill.billing.invoice.plugin.api'
33
+ class InvoicePluginApi < JPlugin
34
+
35
+ include org.killbill.billing.invoice.plugin.api.InvoicePluginApi
36
+
37
+ def initialize(real_class_name, services = {})
38
+ super(real_class_name, services)
39
+ end
40
+
41
+
42
+ java_signature 'Java::java.util.List getAdditionalInvoiceItems(Java::org.killbill.billing.invoice.api.Invoice, Java::java.lang.Iterable, Java::org.killbill.billing.util.callcontext.CallContext)'
43
+ def get_additional_invoice_items(invoice, properties, context)
44
+
45
+ # conversion for invoice [type = org.killbill.billing.invoice.api.Invoice]
46
+ invoice = Killbill::Plugin::Model::Invoice.new.to_ruby(invoice) unless invoice.nil?
47
+
48
+ # conversion for properties [type = java.lang.Iterable]
49
+ tmp = []
50
+ (properties.nil? ? [] : properties.iterator).each do |m|
51
+ # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
52
+ m = Killbill::Plugin::Model::PluginProperty.new.to_ruby(m) unless m.nil?
53
+ tmp << m
54
+ end
55
+ properties = tmp
56
+
57
+ # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
58
+ context = Killbill::Plugin::Model::CallContext.new.to_ruby(context) unless context.nil?
59
+ begin
60
+ res = @delegate_plugin.get_additional_invoice_items(invoice, properties, context)
61
+ # conversion for res [type = java.util.List]
62
+ tmp = java.util.ArrayList.new
63
+ (res || []).each do |m|
64
+ # conversion for m [type = org.killbill.billing.invoice.api.InvoiceItem]
65
+ m = m.to_java unless m.nil?
66
+ tmp.add(m)
67
+ end
68
+ res = tmp
69
+ return res
70
+ rescue Exception => e
71
+ message = "Failure in get_additional_invoice_items: #{e}"
72
+ unless e.backtrace.nil?
73
+ message = "#{message}\n#{e.backtrace.join("\n")}"
74
+ end
75
+ logger.warn message
76
+ raise Java::org.killbill.billing.payment.plugin.api.PaymentPluginApiException.new("get_additional_invoice_items failure", e.message)
77
+ ensure
78
+ @delegate_plugin.after_request
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -30,6 +30,7 @@ require 'killbill/gen/plugin-api/payment_plugin_api'
30
30
  require 'killbill/gen/plugin-api/payment_plugin_api_exception'
31
31
  require 'killbill/gen/plugin-api/ext_bus_event'
32
32
  require 'killbill/gen/plugin-api/notification_plugin_api'
33
+ require 'killbill/gen/plugin-api/invoice_plugin_api'
33
34
  require 'killbill/gen/plugin-api/currency_plugin_api'
34
35
  require 'killbill/gen/plugin-api/gateway_notification'
35
36
  require 'killbill/gen/plugin-api/hosted_payment_page_form_descriptor'
@@ -42,7 +42,7 @@ module Killbill
42
42
  pool.remove(connection)
43
43
  connection.disconnect!
44
44
 
45
- @logger.debug "after_request: pool.active_connection? = #{pool.active_connection?}, connection.active? = #{connection.active?}, pool.connections.size = #{pool.connections.size}, connections = #{pool.connections.inspect}"
45
+ @logger.debug { "after_request: pool.active_connection? = #{pool.active_connection?}, connection.active? = #{connection.active?}, pool.connections.size = #{pool.connections.size}, connections = #{pool.connections.inspect}" }
46
46
  end
47
47
 
48
48
  def authorize_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
@@ -518,7 +518,7 @@ module Killbill
518
518
 
519
519
  response, transaction = @response_model.create_response_and_transaction(@identifier, @transaction_model, api_call, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, gw_response, amount_in_cents, currency, {}, @response_model)
520
520
 
521
- @logger.debug "Recorded transaction: #{transaction.inspect}" unless transaction.nil?
521
+ @logger.debug { "Recorded transaction: #{transaction.inspect}" } unless transaction.nil?
522
522
 
523
523
  return response, transaction
524
524
  end
@@ -76,7 +76,7 @@ module Killbill
76
76
 
77
77
  response, transaction = @response_model.create_response_and_transaction(@identifier, @transaction_model, api_call, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, gw_response, amount_in_cents, currency, {}, @response_model)
78
78
 
79
- logger.debug "Recorded transaction: #{transaction.inspect}" unless transaction.nil?
79
+ logger.debug { "Recorded transaction: #{transaction.inspect}" } unless transaction.nil?
80
80
 
81
81
  return response, transaction
82
82
  end
@@ -0,0 +1,41 @@
1
+ require 'killbill/plugin'
2
+ require 'securerandom'
3
+
4
+ module Killbill
5
+ module Plugin
6
+ class Invoice < PluginBase
7
+
8
+ def get_additional_invoice_items(invoice, properties, context)
9
+ []
10
+ end
11
+
12
+ # Helper method to build a new item from an existing one
13
+ def build_item(item_model, amount, description = nil, type = :EXTERNAL_CHARGE)
14
+ item = Model::InvoiceItem.new
15
+
16
+ item.created_date = item_model.created_date
17
+ item.updated_date = item_model.updated_date
18
+ item.invoice_id = item_model.invoice_id
19
+ item.account_id = item_model.account_id
20
+ item.currency = item_model.currency
21
+ item.bundle_id = item_model.bundle_id
22
+ item.subscription_id = item_model.subscription_id
23
+ item.start_date = item_model.start_date
24
+ item.end_date = item_model.end_date
25
+ item.plan_name = item_model.plan_name
26
+ item.phase_name = item_model.phase_name
27
+ item.usage_name = item_model.usage_name
28
+
29
+ item.linked_item_id = item_model.id
30
+
31
+ item.id = SecureRandom.uuid
32
+ item.invoice_item_type = type
33
+ item.amount = amount
34
+ item.description = description
35
+ item.rate = nil
36
+
37
+ item
38
+ end
39
+ end
40
+ end
41
+ end
@@ -15,19 +15,19 @@ module Killbill
15
15
  end
16
16
 
17
17
  def debug(message=nil, &block)
18
- @logger.log(4, build_message(message, &block))
18
+ @logger.log(4, build_message(message, &block)) if debug?
19
19
  end
20
20
 
21
21
  def info(message=nil, &block)
22
- @logger.log(3, build_message(message, &block))
22
+ @logger.log(3, build_message(message, &block)) if info?
23
23
  end
24
24
 
25
25
  def warn(message=nil, &block)
26
- @logger.log(2, build_message(message, &block))
26
+ @logger.log(2, build_message(message, &block)) if warn?
27
27
  end
28
28
 
29
29
  def error(message=nil, &block)
30
- @logger.log(1, build_message(message, &block))
30
+ @logger.log(1, build_message(message, &block)) if error?
31
31
  end
32
32
 
33
33
  # Rack Error stream
@@ -59,7 +59,7 @@ module Killbill
59
59
  end
60
60
  end
61
61
 
62
- def build_message(message=nil, &block)
62
+ def build_message(message = nil)
63
63
  if message.nil?
64
64
  if block_given?
65
65
  message = yield
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Killbill::Plugin::Api::InvoicePluginApi do
4
+
5
+ before(:all) do
6
+ logger = ::Logger.new(STDOUT)
7
+ @invoicePluginApi = Killbill::Plugin::Api::InvoicePluginApi.new('Killbill::Plugin::InvoiceTest', {'logger' => logger})
8
+ end
9
+
10
+ it 'should add items' do
11
+ invoice = create_invoice
12
+
13
+ items = @invoicePluginApi.get_additional_invoice_items(invoice, java.util.ArrayList.new, nil)
14
+ items.size.should == 2
15
+
16
+ items.get(0).invoice_id.should == invoice.id
17
+ items.get(0).amount.compareTo(java.math.BigDecimal.new('7')).should == 0
18
+ items.get(0).invoice_item_type.should == org.killbill.billing.invoice.api.InvoiceItemType::TAX
19
+
20
+ items.get(1).invoice_id.should == invoice.id
21
+ items.get(1).amount.compareTo(java.math.BigDecimal.new('200')).should == 0
22
+ items.get(1).invoice_item_type.should == org.killbill.billing.invoice.api.InvoiceItemType::EXTERNAL_CHARGE
23
+ end
24
+
25
+ private
26
+
27
+ def create_invoice
28
+ invoice_id = java.util.UUID.random_uuid
29
+
30
+ invoice = org.mockito.Mockito.mock(org.killbill.billing.invoice.api.Invoice.java_class)
31
+ org.mockito.Mockito.when(invoice.getId).thenReturn(invoice_id)
32
+
33
+ item = org.mockito.Mockito.mock(org.killbill.billing.invoice.api.InvoiceItem.java_class)
34
+ org.mockito.Mockito.when(item.getInvoiceId).thenReturn(invoice_id)
35
+ org.mockito.Mockito.when(item.getAmount).thenReturn(java.math.BigDecimal.new('100'))
36
+
37
+ items = java.util.ArrayList.new
38
+ items.add(item)
39
+ org.mockito.Mockito.when(invoice.getInvoiceItems).thenReturn(items)
40
+
41
+ invoice
42
+ end
43
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ class DummyInvoicePlugin < Killbill::Plugin::Invoice
4
+ end
5
+
6
+ describe Killbill::Plugin::Invoice do
7
+
8
+ it 'should not raise exceptions by default' do
9
+ plugin = DummyInvoicePlugin.new
10
+ plugin.get_additional_invoice_items(nil, nil, nil).size.should == 0
11
+ end
12
+
13
+ it 'should be able to build items' do
14
+ model = Killbill::Plugin::Model::InvoiceItem.new
15
+ model.created_date = SecureRandom.uuid
16
+ model.updated_date = SecureRandom.uuid
17
+ model.invoice_id = SecureRandom.uuid
18
+ model.account_id = SecureRandom.uuid
19
+ model.currency = SecureRandom.uuid
20
+ model.bundle_id = SecureRandom.uuid
21
+ model.subscription_id = SecureRandom.uuid
22
+ model.start_date = SecureRandom.uuid
23
+ model.end_date = SecureRandom.uuid
24
+ model.plan_name = SecureRandom.uuid
25
+ model.phase_name = SecureRandom.uuid
26
+ model.usage_name = SecureRandom.uuid
27
+ model.linked_item_id = SecureRandom.uuid
28
+ model.id = SecureRandom.uuid
29
+ model.invoice_item_type = SecureRandom.uuid
30
+ model.amount = SecureRandom.uuid
31
+ model.description = SecureRandom.uuid
32
+ model.rate = SecureRandom.uuid
33
+
34
+ amount = 123
35
+ description = 'Toto'
36
+ type = :TAX
37
+
38
+ plugin = DummyInvoicePlugin.new
39
+ item = plugin.build_item(model, amount, description, type)
40
+
41
+ item.created_date.should == model.created_date
42
+ item.updated_date.should == model.updated_date
43
+ item.invoice_id.should == model.invoice_id
44
+ item.account_id.should == model.account_id
45
+ item.currency.should == model.currency
46
+ item.bundle_id.should == model.bundle_id
47
+ item.subscription_id.should == model.subscription_id
48
+ item.start_date.should == model.start_date
49
+ item.end_date.should == model.end_date
50
+ item.plan_name.should == model.plan_name
51
+ item.phase_name.should == model.phase_name
52
+ item.usage_name.should == model.usage_name
53
+ item.linked_item_id.should == model.id
54
+
55
+ item.id.should_not == model.id
56
+ item.amount.should == amount
57
+ item.description.should == description
58
+ item.invoice_item_type.should == type
59
+ item.rate.should be_nil
60
+ end
61
+ end
@@ -0,0 +1,20 @@
1
+ require 'killbill/invoice'
2
+
3
+ # See invoice_plugin_api_spec.rb
4
+ module Killbill
5
+ module Plugin
6
+ class InvoiceTest < Invoice
7
+
8
+ def get_additional_invoice_items(invoice, properties, context)
9
+ additional_items = []
10
+ invoice.invoice_items.each do |original_item|
11
+ additional_items << build_item(original_item, original_item.amount * 7 / 100, 'Tax item', :TAX)
12
+ additional_items << build_item(original_item, original_item.amount * 2, 'Charge item', :EXTERNAL_CHARGE)
13
+ end
14
+
15
+ additional_items
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -10,4 +10,15 @@ describe Killbill::Plugin::KillbillLogger do
10
10
  logger.add(Logger::FATAL) { 'Fatal error!' }
11
11
  logger.close
12
12
  end
13
+
14
+ it 'only executes block when at given level' do
15
+ logger = Killbill::Plugin::KillbillLogger.new(::Logger.new(STDOUT))
16
+ logger.log_level = ::Logger::INFO
17
+ logger.info { 'logging at INFO level' }
18
+ logger.debug { raise 'logging at DEBUG level' } # should not raise
19
+ logger.add(Logger::WARN) { 'logging at WARN level' }
20
+ logger.add(Logger::DEBUG) { raise 'logging at DEBUG level' } # should not raise
21
+ logger.close
22
+ end
23
+
13
24
  end
@@ -1,5 +1,6 @@
1
1
  require 'killbill/notification'
2
2
 
3
+ # See notification_plugin_api_spec.rb
3
4
  module Killbill
4
5
  module Plugin
5
6
  class NotificationTest < Notification
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,7 @@ require 'killbill/http_servlet'
11
11
 
12
12
  require 'killbill/payment_test'
13
13
  require 'killbill/notification_test'
14
+ require 'killbill/invoice_test'
14
15
  require 'killbill/helpers/active_merchant'
15
16
  require 'killbill/helpers/active_merchant/active_record/models/helpers'
16
17
  require 'killbill/helpers/active_merchant/killbill_spec_helper'
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.1
4
+ version: 3.2.2
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-08 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -414,6 +414,7 @@ files:
414
414
  - lib/killbill/gen/plugin-api/ext_bus_event.rb
415
415
  - lib/killbill/gen/plugin-api/gateway_notification.rb
416
416
  - lib/killbill/gen/plugin-api/hosted_payment_page_form_descriptor.rb
417
+ - lib/killbill/gen/plugin-api/invoice_plugin_api.rb
417
418
  - lib/killbill/gen/plugin-api/notification_plugin_api.rb
418
419
  - lib/killbill/gen/plugin-api/payment_method_info_plugin.rb
419
420
  - lib/killbill/gen/plugin-api/payment_plugin_api.rb
@@ -437,6 +438,7 @@ files:
437
438
  - lib/killbill/helpers/active_merchant/sinatra.rb
438
439
  - lib/killbill/helpers/active_merchant/utils.rb
439
440
  - lib/killbill/http_servlet.rb
441
+ - lib/killbill/invoice.rb
440
442
  - lib/killbill/jnotification.rb
441
443
  - lib/killbill/jplugin.rb
442
444
  - lib/killbill/killbill_api.rb
@@ -461,6 +463,9 @@ files:
461
463
  - spec/killbill/helpers/test_schema.rb
462
464
  - spec/killbill/helpers/transaction_spec.rb
463
465
  - spec/killbill/helpers/utils_spec.rb
466
+ - spec/killbill/invoice_plugin_api_spec.rb
467
+ - spec/killbill/invoice_plugin_spec.rb
468
+ - spec/killbill/invoice_test.rb
464
469
  - spec/killbill/killbill_integration_spec.rb
465
470
  - spec/killbill/killbill_logger_spec.rb
466
471
  - spec/killbill/killbillapi_spec.rb
@@ -517,6 +522,9 @@ test_files:
517
522
  - spec/killbill/helpers/test_schema.rb
518
523
  - spec/killbill/helpers/transaction_spec.rb
519
524
  - spec/killbill/helpers/utils_spec.rb
525
+ - spec/killbill/invoice_plugin_api_spec.rb
526
+ - spec/killbill/invoice_plugin_spec.rb
527
+ - spec/killbill/invoice_test.rb
520
528
  - spec/killbill/killbill_integration_spec.rb
521
529
  - spec/killbill/killbill_logger_spec.rb
522
530
  - spec/killbill/killbillapi_spec.rb