killbill 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/killbill.rb +35 -33
- data/lib/killbill/creator.rb +28 -0
- data/lib/killbill/jpayment.rb +2 -7
- data/lib/killbill/jplugin.rb +45 -0
- data/lib/killbill/plugin.rb +3 -13
- data/lib/killbill/response/payment_method_response.rb +7 -1
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/killbill.rb
CHANGED
@@ -1,45 +1,47 @@
|
|
1
1
|
begin
|
2
2
|
require 'java'
|
3
|
-
rescue LoadError => e
|
4
|
-
warn 'You need JRuby to run Killbill plugins'
|
5
|
-
raise e
|
6
|
-
end
|
7
3
|
|
8
|
-
KILLBILL_APIS = %w(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
)
|
4
|
+
KILLBILL_APIS = %w(
|
5
|
+
com.ning.billing.account.api.AccountUserApi
|
6
|
+
com.ning.billing.analytics.api.sanity.AnalyticsSanityApi
|
7
|
+
com.ning.billing.analytics.api.user.AnalyticsUserApi
|
8
|
+
com.ning.billing.catalog.api.CatalogUserApi
|
9
|
+
com.ning.billing.entitlement.api.migration.EntitlementMigrationApi
|
10
|
+
com.ning.billing.entitlement.api.timeline.EntitlementTimelineApi
|
11
|
+
com.ning.billing.entitlement.api.transfer.EntitlementTransferApi
|
12
|
+
com.ning.billing.entitlement.api.user.EntitlementUserApi
|
13
|
+
com.ning.billing.invoice.api.InvoiceMigrationApi
|
14
|
+
com.ning.billing.invoice.api.InvoicePaymentApi
|
15
|
+
com.ning.billing.invoice.api.InvoiceUserApi
|
16
|
+
com.ning.billing.overdue.OverdueUserApi
|
17
|
+
com.ning.billing.payment.api.PaymentApi
|
18
|
+
com.ning.billing.tenant.api.TenantUserApi
|
19
|
+
com.ning.billing.usage.api.UsageUserApi
|
20
|
+
com.ning.billing.util.api.AuditUserApi
|
21
|
+
com.ning.billing.util.api.CustomFieldUserApi
|
22
|
+
com.ning.billing.util.api.ExportUserApi
|
23
|
+
com.ning.billing.util.api.TagUserApi
|
24
|
+
)
|
29
25
|
|
30
|
-
begin
|
31
|
-
KILLBILL_APIS.each { |api| java_import api }
|
32
|
-
rescue NameError
|
33
|
-
# killbill-api should be provided by the JRuby OSGI bundle. We default to using JBundler for development purposes only
|
34
26
|
begin
|
35
|
-
require 'jbundler'
|
36
27
|
KILLBILL_APIS.each { |api| java_import api }
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
rescue NameError
|
29
|
+
# killbill-api should be provided by the JRuby OSGI bundle. We default to using JBundler for development purposes only
|
30
|
+
begin
|
31
|
+
require 'jbundler'
|
32
|
+
KILLBILL_APIS.each { |api| java_import api }
|
33
|
+
warn 'Using JBundler to load killbill-api (see .jbundler/classpath.rb). This should only happen in development mode!'
|
34
|
+
rescue LoadError => e
|
35
|
+
warn 'Unable to load killbill-api. For development purposes, use JBundler (create the following Jarfile: http://git.io/eobYXA and run: `bundle install && jbundle install\')'
|
36
|
+
end
|
40
37
|
end
|
38
|
+
|
39
|
+
rescue LoadError => e
|
40
|
+
warn 'You need JRuby to run Killbill plugins'
|
41
|
+
#raise e
|
41
42
|
end
|
42
43
|
|
44
|
+
|
43
45
|
require 'killbill/http_servlet'
|
44
46
|
require 'killbill/notification'
|
45
47
|
require 'killbill/payment'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module Killbill
|
3
|
+
module Plugin
|
4
|
+
class Creator
|
5
|
+
|
6
|
+
attr_reader :target_class_name
|
7
|
+
|
8
|
+
def initialize(target_class_name)
|
9
|
+
@target_class_name = target_class_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(*args)
|
13
|
+
real_class = class_from_string
|
14
|
+
args.nil? ? real_class.new : real_class.new(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def class_from_string()
|
20
|
+
@target_class_name.split('::').inject(Kernel) do |mod, class_name|
|
21
|
+
mod.const_get(class_name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/killbill/jpayment.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
|
3
|
+
require 'killbill/creator'
|
3
4
|
require 'killbill/plugin'
|
4
5
|
require 'killbill/jresponse/jpayment_response'
|
5
6
|
require 'killbill/jresponse/jrefund_response'
|
@@ -18,8 +19,7 @@ module Killbill
|
|
18
19
|
attr_reader :real_payment
|
19
20
|
|
20
21
|
def initialize(real_class_name, services = {})
|
21
|
-
|
22
|
-
@real_payment = real_payment_class.new(services)
|
22
|
+
@real_payment = Creator.new(real_class_name).create(services)
|
23
23
|
end
|
24
24
|
|
25
25
|
# TODO STEPH decide what to do the getName()
|
@@ -110,11 +110,6 @@ module Killbill
|
|
110
110
|
raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", e.message)
|
111
111
|
end
|
112
112
|
|
113
|
-
def class_from_string(str)
|
114
|
-
str.split('::').inject(Kernel) do |mod, class_name|
|
115
|
-
mod.const_get(class_name)
|
116
|
-
end
|
117
|
-
end
|
118
113
|
|
119
114
|
def convert_args(api, args)
|
120
115
|
args.collect! do |a|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'killbill/http_servlet'
|
2
|
+
require 'killbill/logger'
|
3
|
+
|
4
|
+
module Killbill
|
5
|
+
# There are various types of plugins one can write for Killbill:
|
6
|
+
#
|
7
|
+
# 1) notifications plugins, which listen to external bus events and can react to it
|
8
|
+
# 2) payment plugins, which are used to issue payments against a payment gateway
|
9
|
+
module Plugin
|
10
|
+
class JPlugin
|
11
|
+
|
12
|
+
attr_reader :delegate_plugin
|
13
|
+
|
14
|
+
# Called by the Killbill lifecycle when initializing the plugin
|
15
|
+
def start_plugin
|
16
|
+
@delegate_plugin.start_plugin
|
17
|
+
end
|
18
|
+
|
19
|
+
# Called by the Killbill lifecycle when stopping the plugin
|
20
|
+
def stop_plugin
|
21
|
+
@delegate_plugin.stop_plugin
|
22
|
+
end
|
23
|
+
|
24
|
+
# Called by the Killbill lifecycle when instantiating the plugin
|
25
|
+
def initialize(plugin_class_name, services = {})
|
26
|
+
@delegate_plugin = Creator.new(plugin_class_name).create(services)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Called by the Killbill lifecycle to register the servlet
|
30
|
+
def rack_handler
|
31
|
+
config_ru = Pathname.new("#{@delegate_plugin.root}/config.ru").expand_path
|
32
|
+
if config_ru.file?
|
33
|
+
@delegate_plugin.logger.info "Found Rack configuration file at #{config_ru.to_s}"
|
34
|
+
instance = Killbill::Plugin::RackHandler.instance
|
35
|
+
instance.configure(@logger, config_ru.to_s) unless instance.configured?
|
36
|
+
instance
|
37
|
+
else
|
38
|
+
@delegate_plugin.logger.info "No Rack configuration file found at #{config_ru.to_s}"
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/killbill/plugin.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'killbill/http_servlet'
|
2
1
|
require 'killbill/logger'
|
3
2
|
|
4
3
|
module Killbill
|
@@ -47,6 +46,7 @@ module Killbill
|
|
47
46
|
|
48
47
|
# Called by the Killbill lifecycle when instantiating the plugin
|
49
48
|
def initialize(services = {})
|
49
|
+
|
50
50
|
@active = false
|
51
51
|
|
52
52
|
services.each do |service_name, service_instance|
|
@@ -62,18 +62,8 @@ module Killbill
|
|
62
62
|
@logger = Killbill::Plugin::Logger.new(logger)
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
config_ru = Pathname.new("#{@root}/config.ru").expand_path
|
68
|
-
if config_ru.file?
|
69
|
-
@logger.info "Found Rack configuration file at #{config_ru.to_s}"
|
70
|
-
instance = Killbill::Plugin::RackHandler.instance
|
71
|
-
instance.configure(@logger, config_ru.to_s) unless instance.configured?
|
72
|
-
instance
|
73
|
-
else
|
74
|
-
@logger.info "No Rack configuration file found at #{config_ru.to_s}"
|
75
|
-
nil
|
76
|
-
end
|
65
|
+
def logger
|
66
|
+
@logger ||= Logger.new(STDOUT)
|
77
67
|
end
|
78
68
|
|
79
69
|
class APINotAvailableError < NotImplementedError
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: killbill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Killbill core team
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jbundler
|
@@ -106,8 +106,10 @@ files:
|
|
106
106
|
- VERSION
|
107
107
|
- killbill.gemspec
|
108
108
|
- lib/killbill.rb
|
109
|
+
- lib/killbill/creator.rb
|
109
110
|
- lib/killbill/http_servlet.rb
|
110
111
|
- lib/killbill/jpayment.rb
|
112
|
+
- lib/killbill/jplugin.rb
|
111
113
|
- lib/killbill/jresponse/jconverter.rb
|
112
114
|
- lib/killbill/jresponse/jpayment_method_response.rb
|
113
115
|
- lib/killbill/jresponse/jpayment_method_response_internal.rb
|