killbill 1.0.13 → 1.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/Jarfile CHANGED
@@ -1,3 +1,3 @@
1
- jar 'com.ning.billing:killbill-api', '0.1.61'
2
- jar 'com.ning.billing:killbill-util:tests', '0.1.61'
1
+ jar 'com.ning.billing:killbill-api', '0.1.76-SNAPSHOT'
2
+ jar 'com.ning.billing:killbill-util:tests', '0.1.76-SNAPSHOT'
3
3
  jar 'javax.servlet:javax.servlet-api', '3.0.1'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.13
1
+ 1.0.14
@@ -0,0 +1,35 @@
1
+ require 'java'
2
+
3
+ require 'singleton'
4
+
5
+ require 'killbill/creator'
6
+ require 'killbill/plugin'
7
+ require 'killbill/jresponse/jpayment_response'
8
+ require 'killbill/jresponse/jrefund_response'
9
+ require 'killbill/jresponse/jpayment_method_response'
10
+ require 'killbill/jresponse/jpayment_method_response_internal'
11
+
12
+ include Java
13
+
14
+ module Killbill
15
+ module Plugin
16
+
17
+ java_package 'com.ning.billing.notification.plugin.api'
18
+ class JNotification < JPlugin
19
+
20
+ include 'com.ning.billing.notification.plugin.api.NotificationPluginApi'
21
+
22
+ def initialize(real_class_name, services = {})
23
+ super(real_class_name, services)
24
+ end
25
+
26
+ java_signature 'void onEvent(Java::com.ning.billing.beatrix.bus.api.ExtBusEvent killbillEvent)'
27
+ def on_event(killbill_event)
28
+ do_call_handle_exception(__method__, *args) do |res|
29
+ return nil
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -111,71 +111,6 @@ module Killbill
111
111
  end
112
112
  end
113
113
 
114
- private
115
-
116
- def do_call_handle_exception(method_name, *args)
117
- begin
118
- rargs = convert_args(method_name, args)
119
- res = @delegate_plugin.send(method_name.to_s.snake_case.to_sym, *rargs)
120
- yield(res)
121
- rescue Exception => e
122
- wrap_and_throw_exception(method_name, e)
123
- ensure
124
- @delegate_plugin.after_request
125
- end
126
- end
127
-
128
- def wrap_and_throw_exception(api, e)
129
- message = "#{api} failure: #{e}"
130
- unless e.backtrace.nil?
131
- message = "#{message}\n#{e.backtrace.join("\n")}"
132
- end
133
- logger.warn message
134
- raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", e.message)
135
- end
136
-
137
-
138
- def convert_args(api, args)
139
- args.collect! do |a|
140
- if a.nil?
141
- nil
142
- elsif a.java_kind_of? java.util.UUID
143
- JConverter.from_uuid(a)
144
- elsif a.java_kind_of? java.math.BigDecimal
145
- JConverter.from_big_decimal(a)
146
- elsif a.java_kind_of? Java::com.ning.billing.catalog.api.Currency
147
- a.to_string
148
- elsif a.java_kind_of? Java::com.ning.billing.payment.api.PaymentMethodPlugin
149
- JConverter.from_payment_method_plugin(a)
150
- elsif ((a.java_kind_of? Java::boolean) || (a.java_kind_of? java.lang.Boolean))
151
- JConverter.from_boolean(a)
152
- # Require because it looks like if non boxed value are passed they already arrive as Ruby type
153
- elsif ((a.java_kind_of? TrueClass) || (a.java_kind_of? FalseClass))
154
- a
155
- elsif a.java_kind_of? java.util.List
156
- result = Array.new
157
- if a.size > 0
158
- first_element = a.get(0)
159
- if first_element.java_kind_of? Java::com.ning.billing.payment.plugin.api.PaymentMethodInfoPlugin
160
- a.each do |el|
161
- result << JConverter.from_payment_method_info_plugin(el)
162
- end
163
- else
164
- raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{first_element.class} for list")
165
- end
166
- end
167
- result
168
- else
169
- # Since we don't pass the Context at this point, we can't raise any exceptions for unexpected types.
170
- #raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{a.class}")
171
- nil
172
- end
173
- end
174
- # Remove last argument if this is null (it means we passed a context)
175
- args.delete_at(-1) if args[-1].nil?
176
- args
177
- end
178
-
179
114
  end
180
115
  end
181
116
  end
@@ -50,6 +50,73 @@ module Killbill
50
50
  require 'logger'
