killbill 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -3
- data/Jarfile +8 -7
- data/Jarfile.lock +9 -8
- data/README.md +131 -108
- data/gen_config/api.conf +1 -1
- data/gen_config/plugin_api.conf +7 -6
- data/generators/active_merchant/templates/Jarfile.rb +7 -7
- data/generators/active_merchant/templates/plugin.gemspec.rb +2 -3
- data/killbill.gemspec +5 -2
- data/lib/killbill.rb +26 -22
- data/lib/killbill/gen/api/admin_payment_api.rb +76 -0
- data/lib/killbill/gen/api/payment_api.rb +82 -0
- data/lib/killbill/gen/api/payment_gateway_api.rb +75 -0
- data/lib/killbill/gen/api/require_gen.rb +1 -0
- data/lib/killbill/gen/plugin-api/catalog_plugin_api.rb +76 -0
- data/lib/killbill/gen/plugin-api/on_failure_payment_routing_result.rb +65 -0
- data/lib/killbill/gen/plugin-api/on_success_payment_routing_result.rb +53 -0
- data/lib/killbill/gen/plugin-api/payment_routing_api_exception.rb +51 -0
- data/lib/killbill/gen/plugin-api/payment_routing_context.rb +246 -0
- data/lib/killbill/gen/plugin-api/payment_routing_plugin_api.rb +138 -0
- data/lib/killbill/gen/plugin-api/prior_payment_routing_result.rb +107 -0
- data/lib/killbill/gen/plugin-api/require_gen.rb +9 -0
- data/lib/killbill/gen/plugin-api/standalone_plugin_catalog.rb +174 -0
- data/lib/killbill/gen/plugin-api/versioned_plugin_catalog.rb +83 -0
- data/lib/killbill/helpers/active_merchant.rb +6 -4
- data/lib/killbill/helpers/active_merchant/active_record/models/response.rb +16 -4
- data/lib/killbill/helpers/active_merchant/configuration.rb +7 -2
- data/lib/killbill/helpers/active_merchant/gateway.rb +76 -5
- data/lib/killbill/helpers/active_merchant/payment_plugin.rb +12 -8
- data/lib/killbill/helpers/catalog.rb +15 -0
- data/lib/killbill/payment_control.rb +23 -0
- data/lib/killbill/version.rb +3 -0
- data/spec/killbill/helpers/configuration_spec.rb +18 -4
- data/spec/killbill/helpers/payment_plugin_spec.rb +140 -36
- data/spec/killbill/helpers/response_spec.rb +1 -1
- metadata +49 -5
- data/VERSION +0 -1
@@ -0,0 +1,107 @@
|
|
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 Model
|
31
|
+
|
32
|
+
java_package 'org.killbill.billing.routing.plugin.api'
|
33
|
+
class PriorPaymentRoutingResult
|
34
|
+
|
35
|
+
include org.killbill.billing.routing.plugin.api.PriorPaymentRoutingResult
|
36
|
+
|
37
|
+
attr_accessor :is_aborted, :adjusted_amount, :adjusted_currency, :adjusted_payment_method_id, :adjusted_plugin_properties
|
38
|
+
|
39
|
+
def initialize()
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_java()
|
43
|
+
# conversion for is_aborted [type = boolean]
|
44
|
+
@is_aborted = @is_aborted.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(@is_aborted)
|
45
|
+
|
46
|
+
# conversion for adjusted_amount [type = java.math.BigDecimal]
|
47
|
+
if @adjusted_amount.nil?
|
48
|
+
@adjusted_amount = java.math.BigDecimal::ZERO
|
49
|
+
else
|
50
|
+
@adjusted_amount = java.math.BigDecimal.new(@adjusted_amount.to_s)
|
51
|
+
end
|
52
|
+
|
53
|
+
# conversion for adjusted_currency [type = org.killbill.billing.catalog.api.Currency]
|
54
|
+
@adjusted_currency = Java::org.killbill.billing.catalog.api.Currency.value_of( @adjusted_currency.to_s ) unless @adjusted_currency.nil?
|
55
|
+
|
56
|
+
# conversion for adjusted_payment_method_id [type = java.util.UUID]
|
57
|
+
@adjusted_payment_method_id = java.util.UUID.fromString(@adjusted_payment_method_id.to_s) unless @adjusted_payment_method_id.nil?
|
58
|
+
|
59
|
+
# conversion for adjusted_plugin_properties [type = java.lang.Iterable]
|
60
|
+
tmp = java.util.ArrayList.new
|
61
|
+
(@adjusted_plugin_properties || []).each do |m|
|
62
|
+
# conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
|
63
|
+
m = m.to_java unless m.nil?
|
64
|
+
tmp.add(m)
|
65
|
+
end
|
66
|
+
@adjusted_plugin_properties = tmp
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_ruby(j_obj)
|
71
|
+
# conversion for is_aborted [type = boolean]
|
72
|
+
@is_aborted = j_obj.is_aborted
|
73
|
+
if @is_aborted.nil?
|
74
|
+
@is_aborted = false
|
75
|
+
else
|
76
|
+
tmp_bool = (@is_aborted.java_kind_of? java.lang.Boolean) ? @is_aborted.boolean_value : @is_aborted
|
77
|
+
@is_aborted = tmp_bool ? true : false
|
78
|
+
end
|
79
|
+
|
80
|
+
# conversion for adjusted_amount [type = java.math.BigDecimal]
|
81
|
+
@adjusted_amount = j_obj.adjusted_amount
|
82
|
+
@adjusted_amount = @adjusted_amount.nil? ? 0 : BigDecimal.new(@adjusted_amount.to_s)
|
83
|
+
|
84
|
+
# conversion for adjusted_currency [type = org.killbill.billing.catalog.api.Currency]
|
85
|
+
@adjusted_currency = j_obj.adjusted_currency
|
86
|
+
@adjusted_currency = @adjusted_currency.to_s.to_sym unless @adjusted_currency.nil?
|
87
|
+
|
88
|
+
# conversion for adjusted_payment_method_id [type = java.util.UUID]
|
89
|
+
@adjusted_payment_method_id = j_obj.adjusted_payment_method_id
|
90
|
+
@adjusted_payment_method_id = @adjusted_payment_method_id.nil? ? nil : @adjusted_payment_method_id.to_s
|
91
|
+
|
92
|
+
# conversion for adjusted_plugin_properties [type = java.lang.Iterable]
|
93
|
+
@adjusted_plugin_properties = j_obj.adjusted_plugin_properties
|
94
|
+
tmp = []
|
95
|
+
(@adjusted_plugin_properties.nil? ? [] : @adjusted_plugin_properties.iterator).each do |m|
|
96
|
+
# conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
|
97
|
+
m = Killbill::Plugin::Model::PluginProperty.new.to_ruby(m) unless m.nil?
|
98
|
+
tmp << m
|
99
|
+
end
|
100
|
+
@adjusted_plugin_properties = tmp
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -32,6 +32,15 @@ require 'killbill/gen/plugin-api/ext_bus_event'
|
|
32
32
|
require 'killbill/gen/plugin-api/notification_plugin_api'
|
33
33
|
require 'killbill/gen/plugin-api/invoice_plugin_api'
|
34
34
|
require 'killbill/gen/plugin-api/currency_plugin_api'
|
35
|
+
require 'killbill/gen/plugin-api/on_failure_payment_routing_result'
|
36
|
+
require 'killbill/gen/plugin-api/on_success_payment_routing_result'
|
37
|
+
require 'killbill/gen/plugin-api/payment_routing_api_exception'
|
38
|
+
require 'killbill/gen/plugin-api/payment_routing_context'
|
39
|
+
require 'killbill/gen/plugin-api/payment_routing_plugin_api'
|
40
|
+
require 'killbill/gen/plugin-api/prior_payment_routing_result'
|
41
|
+
require 'killbill/gen/plugin-api/catalog_plugin_api'
|
42
|
+
require 'killbill/gen/plugin-api/standalone_plugin_catalog'
|
43
|
+
require 'killbill/gen/plugin-api/versioned_plugin_catalog'
|
35
44
|
require 'killbill/gen/plugin-api/gateway_notification'
|
36
45
|
require 'killbill/gen/plugin-api/hosted_payment_page_form_descriptor'
|
37
46
|
require 'killbill/gen/plugin-api/payment_transaction_info_plugin'
|
@@ -0,0 +1,174 @@
|
|
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 Model
|
31
|
+
|
32
|
+
java_package 'org.killbill.billing.catalog.plugin.api'
|
33
|
+
class StandalonePluginCatalog
|
34
|
+
|
35
|
+
include org.killbill.billing.catalog.plugin.api.StandalonePluginCatalog
|
36
|
+
|
37
|
+
attr_accessor :effective_date, :currencies, :units, :products, :plans, :default_price_list, :children_price_list, :plan_rules
|
38
|
+
|
39
|
+
def initialize()
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_java()
|
43
|
+
# conversion for effective_date [type = org.joda.time.DateTime]
|
44
|
+
if !@effective_date.nil?
|
45
|
+
@effective_date = (@effective_date.kind_of? Time) ? DateTime.parse(@effective_date.to_s) : @effective_date
|
46
|
+
@effective_date = Java::org.joda.time.DateTime.new(@effective_date.to_s, Java::org.joda.time.DateTimeZone::UTC)
|
47
|
+
end
|
48
|
+
|
49
|
+
# conversion for currencies [type = java.lang.Iterable]
|
50
|
+
tmp = java.util.ArrayList.new
|
51
|
+
(@currencies || []).each do |m|
|
52
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Currency]
|
53
|
+
m = Java::org.killbill.billing.catalog.api.Currency.value_of( m.to_s ) unless m.nil?
|
54
|
+
tmp.add(m)
|
55
|
+
end
|
56
|
+
@currencies = tmp
|
57
|
+
|
58
|
+
# conversion for units [type = java.lang.Iterable]
|
59
|
+
tmp = java.util.ArrayList.new
|
60
|
+
(@units || []).each do |m|
|
61
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Unit]
|
62
|
+
m = m.to_java unless m.nil?
|
63
|
+
tmp.add(m)
|
64
|
+
end
|
65
|
+
@units = tmp
|
66
|
+
|
67
|
+
# conversion for products [type = java.lang.Iterable]
|
68
|
+
tmp = java.util.ArrayList.new
|
69
|
+
(@products || []).each do |m|
|
70
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Product]
|
71
|
+
m = m.to_java unless m.nil?
|
72
|
+
tmp.add(m)
|
73
|
+
end
|
74
|
+
@products = tmp
|
75
|
+
|
76
|
+
# conversion for plans [type = java.lang.Iterable]
|
77
|
+
tmp = java.util.ArrayList.new
|
78
|
+
(@plans || []).each do |m|
|
79
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Plan]
|
80
|
+
m = m.to_java unless m.nil?
|
81
|
+
tmp.add(m)
|
82
|
+
end
|
83
|
+
@plans = tmp
|
84
|
+
|
85
|
+
# conversion for default_price_list [type = org.killbill.billing.catalog.api.PriceList]
|
86
|
+
@default_price_list = @default_price_list.to_java unless @default_price_list.nil?
|
87
|
+
|
88
|
+
# conversion for children_price_list [type = java.lang.Iterable]
|
89
|
+
tmp = java.util.ArrayList.new
|
90
|
+
(@children_price_list || []).each do |m|
|
91
|
+
# conversion for m [type = org.killbill.billing.catalog.api.PriceList]
|
92
|
+
m = m.to_java unless m.nil?
|
93
|
+
tmp.add(m)
|
94
|
+
end
|
95
|
+
@children_price_list = tmp
|
96
|
+
|
97
|
+
# conversion for plan_rules [type = org.killbill.billing.catalog.api.rules.PlanRules]
|
98
|
+
@plan_rules = @plan_rules.to_java unless @plan_rules.nil?
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
def to_ruby(j_obj)
|
103
|
+
# conversion for effective_date [type = org.joda.time.DateTime]
|
104
|
+
@effective_date = j_obj.effective_date
|
105
|
+
if !@effective_date.nil?
|
106
|
+
fmt = Java::org.joda.time.format.ISODateTimeFormat.date_time_no_millis # See https://github.com/killbill/killbill-java-parser/issues/3
|
107
|
+
str = fmt.print(@effective_date)
|
108
|
+
@effective_date = DateTime.iso8601(str)
|
109
|
+
end
|
110
|
+
|
111
|
+
# conversion for currencies [type = java.lang.Iterable]
|
112
|
+
@currencies = j_obj.currencies
|
113
|
+
tmp = []
|
114
|
+
(@currencies.nil? ? [] : @currencies.iterator).each do |m|
|
115
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Currency]
|
116
|
+
m = m.to_s.to_sym unless m.nil?
|
117
|
+
tmp << m
|
118
|
+
end
|
119
|
+
@currencies = tmp
|
120
|
+
|
121
|
+
# conversion for units [type = java.lang.Iterable]
|
122
|
+
@units = j_obj.units
|
123
|
+
tmp = []
|
124
|
+
(@units.nil? ? [] : @units.iterator).each do |m|
|
125
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Unit]
|
126
|
+
m = Killbill::Plugin::Model::Unit.new.to_ruby(m) unless m.nil?
|
127
|
+
tmp << m
|
128
|
+
end
|
129
|
+
@units = tmp
|
130
|
+
|
131
|
+
# conversion for products [type = java.lang.Iterable]
|
132
|
+
@products = j_obj.products
|
133
|
+
tmp = []
|
134
|
+
(@products.nil? ? [] : @products.iterator).each do |m|
|
135
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Product]
|
136
|
+
m = Killbill::Plugin::Model::Product.new.to_ruby(m) unless m.nil?
|
137
|
+
tmp << m
|
138
|
+
end
|
139
|
+
@products = tmp
|
140
|
+
|
141
|
+
# conversion for plans [type = java.lang.Iterable]
|
142
|
+
@plans = j_obj.plans
|
143
|
+
tmp = []
|
144
|
+
(@plans.nil? ? [] : @plans.iterator).each do |m|
|
145
|
+
# conversion for m [type = org.killbill.billing.catalog.api.Plan]
|
146
|
+
m = Killbill::Plugin::Model::Plan.new.to_ruby(m) unless m.nil?
|
147
|
+
tmp << m
|
148
|
+
end
|
149
|
+
@plans = tmp
|
150
|
+
|
151
|
+
# conversion for default_price_list [type = org.killbill.billing.catalog.api.PriceList]
|
152
|
+
@default_price_list = j_obj.default_price_list
|
153
|
+
@default_price_list = Killbill::Plugin::Model::PriceList.new.to_ruby(@default_price_list) unless @default_price_list.nil?
|
154
|
+
|
155
|
+
# conversion for children_price_list [type = java.lang.Iterable]
|
156
|
+
@children_price_list = j_obj.children_price_list
|
157
|
+
tmp = []
|
158
|
+
(@children_price_list.nil? ? [] : @children_price_list.iterator).each do |m|
|
159
|
+
# conversion for m [type = org.killbill.billing.catalog.api.PriceList]
|
160
|
+
m = Killbill::Plugin::Model::PriceList.new.to_ruby(m) unless m.nil?
|
161
|
+
tmp << m
|
162
|
+
end
|
163
|
+
@children_price_list = tmp
|
164
|
+
|
165
|
+
# conversion for plan_rules [type = org.killbill.billing.catalog.api.rules.PlanRules]
|
166
|
+
@plan_rules = j_obj.plan_rules
|
167
|
+
@plan_rules = Killbill::Plugin::Model::PlanRules.new.to_ruby(@plan_rules) unless @plan_rules.nil?
|
168
|
+
self
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,83 @@
|
|
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 Model
|
31
|
+
|
32
|
+
java_package 'org.killbill.billing.catalog.plugin.api'
|
33
|
+
class VersionedPluginCatalog
|
34
|
+
|
35
|
+
include org.killbill.billing.catalog.plugin.api.VersionedPluginCatalog
|
36
|
+
|
37
|
+
attr_accessor :catalog_name, :recurring_billing_mode, :standalone_plugin_catalogs
|
38
|
+
|
39
|
+
def initialize()
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_java()
|
43
|
+
# conversion for catalog_name [type = java.lang.String]
|
44
|
+
@catalog_name = @catalog_name.to_s unless @catalog_name.nil?
|
45
|
+
|
46
|
+
# conversion for recurring_billing_mode [type = org.killbill.billing.catalog.api.BillingMode]
|
47
|
+
@recurring_billing_mode = Java::org.killbill.billing.catalog.api.BillingMode.value_of( @recurring_billing_mode.to_s ) unless @recurring_billing_mode.nil?
|
48
|
+
|
49
|
+
# conversion for standalone_plugin_catalogs [type = java.lang.Iterable]
|
50
|
+
tmp = java.util.ArrayList.new
|
51
|
+
(@standalone_plugin_catalogs || []).each do |m|
|
52
|
+
# conversion for m [type = org.killbill.billing.catalog.plugin.api.StandalonePluginCatalog]
|
53
|
+
m = m.to_java unless m.nil?
|
54
|
+
tmp.add(m)
|
55
|
+
end
|
56
|
+
@standalone_plugin_catalogs = tmp
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_ruby(j_obj)
|
61
|
+
# conversion for catalog_name [type = java.lang.String]
|
62
|
+
@catalog_name = j_obj.catalog_name
|
63
|
+
|
64
|
+
# conversion for recurring_billing_mode [type = org.killbill.billing.catalog.api.BillingMode]
|
65
|
+
@recurring_billing_mode = j_obj.recurring_billing_mode
|
66
|
+
@recurring_billing_mode = @recurring_billing_mode.to_s.to_sym unless @recurring_billing_mode.nil?
|
67
|
+
|
68
|
+
# conversion for standalone_plugin_catalogs [type = java.lang.Iterable]
|
69
|
+
@standalone_plugin_catalogs = j_obj.standalone_plugin_catalogs
|
70
|
+
tmp = []
|
71
|
+
(@standalone_plugin_catalogs.nil? ? [] : @standalone_plugin_catalogs.iterator).each do |m|
|
72
|
+
# conversion for m [type = org.killbill.billing.catalog.plugin.api.StandalonePluginCatalog]
|
73
|
+
m = Killbill::Plugin::Model::StandalonePluginCatalog.new.to_ruby(m) unless m.nil?
|
74
|
+
tmp << m
|
75
|
+
end
|
76
|
+
@standalone_plugin_catalogs = tmp
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -3,12 +3,14 @@ module Killbill
|
|
3
3
|
module ActiveMerchant
|
4
4
|
require 'killbill'
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'killbill/helpers/properties_helper'
|
7
|
+
require 'killbill/helpers/active_merchant/active_record/active_record_helper.rb'
|
8
|
+
|
9
|
+
require 'active_support'
|
8
10
|
|
9
11
|
require 'active_support/core_ext'
|
10
|
-
require
|
11
|
-
require
|
12
|
+
require 'killbill/helpers/active_merchant/core_ext'
|
13
|
+
require 'killbill/helpers/active_merchant/configuration'
|
12
14
|
|
13
15
|
Dir[File.dirname(__FILE__) + '/active_merchant/*.rb'].each do |f|
|
14
16
|
# Get camelized class name
|
@@ -99,16 +99,28 @@ module Killbill
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def to_transaction_info_plugin(transaction=nil)
|
102
|
+
error_details = {}
|
103
|
+
|
102
104
|
if transaction.nil?
|
103
105
|
amount_in_cents = nil
|
104
106
|
currency = nil
|
105
107
|
created_date = created_at
|
106
|
-
|
108
|
+
# See Killbill::Plugin::ActiveMerchant::Gateway
|
109
|
+
error_details = JSON.parse(message) rescue {}
|
107
110
|
else
|
108
111
|
amount_in_cents = transaction.amount_in_cents
|
109
112
|
currency = transaction.currency
|
110
113
|
created_date = transaction.created_at
|
111
|
-
|
114
|
+
end
|
115
|
+
|
116
|
+
# See https://github.com/killbill/killbill-plugin-framework-ruby/issues/43
|
117
|
+
# Note: status could also be :PENDING, but it would be handled only in the plugins which need it
|
118
|
+
if !error_details['payment_plugin_status'].blank?
|
119
|
+
status = error_details['payment_plugin_status'].to_sym
|
120
|
+
else
|
121
|
+
# Note: (success && transaction.nil?) _could_ happen (see above), but it would be an issue on our side
|
122
|
+
# (the payment did go through in the gateway).
|
123
|
+
status = success ? :PROCESSED : :ERROR
|
112
124
|
end
|
113
125
|
|
114
126
|
t_info_plugin = Killbill::Plugin::Model::PaymentTransactionInfoPlugin.new
|
@@ -120,8 +132,8 @@ module Killbill
|
|
120
132
|
t_info_plugin.created_date = created_date
|
121
133
|
t_info_plugin.effective_date = effective_date
|
122
134
|
t_info_plugin.status = status
|
123
|
-
t_info_plugin.gateway_error = gateway_error
|
124
|
-
t_info_plugin.gateway_error_code = gateway_error_code
|
135
|
+
t_info_plugin.gateway_error = error_details['exception_message'] || gateway_error
|
136
|
+
t_info_plugin.gateway_error_code = error_details['exception_class'] || gateway_error_code
|
125
137
|
t_info_plugin.first_payment_reference_id = first_reference_id
|
126
138
|
t_info_plugin.second_payment_reference_id = second_reference_id
|
127
139
|
|
@@ -78,13 +78,18 @@ module Killbill
|
|
78
78
|
if gateway_account_id.nil?
|
79
79
|
@@logger.warn "Skipping config #{gateway_config} -- missing :account_id"
|
80
80
|
else
|
81
|
-
gateways_config[gateway_account_id.to_sym] = Gateway.wrap(gateway_builder, gateway_config)
|
81
|
+
gateways_config[gateway_account_id.to_sym] = Gateway.wrap(gateway_builder, gateway_config, @@logger)
|
82
82
|
default_gateway = gateways_config[gateway_account_id.to_sym] if idx == 0
|
83
83
|
end
|
84
84
|
end
|
85
85
|
gateways_config[:default] = default_gateway if gateways_config[:default].nil?
|
86
86
|
else
|
87
|
-
|
87
|
+
# We assume the configuration should never be nil (if you really do have a use-case, just specify a dummy config)
|
88
|
+
if gateway_configs.nil?
|
89
|
+
@@logger.warn "Unable to configure gateway #{@@gateway_name}, invalid configuration: #{config}"
|
90
|
+
else
|
91
|
+
gateways_config[:default] = Gateway.wrap(@@gateway_builder, gateway_configs, @@logger)
|
92
|
+
end
|
88
93
|
end
|
89
94
|
gateways_config
|
90
95
|
end
|