kaui 1.4.0 → 2.0.3
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/README.md +24 -1
- data/app/assets/javascripts/kaui/kaui.js +8 -2
- data/app/assets/stylesheets/kaui/common.less +44 -1
- data/app/controllers/kaui/admin_tenants_controller.rb +77 -106
- data/app/controllers/kaui/audit_logs_controller.rb +23 -1
- data/app/controllers/kaui/charges_controller.rb +1 -1
- data/app/controllers/kaui/credits_controller.rb +5 -5
- data/app/controllers/kaui/home_controller.rb +2 -2
- data/app/controllers/kaui/invoice_items_controller.rb +1 -1
- data/app/controllers/kaui/invoices_controller.rb +6 -4
- data/app/controllers/kaui/payment_methods_controller.rb +9 -3
- data/app/controllers/kaui/payments_controller.rb +1 -1
- data/app/controllers/kaui/refunds_controller.rb +2 -2
- data/app/controllers/kaui/sessions_controller.rb +6 -0
- data/app/controllers/kaui/subscriptions_controller.rb +29 -5
- data/app/helpers/kaui/payment_method_helper.rb +5 -3
- data/app/helpers/kaui/plugin_helper.rb +9 -48
- data/app/helpers/kaui/subscription_helper.rb +5 -4
- data/app/models/kaui/admin_tenant.rb +8 -84
- data/app/models/kaui/catalog.rb +14 -2
- data/app/views/kaui/account_emails/_form.html.erb +1 -1
- data/app/views/kaui/accounts/_form.html.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +48 -240
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +6 -6
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +16 -15
- data/app/views/kaui/bundles/index.html.erb +1 -1
- data/app/views/kaui/chargebacks/_form.html.erb +1 -1
- data/app/views/kaui/charges/_form.html.erb +1 -1
- data/app/views/kaui/credits/_form.html.erb +2 -2
- data/app/views/kaui/invoices/show.html.erb +0 -1
- data/app/views/kaui/payments/_form.html.erb +1 -1
- data/app/views/kaui/payments/_payment_table.html.erb +2 -2
- data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_form.html.erb +16 -4
- data/config/routes.rb +1 -1
- data/lib/kaui/version.rb +1 -1
- data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/test/functional/kaui/admin_tenants_controller_test.rb +2 -22
- data/test/functional/kaui/credits_controller_test.rb +3 -3
- data/test/functional/kaui/home_controller_test.rb +5 -5
- data/test/functional/kaui/subscriptions_controller_test.rb +1 -1
- data/test/killbill_test_helper.rb +6 -6
- data/test/unit/helpers/kaui/payment_method_helper_test.rb +17 -0
- data/test/unit/kaui/admin_tenant_test.rb +10 -47
- metadata +8 -6
@@ -52,7 +52,7 @@ class Kaui::HomeController < Kaui::EngineController
|
|
52
52
|
def invoice_search(search_query, search_by = nil, fast = 0, options = {})
|
53
53
|
if search_by == 'ID'
|
54
54
|
begin
|
55
|
-
invoice = Kaui::Invoice.find_by_id(search_query,
|
55
|
+
invoice = Kaui::Invoice.find_by_id(search_query, 'NONE', options)
|
56
56
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
|
57
57
|
rescue KillBillClient::API::NotFound => _
|
58
58
|
search_error("No invoice matches \"#{search_query}\"")
|
@@ -63,7 +63,7 @@ class Kaui::HomeController < Kaui::EngineController
|
|
63
63
|
invoice = Kaui::Invoice.list_or_search(search_query, 0, 1, options).first
|
64
64
|
if invoice.blank?
|
65
65
|
begin
|
66
|
-
invoice = Kaui::Invoice.find_by_invoice_item_id(search_query, false,
|
66
|
+
invoice = Kaui::Invoice.find_by_invoice_item_id(search_query, false, 'NONE', options)
|
67
67
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
|
68
68
|
rescue KillBillClient::API::NotFound => _
|
69
69
|
search_error("No invoice matches \"#{search_query}\"")
|
@@ -5,7 +5,7 @@ class Kaui::InvoiceItemsController < Kaui::EngineController
|
|
5
5
|
invoice_id = params.require(:invoice_id)
|
6
6
|
|
7
7
|
# See https://github.com/killbill/killbill/issues/7
|
8
|
-
invoice = Kaui::Invoice.find_by_id(invoice_id,
|
8
|
+
invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
|
9
9
|
@invoice_item = invoice.items.find { |ii| ii.invoice_item_id == invoice_item_id }
|
10
10
|
|
11
11
|
if @invoice_item.nil?
|
@@ -18,7 +18,7 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
18
18
|
if account.nil?
|
19
19
|
Kaui::Invoice.list_or_search(search_key, offset, limit, cached_options_for_klient)
|
20
20
|
else
|
21
|
-
account.invoices(
|
21
|
+
account.invoices(cached_options_for_klient).map! { |invoice| Kaui::Invoice.build_from_raw_invoice(invoice) }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -47,7 +47,9 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
47
47
|
# Go to the database once
|
48
48
|
cached_options_for_klient = options_for_klient
|
49
49
|
|
50
|
-
@invoice = Kaui::Invoice.find_by_id(params.require(:id),
|
50
|
+
@invoice = Kaui::Invoice.find_by_id(params.require(:id), 'FULL', cached_options_for_klient)
|
51
|
+
# This will put the TAX items at the bottom
|
52
|
+
@invoice.items.sort_by! { |ii| [ii.item_type, ii.description] }
|
51
53
|
|
52
54
|
fetch_payments = promise { @invoice.payments(true, true, 'FULL', cached_options_for_klient).map { |payment| Kaui::InvoicePayment.build_from_raw_payment(payment) } }
|
53
55
|
fetch_pms = fetch_payments.then { |payments| Kaui::PaymentMethod.payment_methods_for_payments(payments, cached_options_for_klient) }
|
@@ -78,7 +80,7 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
78
80
|
end
|
79
81
|
|
80
82
|
def restful_show
|
81
|
-
invoice = Kaui::Invoice.find_by_id(params.require(:id),
|
83
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
82
84
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
83
85
|
end
|
84
86
|
|
@@ -88,7 +90,7 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
88
90
|
|
89
91
|
def commit_invoice
|
90
92
|
cached_options_for_klient = options_for_klient
|
91
|
-
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id),
|
93
|
+
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), 'NONE', cached_options_for_klient)
|
92
94
|
invoice.commit(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
93
95
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), :notice => 'Invoice successfully committed'
|
94
96
|
end
|
@@ -45,9 +45,15 @@ class Kaui::PaymentMethodsController < Kaui::EngineController
|
|
45
45
|
}
|
46
46
|
|
47
47
|
@plugin_properties = params[:plugin_properties].values.select{ |item| !(item['value'].blank? || item['key'].blank?) } rescue @plugin_properties = nil
|
48
|
-
@plugin_properties.
|
49
|
-
|
50
|
-
|
48
|
+
if @plugin_properties.blank?
|
49
|
+
# In case of error, we want the view to receive nil, not [], so that at least the first row is populated (required to make the JS work)
|
50
|
+
# See https://github.com/killbill/killbill-admin-ui/issues/258
|
51
|
+
@plugin_properties = nil
|
52
|
+
else
|
53
|
+
@plugin_properties.map! do |property|
|
54
|
+
KillBillClient::Model::PluginPropertyAttributes.new(property)
|
55
|
+
end
|
56
|
+
end
|
51
57
|
|
52
58
|
begin
|
53
59
|
@payment_method = @payment_method.create(@payment_method.is_default, current_user.kb_username, params[:reason], params[:comment],
|
@@ -74,7 +74,7 @@ class Kaui::PaymentsController < Kaui::EngineController
|
|
74
74
|
|
75
75
|
def new
|
76
76
|
cached_options_for_klient = options_for_klient
|
77
|
-
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id),
|
77
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
|
78
78
|
fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(params.require(:account_id), false, cached_options_for_klient) }
|
79
79
|
|
80
80
|
@invoice = wait(fetch_invoice)
|
@@ -3,7 +3,7 @@ class Kaui::RefundsController < Kaui::EngineController
|
|
3
3
|
def new
|
4
4
|
cached_options_for_klient = options_for_klient
|
5
5
|
|
6
|
-
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id),
|
6
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
|
7
7
|
fetch_payment = promise { Kaui::InvoicePayment::find_by_id(params.require(:payment_id), false, false, cached_options_for_klient) }
|
8
8
|
fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
|
9
9
|
|
@@ -15,7 +15,7 @@ class Kaui::RefundsController < Kaui::EngineController
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def create
|
18
|
-
invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id),
|
18
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', options_for_klient)
|
19
19
|
|
20
20
|
if params[:adjustment_type] == 'invoiceItemAdjustment'
|
21
21
|
items = []
|
@@ -18,5 +18,11 @@ module Kaui
|
|
18
18
|
def after_sign_out_path_for(resource)
|
19
19
|
kaui_path
|
20
20
|
end
|
21
|
+
|
22
|
+
def require_no_authentication
|
23
|
+
super
|
24
|
+
# Remove the somewhat confusing message "You are already signed in."
|
25
|
+
flash.discard(:alert) if flash[:alert] == I18n.t("devise.failure.already_authenticated")
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
@@ -11,9 +11,9 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
11
11
|
|
12
12
|
if @plans.empty?
|
13
13
|
if @subscription.product_category == 'BASE'
|
14
|
-
flash[:error] = 'No available
|
14
|
+
flash[:error] = 'No plan available in the catalog'
|
15
15
|
else
|
16
|
-
flash[:error] = "No
|
16
|
+
flash[:error] = "No add-on available in the catalog for product #{@base_product_name}"
|
17
17
|
end
|
18
18
|
redirect_to kaui_engine.account_bundles_path(@subscription.account_id), :error => 'No available plan'
|
19
19
|
end
|
@@ -46,6 +46,16 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
46
46
|
redirect_to kaui_engine.account_bundles_path(@subscription.account_id), :notice => 'Subscription was successfully created'
|
47
47
|
rescue => e
|
48
48
|
@plans = plans_details.nil? ? [] : plans_details.map { |p| p.plan }
|
49
|
+
|
50
|
+
if e.is_a?(::KillBillClient::API::BadRequest) && !e.response.nil? && !e.response.body.nil?
|
51
|
+
error_message = JSON.parse(e.response.body) rescue nil
|
52
|
+
if !error_message.nil? & !error_message['code'].nil? && error_message['code'] == 2010 # CAT_NO_PRICE_FOR_CURRENCY
|
53
|
+
# Hack for lack of proper Kill Bill messaging (https://github.com/killbill/killbill-admin-ui/issues/266)
|
54
|
+
flash.now[:error] = "Unable to create the subscription: a price for this currency hasn't been specified in the catalog"
|
55
|
+
render :new and return
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
49
59
|
flash.now[:error] = "Error while creating the subscription: #{as_string(e)}"
|
50
60
|
render :new
|
51
61
|
end
|
@@ -141,7 +151,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
141
151
|
redirect_to kaui_engine.account_bundles_path(subscription.account_id)
|
142
152
|
end
|
143
153
|
|
144
|
-
def
|
154
|
+
def validate_bundle_external_key
|
145
155
|
json_response do
|
146
156
|
external_key = params.require(:external_key)
|
147
157
|
|
@@ -155,6 +165,21 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
155
165
|
end
|
156
166
|
end
|
157
167
|
|
168
|
+
|
169
|
+
def validate_external_key
|
170
|
+
json_response do
|
171
|
+
external_key = params.require(:external_key)
|
172
|
+
|
173
|
+
begin
|
174
|
+
subscription = Kaui::Subscription.find_by_external_key(external_key, options_for_klient)
|
175
|
+
rescue KillBillClient::API::NotFound
|
176
|
+
subscription = nil
|
177
|
+
end
|
178
|
+
|
179
|
+
{ :is_found => !subscription.nil? }
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
158
183
|
def update_tags
|
159
184
|
subscription_id = params.require(:id)
|
160
185
|
subscription = Kaui::Subscription.find_by_id(subscription_id, options_for_klient)
|
@@ -197,8 +222,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
197
222
|
else
|
198
223
|
options = options_for_klient
|
199
224
|
|
200
|
-
catalog = Kaui::Catalog.get_tenant_catalog_json(
|
201
|
-
|
225
|
+
catalog = Kaui::Catalog.get_tenant_catalog_json(DateTime.now.to_s, options)
|
202
226
|
return [] if catalog.blank?
|
203
227
|
|
204
228
|
plans = []
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module Kaui
|
2
2
|
module PaymentMethodHelper
|
3
3
|
|
4
|
-
def is_json?(
|
5
|
-
|
4
|
+
def is_json?(value)
|
5
|
+
result = JSON.parse(value)
|
6
|
+
result.is_a?(Hash) || result.is_a?(Array)
|
7
|
+
rescue JSON::ParserError, TypeError
|
8
|
+
false
|
6
9
|
end
|
7
|
-
|
8
10
|
end
|
9
11
|
end
|
@@ -1,46 +1,13 @@
|
|
1
1
|
module Kaui
|
2
2
|
module PluginHelper
|
3
|
-
# including plugin that are installed
|
4
|
-
def plugin_repository
|
5
|
-
plugins = []
|
6
|
-
plugin_repository = Kaui::AdminTenant.get_plugin_repository
|
7
|
-
plugin_repository.each_pair do |key, info|
|
8
|
-
plugins << {
|
9
|
-
plugin_key: plugin_key(key.to_s, info),
|
10
|
-
plugin_name: plugin_name(key.to_s, info),
|
11
|
-
plugin_type: info[:type],
|
12
|
-
installed: false
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
installed_plugins = installed_plugins(plugins)
|
17
|
-
|
18
|
-
plugins.sort! { |a, b| a[:plugin_key] <=> b[:plugin_key] }
|
19
|
-
plugins.each { |plugin| installed_plugins << plugin }
|
20
3
|
|
4
|
+
def plugin_repository
|
21
5
|
installed_plugins
|
22
6
|
end
|
23
7
|
|
24
8
|
private
|
25
9
|
|
26
|
-
def
|
27
|
-
if info[:artifact_id].nil?
|
28
|
-
"killbill-#{key}"
|
29
|
-
else
|
30
|
-
"killbill-#{info[:artifact_id].gsub('killbill-','').gsub('-plugin','')}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def plugin_key(key, info)
|
35
|
-
# hack:: replace paypal key with paypal_express, to set configuration and allow the ui to find the right configuration inputs
|
36
|
-
if key.eql?('paypal')
|
37
|
-
'paypal_express'
|
38
|
-
else
|
39
|
-
"#{key}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def installed_plugins(plugins)
|
10
|
+
def installed_plugins
|
44
11
|
installed_plugins = []
|
45
12
|
nodes_info = KillBillClient::Model::NodesInfo.nodes_info(Kaui.current_tenant_user_options(current_user, session)) || []
|
46
13
|
plugins_info = nodes_info.first.plugins_info || []
|
@@ -49,11 +16,15 @@ module Kaui
|
|
49
16
|
next if plugin.version.nil?
|
50
17
|
# do not allow duplicate
|
51
18
|
next if installed_plugins.any? { |p| p[:plugin_name].eql?(plugin.plugin_name) }
|
52
|
-
plugin_key =
|
19
|
+
plugin_key = plugin.plugin_key
|
53
20
|
installed_plugins << {
|
21
|
+
# Unique identifier chosen by the user and used for kpm operations
|
54
22
|
plugin_key: plugin_key,
|
55
|
-
|
56
|
-
|
23
|
+
# Notes:
|
24
|
+
# * plugin.plugin_name comes from kpm and is arbitrary (see Utils.get_plugin_name_from_file_path in the kpm codebase for instance)
|
25
|
+
# * plugin_name here is the plugin name as seen by Kill Bill and is typically defined in the Activator.java (this value is the one that matters for plugin configuration)
|
26
|
+
# * The mapping here is a convention we've used over the years and is no way enforced anywhere - it likely won't work for proprietary plugins (the user would need to specify it by toggling the input on the UI)
|
27
|
+
plugin_name: "killbill-#{plugin_key}",
|
57
28
|
installed: true
|
58
29
|
}
|
59
30
|
end
|
@@ -61,15 +32,5 @@ module Kaui
|
|
61
32
|
# to_s to handle nil
|
62
33
|
installed_plugins.sort! { |a,b| a[:plugin_key].to_s <=> b[:plugin_key].to_s }
|
63
34
|
end
|
64
|
-
|
65
|
-
def find_plugin_type(plugins, plugin_key_to_search)
|
66
|
-
plugins.each do |plugin|
|
67
|
-
if plugin[:plugin_key] == plugin_key_to_search
|
68
|
-
return plugin[:plugin_type]
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
return nil
|
73
|
-
end
|
74
35
|
end
|
75
36
|
end
|
@@ -10,12 +10,12 @@ module Kaui
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def humanized_product_category(product_category)
|
13
|
-
if product_category == 'BASE'
|
13
|
+
if product_category.to_s == 'BASE'
|
14
14
|
'Base'
|
15
|
-
elsif product_category == 'ADD_ON'
|
15
|
+
elsif product_category.to_s == 'ADD_ON'
|
16
16
|
'Add-on'
|
17
17
|
else
|
18
|
-
product_category.downcase.capitalize
|
18
|
+
product_category.to_s.downcase.capitalize
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -28,7 +28,8 @@ module Kaui
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def humanized_product_name(product_name)
|
31
|
-
|
31
|
+
# Don't change the casing to avoid confusions (could lead to different products with different casing)
|
32
|
+
product_name
|
32
33
|
end
|
33
34
|
|
34
35
|
def humanized_subscription_billing_period(sub)
|
@@ -26,81 +26,21 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
|
|
26
26
|
KillBillClient::Model::Tenant.upload_tenant_plugin_config(plugin_name, plugin_config, user, reason, comment, options)
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
require 'yaml'
|
32
|
-
|
33
|
-
source = URI.parse('https://raw.githubusercontent.com/killbill/killbill-cloud/master/kpm/lib/kpm/plugins_directory.yml').read
|
34
|
-
YAML.load(source)
|
35
|
-
rescue
|
36
|
-
# Ignore gracefully
|
37
|
-
{}
|
38
|
-
end
|
39
|
-
|
40
|
-
def get_oss_plugin_info(plugin_directory)
|
41
|
-
# Serialize the plugin state for the view:
|
42
|
-
# plugin_name#plugin_type:prop1,prop2,prop3;plugin_name#plugin_type:prop1,prop2,prop3;...
|
43
|
-
#
|
44
|
-
plugin_config = plugin_directory.inject({}) do |hsh, (k,v)|
|
45
|
-
hsh["#{k}##{v[:type]}"] = v[:require] || []
|
46
|
-
hsh
|
47
|
-
end
|
48
|
-
plugin_config.map { |e,v| "#{e}:#{v.join(",")}" }.join(";")
|
49
|
-
end
|
50
|
-
|
51
|
-
def get_tenant_plugin_config(plugin_directory, options)
|
52
|
-
require 'yaml'
|
53
|
-
|
29
|
+
# Return a map of plugin_name => config
|
30
|
+
def get_tenant_plugin_config(options)
|
54
31
|
raw_tenant_config = KillBillClient::Model::Tenant::search_tenant_config("PLUGIN_CONFIG_", options)
|
55
32
|
|
56
33
|
tenant_config = raw_tenant_config.inject({}) do |hsh, e|
|
57
34
|
# Strip prefix '/PLUGIN_CONFIG_'
|
58
|
-
|
59
|
-
|
60
|
-
#
|
61
|
-
|
62
|
-
|
63
|
-
# hack:: rewrite key, to allow the ui to find the right configuration inputs
|
64
|
-
plugin_key = rewrite_plugin_key(plugin_key) unless plugin_key.nil?
|
65
|
-
# If such key exists, lookup in plugin directory to see if is an official plugin
|
66
|
-
is_an_official_plugin = !plugin_key.nil? && !plugin_directory[plugin_key.to_sym].blank?
|
67
|
-
# Deserialize config based on string possible format, if exist in the official repository
|
68
|
-
if is_an_official_plugin && is_yaml?(e.values[0])
|
69
|
-
yml = YAML.load(e.values[0])
|
70
|
-
# Hash of properties
|
71
|
-
# is plugin key part of the yaml?
|
72
|
-
if yml[plugin_key.to_sym].blank?
|
73
|
-
# if not set it as raw
|
74
|
-
hsh[plugin_key] = {:raw_config => e.values[0]}
|
75
|
-
else
|
76
|
-
hsh[plugin_key] = yml[plugin_key.to_sym]
|
77
|
-
end
|
78
|
-
hsh[plugin_key][:_raw] = e.values[0]
|
79
|
-
elsif is_an_official_plugin && is_kv?(e.values[0])
|
80
|
-
# Construct hash of properties based on java properties (k1=v1\nk2=v2\n...)
|
81
|
-
hsh[plugin_key] = e.values[0].split("\n").inject({}) do |h, p0|
|
82
|
-
k, v = p0.split('=');
|
83
|
-
h[k] = v;
|
84
|
-
h
|
85
|
-
end
|
86
|
-
hsh[plugin_key][:_raw] = e.values[0]
|
87
|
-
else
|
88
|
-
# Construct simple hash with one property :raw_config
|
89
|
-
hsh[killbill_key] = {:raw_config => e.values[0], :_raw => e.values[0]}
|
90
|
-
end
|
35
|
+
plugin_name = e.key.gsub!(/PLUGIN_CONFIG_/, '')
|
36
|
+
|
37
|
+
# Construct simple hash with one property (first value)
|
38
|
+
hsh[plugin_name] = e.values[0]
|
39
|
+
|
91
40
|
hsh
|
92
41
|
end
|
93
42
|
|
94
|
-
|
95
|
-
# plugin_key1::key1=value1|key2=value2|..;plugin_key2::...
|
96
|
-
tenant_config.map do |plugin_key, props|
|
97
|
-
serialized_props = props.inject("") do |s, (k, v)|
|
98
|
-
e="#{k.to_s}=#{v.to_s}";
|
99
|
-
s == "" ? s="#{e}" : s="#{s}|#{e}";
|
100
|
-
s
|
101
|
-
end
|
102
|
-
"#{plugin_key}::#{serialized_props}"
|
103
|
-
end.join(";")
|
43
|
+
tenant_config
|
104
44
|
end
|
105
45
|
|
106
46
|
def format_plugin_config(plugin_key, plugin_type, props)
|
@@ -142,22 +82,6 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
|
|
142
82
|
props
|
143
83
|
end
|
144
84
|
|
145
|
-
# hack when the plugin name after killbill is not the same as the plugin key, this mainly affects ruby plugin configuration,
|
146
|
-
# as it use the key to retrieve the configuration.
|
147
|
-
def rewrite_plugin_key(plugin_key)
|
148
|
-
if plugin_key.start_with?('paypal')
|
149
|
-
'paypal_express'
|
150
|
-
elsif plugin_key.start_with?('firstdata')
|
151
|
-
'firstdata_e4'
|
152
|
-
elsif plugin_key.start_with?('bridge')
|
153
|
-
'payment_bridge'
|
154
|
-
elsif plugin_key.start_with?('payu-latam')
|
155
|
-
'payu_latam'
|
156
|
-
else
|
157
|
-
"#{plugin_key}"
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
85
|
# checks if string could be parse as yaml
|
162
86
|
def is_yaml?(candidate_string)
|
163
87
|
is_yaml = false
|
data/app/models/kaui/catalog.rb
CHANGED
@@ -4,9 +4,21 @@ class Kaui::Catalog < KillBillClient::Model::Catalog
|
|
4
4
|
|
5
5
|
class << self
|
6
6
|
|
7
|
-
def
|
7
|
+
def get_tenant_catalog_json(requested_date = nil, options = {})
|
8
|
+
super
|
9
|
+
rescue ::KillBillClient::API::InternalServerError => e
|
10
|
+
if !e.response.nil? && !e.response.body.nil?
|
11
|
+
error_message = JSON.parse(e.response.body) rescue nil
|
12
|
+
raise e if error_message.nil? || error_message['message'].nil?
|
13
|
+
|
14
|
+
# Hack for lack of proper Kill Bill messaging (see https://github.com/killbill/killbill-admin-ui/issues/265)
|
15
|
+
return [] if error_message['message'].starts_with?('No existing versions')
|
16
|
+
end
|
17
|
+
raise e
|
18
|
+
end
|
8
19
|
|
9
|
-
|
20
|
+
def get_catalog_json(latest, requested_date, options)
|
21
|
+
catalogs = get_tenant_catalog_json(requested_date, options)
|
10
22
|
return catalogs.length > 0 ? catalogs[catalogs.length - 1] : nil if latest
|
11
23
|
|
12
24
|
# Order by latest
|