51
51
  @delegate_plugin.nil? ? ::Logger.new(STDOUT) : @delegate_plugin.logger
52
52
  end
53
+
54
+ protected
55
+
56
+ def do_call_handle_exception(method_name, *args)
57
+ begin
58
+ rargs = convert_args(method_name, args)
59
+ res = @delegate_plugin.send(method_name.to_s.snake_case.to_sym, *rargs)
60
+ yield(res)
61
+ rescue Exception => e
62
+ wrap_and_throw_exception(method_name, e)
63
+ ensure
64
+ @delegate_plugin.after_request
65
+ end
66
+ end
67
+
68
+ def wrap_and_throw_exception(api, e)
69
+ message = "#{api} failure: #{e}"
70
+ unless e.backtrace.nil?
71
+ message = "#{message}\n#{e.backtrace.join("\n")}"
72
+ end
73
+ logger.warn message
74
+ raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", e.message)
75
+ end
76
+
77
+ def convert_args(api, args)
78
+ args.collect! do |a|
79
+ if a.nil?
80
+ nil
81
+ elsif a.java_kind_of? java.util.UUID
82
+ JConverter.from_uuid(a)
83
+ elsif a.java_kind_of? java.math.BigDecimal
84
+ JConverter.from_big_decimal(a)
85
+ elsif a.java_kind_of? Java::com.ning.billing.catalog.api.Currency
86
+ a.to_string
87
+ elsif a.java_kind_of? Java::com.ning.billing.payment.api.PaymentMethodPlugin
88
+ JConverter.from_payment_method_plugin(a)
89
+ elsif a.java_kind_of? Java::com.ning.billing.beatrix.bus.api.ExtBusEvent
90
+ JConverter.from_ext_bus_event(a)
91
+ elsif ((a.java_kind_of? Java::boolean) || (a.java_kind_of? java.lang.Boolean))
92
+ JConverter.from_boolean(a)
93
+ # Require because it looks like if non boxed value are passed they already arrive as Ruby type
94
+ elsif ((a.java_kind_of? TrueClass) || (a.java_kind_of? FalseClass))
95
+ a
96
+ elsif a.java_kind_of? java.util.List
97
+ result = Array.new
98
+ if a.size > 0
99
+ first_element = a.get(0)
100
+ if first_element.java_kind_of? Java::com.ning.billing.payment.plugin.api.PaymentMethodInfoPlugin
101
+ a.each do |el|
102
+ result << JConverter.from_payment_method_info_plugin(el)
103
+ end
104
+ else
105
+ raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{first_element.class} for list")
106
+ end
107
+ end
108
+ result
109
+ else
110
+ # Since we don't pass the Context at this point, we can't raise any exceptions for unexpected types.
111
+ #raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{a.class}")
112
+ nil
113
+ end
114
+ end
115
+ # Remove last argument if this is null (it means we passed a context)
116
+ args.delete_at(-1) if args[-1].nil?
117
+ args
118
+ end
119
+
53
120
  end
54
121
  end
55
122
  end
@@ -115,6 +115,11 @@ module Killbill
115
115
  def from_payment_method_info_plugin(payment_method_info_plugin)
116
116
  JPaymentMethodResponseInternal.to_payment_method_response_internal(payment_method_info_plugin)
117
117
  end
118
+
119
+ def from_ext_bus_event(ext_bus)
120
+ JEvent.to_event(ext_bus)
121
+ end
122
+
118
123
  end
119
124
  end
120
125
  end
@@ -0,0 +1,56 @@
1
+ module Killbill
2
+ module Plugin
3
+
4
+ java_package'com.ning.billing.beatrix.bus.api'
5
+ class JEvent
6
+
7
+ include Java::com.ning.billing.beatrix.bus.api.ExtBusEvent
8
+
9
+ attr_reader :event_type, :object_type, :object_id, :account_id, :tenant_id
10
+
11
+ def initialize(event_type, object_type, object_id, account_id, tenant_id)
12
+ @event_type = event_type
13
+ @object_type = object_type
14
+ @object_id = object_id
15
+ @account_id = account_id
16
+ @tenant_id = tenant_id
17
+ end
18
+
19
+ java_signature 'Java::com.ning.billing.beatrix.bus.api.ExtBusEventType getEventType()'
20
+ def get_event_type
21
+ @event_type
22
+ end
23
+
24
+ java_signature 'Java::com.ning.billing.ObjectType getObjectType()'
25
+ def get_object_type
26
+ @object_type
27
+ end
28
+
29
+ java_signature 'java.lang.UUID getObjectId()'
30
+ def get_object_id
31
+ @object_id
32
+ end
33
+
34
+ java_signature 'java.lang.UUID getAccountId()'
35
+ def get_account_id
36
+ @account_id
37
+ end
38
+
39
+ java_signature 'java.lang.UUID getTenantId()'
40
+ def get_tenant_id
41
+ @tenant_id
42
+ end
43
+
44
+ class << self
45
+ def to_event(jevent)
46
+ event_type = jevent.get_event_type.to_s
47
+ object_type = jevent.get_object_type.to_s
48
+ object_id = JConverter.from_uuid(jevent.get_object_id)
49
+ account_id = JConverter.from_uuid(jevent.get_account_id)
50
+ tenant_id = JConverter.from_uuid(jevent.get_tenant_id)
51
+ Event.new(event_type, object_type, object_id, account_id, tenant_id)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -98,18 +98,18 @@ module Killbill
98
98
  get_value_string(PaymentMethodResponse::PROP_CC_TYPE)
