killbill 3.2.4 → 4.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/.travis.yml +26 -5
- data/Gemfile +1 -1
- data/Gemfile.head +5 -0
- data/Gemfile.lock +125 -0
- data/Jarfile +9 -9
- data/Jarfile.lock +54 -0
- data/NEWS +3 -0
- data/README.md +13 -0
- data/VERSION +1 -1
- data/generators/active_merchant/templates/.gitignore.rb +2 -3
- data/generators/active_merchant/templates/.travis.yml.rb +22 -3
- data/generators/active_merchant/templates/Gemfile.head.rb +5 -0
- data/generators/active_merchant/templates/Gemfile.rb +1 -1
- data/generators/active_merchant/templates/Jarfile.rb +9 -8
- data/generators/active_merchant/templates/LICENSE.rb +2 -2
- data/generators/active_merchant/templates/config.yml.rb +16 -6
- data/generators/active_merchant/templates/lib/plugin.rb +0 -1
- data/generators/active_merchant/templates/plugin.gemspec.rb +17 -15
- data/generators/active_merchant/templates/pom.xml.rb +1 -1
- data/generators/active_merchant/templates/release.sh.rb +34 -14
- data/generators/active_merchant/templates/spec/base_plugin_spec.rb +5 -7
- data/generators/active_merchant/templates/spec/integration_spec.rb +7 -18
- data/killbill.gemspec +21 -15
- data/lib/killbill/ext/active_merchant/typhoeus_connection.rb +3 -4
- data/lib/killbill/gen/api/account.rb +1 -1
- data/lib/killbill/gen/api/account_data.rb +1 -1
- data/lib/killbill/gen/api/audit_log.rb +2 -2
- data/lib/killbill/gen/api/audit_user_api.rb +3 -3
- data/lib/killbill/gen/api/block.rb +1 -1
- data/lib/killbill/gen/api/blocking_state.rb +1 -1
- data/lib/killbill/gen/api/call_context.rb +2 -2
- data/lib/killbill/gen/api/control_tag.rb +2 -2
- data/lib/killbill/gen/api/currency_conversion.rb +1 -1
- data/lib/killbill/gen/api/currency_conversion_api.rb +2 -2
- data/lib/killbill/gen/api/custom_field.rb +1 -1
- data/lib/killbill/gen/api/custom_field_user_api.rb +2 -2
- data/lib/killbill/gen/api/dry_run_arguments.rb +22 -3
- data/lib/killbill/gen/api/duration.rb +1 -1
- data/lib/killbill/gen/api/entitlement.rb +3 -3
- data/lib/killbill/gen/api/entitlement_ao_status_dry_run.rb +3 -3
- data/lib/killbill/gen/api/entitlement_api.rb +25 -7
- data/lib/killbill/gen/api/fixed.rb +1 -1
- data/lib/killbill/gen/api/invoice.rb +1 -1
- data/lib/killbill/gen/api/invoice_formatter.rb +2 -2
- data/lib/killbill/gen/api/invoice_item.rb +2 -2
- data/lib/killbill/gen/api/invoice_item_formatter.rb +2 -2
- data/lib/killbill/gen/api/invoice_payment.rb +3 -3
- data/lib/killbill/gen/api/invoice_user_api.rb +2 -2
- data/lib/killbill/gen/api/migration_plan.rb +1 -1
- data/lib/killbill/gen/api/mutable_account_data.rb +1 -1
- data/lib/killbill/gen/api/payment.rb +1 -1
- data/lib/killbill/gen/api/payment_api.rb +11 -11
- data/lib/killbill/gen/api/payment_transaction.rb +4 -4
- data/lib/killbill/gen/api/plan.rb +1 -1
- data/lib/killbill/gen/api/plan_change_result.rb +2 -2
- data/lib/killbill/gen/api/plan_phase.rb +1 -1
- data/lib/killbill/gen/api/plan_phase_price_override.rb +93 -0
- data/lib/killbill/gen/api/plan_phase_price_overrides_with_call_context.rb +77 -0
- data/lib/killbill/gen/api/plan_phase_specifier.rb +3 -3
- data/lib/killbill/gen/api/plan_specifier.rb +2 -2
- data/lib/killbill/gen/api/price.rb +1 -1
- data/lib/killbill/gen/api/product.rb +1 -1
- data/lib/killbill/gen/api/rate.rb +2 -2
- data/lib/killbill/gen/api/record_id_api.rb +1 -1
- data/lib/killbill/gen/api/recurring.rb +1 -1
- data/lib/killbill/gen/api/refund.rb +2 -2
- data/lib/killbill/gen/api/require_gen.rb +2 -0
- data/lib/killbill/gen/api/static_catalog.rb +2 -2
- data/lib/killbill/gen/api/subscription.rb +3 -3
- data/lib/killbill/gen/api/subscription_event.rb +3 -3
- data/lib/killbill/gen/api/tag.rb +1 -1
- data/lib/killbill/gen/api/tag_definition.rb +1 -1
- data/lib/killbill/gen/api/tag_user_api.rb +6 -6
- data/lib/killbill/gen/api/tiered_block.rb +1 -1
- data/lib/killbill/gen/api/usage.rb +3 -3
- data/lib/killbill/gen/plugin-api/currency_plugin_api.rb +1 -1
- data/lib/killbill/gen/plugin-api/ext_bus_event.rb +2 -2
- data/lib/killbill/gen/plugin-api/payment_transaction_info_plugin.rb +3 -3
- data/lib/killbill/helpers/active_merchant.rb +2 -2
- data/lib/killbill/helpers/active_merchant/active_record.rb +1 -1
- data/lib/killbill/helpers/active_merchant/active_record/active_record_helper.rb +14 -0
- data/lib/killbill/helpers/active_merchant/active_record/models/helpers.rb +8 -0
- data/lib/killbill/helpers/active_merchant/active_record/models/payment_method.rb +10 -8
- data/lib/killbill/helpers/active_merchant/active_record/models/response.rb +16 -3
- data/lib/killbill/helpers/active_merchant/active_record/models/streamy_result_set.rb +1 -3
- data/lib/killbill/helpers/active_merchant/active_record/models/transaction.rb +2 -0
- data/lib/killbill/helpers/active_merchant/configuration.rb +119 -27
- data/lib/killbill/helpers/active_merchant/gateway.rb +40 -27
- data/lib/killbill/helpers/active_merchant/killbill_spec_helper.rb +63 -45
- data/lib/killbill/helpers/active_merchant/payment_plugin.rb +121 -95
- data/lib/killbill/helpers/active_merchant/private_payment_plugin.rb +1 -1
- data/lib/killbill/helpers/active_merchant/properties.rb +9 -2
- data/lib/killbill/helpers/active_merchant/sinatra.rb +4 -8
- data/lib/killbill/helpers/active_merchant/utils.rb +44 -0
- data/lib/killbill/helpers/properties_helper.rb +41 -0
- data/lib/killbill/http_servlet.rb +11 -4
- data/lib/killbill/killbill_api.rb +6 -4
- data/lib/killbill/rake_task.rb +542 -102
- data/spec/killbill/helpers/configuration_spec.rb +117 -33
- data/spec/killbill/helpers/payment_method_spec.rb +20 -17
- data/spec/killbill/helpers/payment_plugin_spec.rb +401 -201
- data/spec/killbill/helpers/private_payment_plugin_spec.rb +3 -16
- data/spec/killbill/helpers/response_spec.rb +92 -22
- data/spec/killbill/helpers/streamy_result_set_spec.rb +3 -2
- data/spec/killbill/helpers/test_payment_method.rb +9 -0
- data/spec/killbill/helpers/test_response.rb +11 -0
- data/spec/killbill/helpers/test_schema.rb +6 -6
- data/spec/killbill/helpers/test_transaction.rb +11 -0
- data/spec/killbill/helpers/transaction_spec.rb +3 -13
- data/spec/killbill/helpers/utils_spec.rb +127 -69
- data/spec/spec_helper.rb +69 -18
- metadata +77 -71
- data/lib/killbill/ext/active_merchant/jdbc_connection.rb +0 -92
- data/lib/killbill/ext/active_merchant/proxy_support.rb +0 -58
- data/spec/killbill/helpers/gateway_spec.rb +0 -36
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
require 'active_record'
|
|
2
|
-
require 'active_record/connection_adapters/jdbc_adapter'
|
|
3
|
-
|
|
4
|
-
module ActiveRecord
|
|
5
|
-
module ConnectionAdapters
|
|
6
|
-
class JdbcConnection
|
|
7
|
-
|
|
8
|
-
# Sets the connection factory from the available configuration.
|
|
9
|
-
#
|
|
10
|
-
# This differs from the original implementation in the following ways:
|
|
11
|
-
# * We attempt to lookup the JNDI data source multiple times, to handle transient lookup issues
|
|
12
|
-
# * If the data source is unavailable, we don't fallback to straight JDBC (which is often not configured anyways)
|
|
13
|
-
# * In the failure scenario, inspect the exception instead of displaying e.message, which is often empty in our testing
|
|
14
|
-
def setup_connection_factory
|
|
15
|
-
if self.class.jndi_config?(config)
|
|
16
|
-
setup_done = false
|
|
17
|
-
jndi_retries = self.class.jndi_retries(config)
|
|
18
|
-
|
|
19
|
-
1.upto(jndi_retries) do |i|
|
|
20
|
-
begin
|
|
21
|
-
setup_jndi_factory
|
|
22
|
-
setup_done = true
|
|
23
|
-
break
|
|
24
|
-
rescue => e
|
|
25
|
-
warn "JNDI data source unavailable: #{e.inspect} (attempt ##{i})"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
raise "JNDI data source unavailable (tried #{jndi_retries} times)" unless setup_done
|
|
30
|
-
else
|
|
31
|
-
setup_jdbc_factory
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def self.jndi_retries(config)
|
|
36
|
-
(config[:jndi_retries] || 5).to_i
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
protected
|
|
40
|
-
|
|
41
|
-
def setup_jndi_factory
|
|
42
|
-
data_source = config[:data_source] || Java::JavaxNaming::InitialContext.new.lookup(config[:jndi].to_s)
|
|
43
|
-
|
|
44
|
-
@jndi = true
|
|
45
|
-
# Really slow under high load (see https://github.com/jruby/activerecord-jdbc-adapter/pull/588).
|
|
46
|
-
#self.connection_factory = JdbcConnectionFactory.impl { data_source.connection }
|
|
47
|
-
self.connection_factory = RubyJdbcConnectionFactory.new(data_source)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
class RubyJdbcConnectionFactory
|
|
51
|
-
include JdbcConnectionFactory
|
|
52
|
-
|
|
53
|
-
def initialize(data_source)
|
|
54
|
-
@data_source = data_source
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def new_connection
|
|
58
|
-
@data_source.connection
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
require 'active_record/persistence'
|
|
66
|
-
|
|
67
|
-
module ActiveRecord
|
|
68
|
-
module Persistence
|
|
69
|
-
|
|
70
|
-
# Creates a record with values matching those of the instance attributes
|
|
71
|
-
# and returns its id.
|
|
72
|
-
def _create_record(attribute_names = @attributes.keys)
|
|
73
|
-
attributes_values = arel_attributes_with_values_for_create(attribute_names)
|
|
74
|
-
|
|
75
|
-
new_id = self.class.unscoped.insert attributes_values
|
|
76
|
-
|
|
77
|
-
# Under heavy load and concurrency, write_attribute_with_type_cast sometimes fail to set the id.
|
|
78
|
-
# Even though self.class.primary_key returns 'id' and new_id is correctly populated from the database
|
|
79
|
-
# (see last_insert_id in activerecord-jdbc-adapter-1.3.9/lib/arjdbc/jdbc/adapter.rb), both self.id ||= new_id
|
|
80
|
-
# and self.id = new_id sometimes don't set the id. I couldn't quite figure it out.
|
|
81
|
-
# A workaround seems to be to retry the assignment (see also activerecord-4.1.5/lib/active_record/attribute_methods/primary_key.rb).
|
|
82
|
-
if self.class.primary_key
|
|
83
|
-
self.id ||= new_id
|
|
84
|
-
self.id ||= new_id if id.nil?
|
|
85
|
-
raise "Unable to set id (new_id=#{new_id}) for #{self.inspect}" if id.nil?
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
@new_record = false
|
|
89
|
-
id
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require 'active_utils/common/posts_data'
|
|
2
|
-
|
|
3
|
-
# Pass the proxy details to the connection object - see https://github.com/Shopify/active_utils/pull/44
|
|
4
|
-
module ActiveMerchant #:nodoc:
|
|
5
|
-
module PostsData #:nodoc:
|
|
6
|
-
|
|
7
|
-
def self.included(base)
|
|
8
|
-
base.superclass_delegating_accessor :ssl_strict
|
|
9
|
-
base.ssl_strict = true
|
|
10
|
-
|
|
11
|
-
base.superclass_delegating_accessor :ssl_version
|
|
12
|
-
base.ssl_version = nil
|
|
13
|
-
|
|
14
|
-
base.class_attribute :retry_safe
|
|
15
|
-
base.retry_safe = false
|
|
16
|
-
|
|
17
|
-
base.superclass_delegating_accessor :open_timeout
|
|
18
|
-
base.open_timeout = 60
|
|
19
|
-
|
|
20
|
-
base.superclass_delegating_accessor :read_timeout
|
|
21
|
-
base.read_timeout = 60
|
|
22
|
-
|
|
23
|
-
base.superclass_delegating_accessor :max_retries
|
|
24
|
-
base.max_retries = Connection::MAX_RETRIES
|
|
25
|
-
|
|
26
|
-
base.superclass_delegating_accessor :logger
|
|
27
|
-
base.superclass_delegating_accessor :wiredump_device
|
|
28
|
-
|
|
29
|
-
base.superclass_delegating_accessor :proxy_address
|
|
30
|
-
base.superclass_delegating_accessor :proxy_port
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def raw_ssl_request(method, endpoint, data, headers = {})
|
|
34
|
-
logger.warn "#{self.class} using ssl_strict=false, which is insecure" if logger unless ssl_strict
|
|
35
|
-
|
|
36
|
-
connection = new_connection(endpoint)
|
|
37
|
-
connection.open_timeout = open_timeout
|
|
38
|
-
connection.read_timeout = read_timeout
|
|
39
|
-
connection.retry_safe = retry_safe
|
|
40
|
-
connection.verify_peer = ssl_strict
|
|
41
|
-
connection.ssl_version = ssl_version
|
|
42
|
-
connection.logger = logger
|
|
43
|
-
connection.max_retries = max_retries
|
|
44
|
-
connection.tag = self.class.name
|
|
45
|
-
connection.wiredump_device = wiredump_device
|
|
46
|
-
|
|
47
|
-
connection.pem = @options[:pem] if @options
|
|
48
|
-
connection.pem_password = @options[:pem_password] if @options
|
|
49
|
-
|
|
50
|
-
connection.ignore_http_status = @options[:ignore_http_status] if @options
|
|
51
|
-
|
|
52
|
-
connection.proxy_address = proxy_address
|
|
53
|
-
connection.proxy_port = proxy_port
|
|
54
|
-
|
|
55
|
-
connection.request(method, data, headers)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Killbill::Plugin::ActiveMerchant::Gateway do
|
|
4
|
-
|
|
5
|
-
it 'should honor configuration options' do
|
|
6
|
-
gateway_builder = Proc.new {}
|
|
7
|
-
logger = Logger.new(STDOUT)
|
|
8
|
-
config = {}
|
|
9
|
-
|
|
10
|
-
verify_config
|
|
11
|
-
|
|
12
|
-
::Killbill::Plugin::ActiveMerchant::Gateway.wrap(gateway_builder, logger, config)
|
|
13
|
-
verify_config(config)
|
|
14
|
-
|
|
15
|
-
config1 = {:open_timeout => 12, :ssl_version => 5}
|
|
16
|
-
::Killbill::Plugin::ActiveMerchant::Gateway.wrap(gateway_builder, logger, config1)
|
|
17
|
-
verify_config(config1)
|
|
18
|
-
|
|
19
|
-
config2 = {:retry_safe => true, :ssl_strict => false, :max_retries => nil}
|
|
20
|
-
::Killbill::Plugin::ActiveMerchant::Gateway.wrap(gateway_builder, logger, config2)
|
|
21
|
-
verify_config(config1.merge(config2).delete_if { |k, v| v.nil? })
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def verify_config(config = {})
|
|
27
|
-
::ActiveMerchant::Billing::Gateway.open_timeout.should == (config.has_key?(:open_timeout) ? config[:open_timeout] : 60)
|
|
28
|
-
::ActiveMerchant::Billing::Gateway.read_timeout.should == (config.has_key?(:read_timeout) ? config[:read_timeout] : 60)
|
|
29
|
-
::ActiveMerchant::Billing::Gateway.retry_safe.should == (config.has_key?(:retry_safe) ? config[:retry_safe] : false)
|
|
30
|
-
::ActiveMerchant::Billing::Gateway.ssl_strict.should == (config.has_key?(:ssl_strict) ? config[:ssl_strict] : true)
|
|
31
|
-
::ActiveMerchant::Billing::Gateway.ssl_version.should == (config.has_key?(:ssl_version) ? config[:ssl_version] : nil)
|
|
32
|
-
::ActiveMerchant::Billing::Gateway.max_retries.should == (config.has_key?(:max_retries) ? config[:max_retries] : 3)
|
|
33
|
-
::ActiveMerchant::Billing::Gateway.proxy_address.should == (config.has_key?(:proxy_address) ? config[:proxy_address] : nil)
|
|
34
|
-
::ActiveMerchant::Billing::Gateway.proxy_port.should == (config.has_key?(:proxy_port) ? config[:proxy_port] : nil)
|
|
35
|
-
end
|
|
36
|
-
end
|