99
99
  end
100
100
 
101
- java_signature 'java.lang.String getCCExprirationMonth()'
101
+ java_signature 'java.lang.String getCCExpirationMonth()'
102
102
  def get_cc_expiration_month
103
103
  get_value_string(PaymentMethodResponse::PROP_CC_EXP_MONTH)
104
104
  end
105
105
 
106
- java_signature 'java.lang.String getCCExprirationYear()'
106
+ java_signature 'java.lang.String getCCExpirationYear()'
107
107
  def get_cc_expiration_year
108
108
  get_value_string(PaymentMethodResponse::PROP_CC_EXP_YEAR)
109
109
  end
110
110
 
111
111
  java_signature 'java.lang.String getCCLast4()'
112
- def get_cc_last_4
112
+ def get_cc_last4
113
113
  get_value_string(PaymentMethodResponse::PROP_CC_LAST_4)
114
114
  end
115
115
 
@@ -6,7 +6,7 @@ module Killbill
6
6
 
7
7
  # Override this method in your plugin to act upon received events
8
8
  def on_event(event)
9
- # no-op
9
+ # No-op by default
10
10
  end
11
11
 
12
12
  end
@@ -24,6 +24,10 @@ module Killbill
24
24
  raise OperationUnsupportedByGatewayError
25
25
  end
26
26
 
27
+ def get_refund_info(kb_account_id, kb_payment_id, options = {})
28
+ raise OperationUnsupportedByGatewayError
29
+ end
30
+
27
31
  def add_payment_method(kb_account_id, kb_payment_method_id, payment_method_props, set_default, options = {})
28
32
  raise OperationUnsupportedByGatewayError
29
33
  end
@@ -42,11 +42,11 @@ module Killbill
42
42
  :tag_user_api
43
43
  # Extra services
44
44
  attr_accessor :root,
45
- :logger
45
+ :logger,
46
+ :conf_dir
46
47
 
47
48
  # Called by the Killbill lifecycle when instantiating the plugin
48
49
  def initialize(services = {})
49
-
50
50
  @active = false
51
51
 
52
52
  services.each do |service_name, service_instance|
@@ -0,0 +1,18 @@
1
+
2
+ module Killbill
3
+ module Plugin
4
+ class Event
5
+
6
+ attr_reader :event_type, :object_type, :object_id, :account_id, :tenant_id
7
+
8
+ def initialize(event_type, object_type, object_id, account_id, tenant_id)
9
+ @event_type = event_type
10
+ @object_type = object_type
11
+ @object_id = object_id
12
+ @account_id = account_id
13
+ @tenant_id = tenant_id
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -6,10 +6,12 @@ require 'killbill/response/payment_method_response_internal'
6
6
  require 'killbill/response/payment_status'
7
7
  require 'killbill/response/payment_response'
8
8
  require 'killbill/response/refund_response'
9
+ require 'killbill/response/event'
9
10
 
10
11
  require 'killbill/jresponse/jconverter'
11
12
  require 'killbill/jresponse/jpayment_method_response'
12
13
  require 'killbill/jresponse/jpayment_method_response_internal'
14
+ require 'killbill/jresponse/jevent'
13
15
 
14
16
  describe Killbill::Plugin::JConverter do
15
17
 
@@ -203,6 +205,33 @@ describe Killbill::Plugin::JConverter do
203
205
 
204
206
  output.external_payment_method_id.should be_an_instance_of String
205
207
  output.external_payment_method_id.should == payment_method_info.external_payment_method_id
206
-
207
208
  end
209
+
210
+ it "should_test_ext_bus_event__from_converter" do
211
+
212
+ object_type = Java::com.ning.billing.ObjectType::INVOICE
213
+ event_type = Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::INVOICE_CREATION
214
+ uuid = java.util.UUID.random_uuid
215
+
216
+ input = Killbill::Plugin::JEvent.new(event_type, object_type, uuid, uuid, uuid)
217
+ output = Killbill::Plugin::JConverter.from_ext_bus_event(input)
218
+
219
+ output.should be_an_instance_of Killbill::Plugin::Event
220
+
221
+ output.event_type.should be_an_instance_of String
222
+ output.event_type.should == 'INVOICE_CREATION'
223
+
224
+ output.object_type.should be_an_instance_of String
225
+ output.object_type.should == 'INVOICE'
226
+
227
+ output.object_id.should be_an_instance_of String
228
+ output.object_id.should == Killbill::Plugin::JConverter.from_uuid(uuid)
229
+
230
+ output.account_id.should be_an_instance_of String
231
+ output.account_id.should == Killbill::Plugin::JConverter.from_uuid(uuid)
232
+
233
+ output.tenant_id.should be_an_instance_of String
234
+ output.tenant_id.should == Killbill::Plugin::JConverter.from_uuid(uuid)
235
+
236
+ end
208
237
  end
@@ -24,6 +24,7 @@ describe Killbill::Plugin::Payment do
24
24
  lambda { @plugin.process_payment(@kb_account_id, @kb_payment_id, @kb_payment_method_id, @amount_in_cents, @currency) }.should raise_error Killbill::Plugin::Payment::OperationUnsupportedByGatewayError
25
25
  lambda { @plugin.process_refund(@kb_account_id, @kb_payment_id, @amount_in_cents, @currency) }.should raise_error Killbill::Plugin::Payment::OperationUnsupportedByGatewayError
26
26
  lambda { @plugin.get_payment_info(@kb_account_id, @kb_payment_id) }.should raise_error Killbill::Plugin::Payment::OperationUnsupportedByGatewayError
27
+ lambda { @plugin.get_refund_info(@kb_account_id, @kb_payment_id) }.should raise_error Killbill::Plugin::Payment::OperationUnsupportedByGatewayError
27
28
  lambda { @plugin.add_payment_method(@kb_account_id, @payment_method, @payment_method_props, true ) }.should raise_error Killbill::Plugin::Payment::OperationUnsupportedByGatewayError
28
29
  lambda { @plugin.delete_payment_method(@kb_account_id, @kb_payment_method_id) }.should raise_error Killbill::Plugin::Payment::OperationUnsupportedByGatewayError
29
30
  lambda { @plugin.set_default_payment_method(@kb_account_id, @payment_method) }.should raise_error Killbill::Plugin::Payment::OperationUnsupportedByGatewayError
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill
3
3
  version: !ruby/object:Gem::Version
4
+ version: 1.0.14
4
5
  prerelease:
5
- version: 1.0.13
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-04-11 00:00:00.000000000 Z
12
+ date: 2013-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jbundler
@@ -108,9 +108,11 @@ files:
108
108
  - lib/killbill.rb
109
109
  - lib/killbill/creator.rb
110
110
  - lib/killbill/http_servlet.rb
111
+ - lib/killbill/jnotification.rb
111
112
  - lib/killbill/jpayment.rb
112
113
  - lib/killbill/jplugin.rb
113
114
  - lib/killbill/jresponse/jconverter.rb
115
+ - lib/killbill/jresponse/jevent.rb
114
116
  - lib/killbill/jresponse/jpayment_method_response.rb
115
117
  - lib/killbill/jresponse/jpayment_method_response_internal.rb
116
118
  - lib/killbill/jresponse/jpayment_response.rb
@@ -120,6 +122,7 @@ files:
120
122
  - lib/killbill/payment.rb
121
123
  - lib/killbill/plugin.rb
122
124
  - lib/killbill/rake_task.rb
125
+ - lib/killbill/response/event.rb
123
126
  - lib/killbill/response/payment_method_response.rb
124
127
  - lib/killbill/response/payment_method_response_internal.rb
125
128
  - lib/killbill/response/payment_response.rb
@@ -160,9 +163,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
163
  - !ruby/object:Gem::Version
161
164
  segments:
162
165
  - 0
163
- hash: 2
164
166
  version: !binary |-
165
167
  MA==
168
+ hash: 2
166
169
  none: false
167
170
  requirements: []
168
171
  rubyforge_project: