kaui 0.2.2 → 0.2.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.
- data/.travis.yml +1 -1
- data/Gemfile +2 -20
- data/Gemfile.lock +61 -53
- data/app/controllers/kaui/accounts_controller.rb +28 -35
- data/app/controllers/kaui/engine_controller.rb +3 -3
- data/app/controllers/kaui/payment_methods_controller.rb +19 -3
- data/app/helpers/kaui/killbill_helper.rb +56 -56
- data/app/views/kaui/payment_methods/_payment_methods_table.html.erb +39 -33
- data/app/views/kaui/payment_methods/index.html.erb +12 -11
- data/app/views/kaui/payment_methods/show.html.erb +1 -1
- data/app/views/kaui/payments/_payments_table.html.erb +1 -1
- data/config/routes.rb +1 -1
- data/kaui.gemspec +29 -17
- data/lib/kaui/engine.rb +1 -0
- data/lib/kaui/error_helper.rb +2 -2
- data/lib/kaui/version.rb +1 -1
- data/lib/kaui.rb +1 -1
- metadata +43 -22
- data/app/models/kaui/payment_method.rb +0 -36
- data/app/models/kaui/plugin_info.rb +0 -10
- data/app/models/kaui/plugin_info_property.rb +0 -5
- data/test/unit/helpers/kaui/plugin_infos_helper_test.rb +0 -20
- data/test/unit/kaui/payment_method_test.rb +0 -26
- data/test/unit/kaui/plugin_info_property_test.rb +0 -20
- data/test/unit/kaui/plugin_info_test.rb +0 -19
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'http://rubygems.org'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
gem 'rest-client', '~> 1.6.7'
|
|
5
|
-
gem 'money-rails', '~> 0.5.0'
|
|
6
|
-
gem 'd3_rails', '~> 2.10.0'
|
|
7
|
-
|
|
8
|
-
group :development, :test do
|
|
9
|
-
# jquery-rails is used by the dummy application
|
|
10
|
-
gem "jquery-rails"
|
|
11
|
-
|
|
12
|
-
if defined?(JRUBY_VERSION)
|
|
13
|
-
gem "jruby-openssl", "~> 0.7.7"
|
|
14
|
-
|
|
15
|
-
gem 'activerecord-jdbc-adapter', '~> 1.2.2'
|
|
16
|
-
gem 'activerecord-jdbcmysql-adapter', '~> 1.2.2'
|
|
17
|
-
gem 'jdbc-mysql', :require => false
|
|
18
|
-
else
|
|
19
|
-
gem 'mysql2'
|
|
20
|
-
end
|
|
21
|
-
end
|
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,51 +1,62 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
kaui (0.2.3)
|
|
5
|
+
d3_rails (~> 2.10.3)
|
|
6
|
+
jquery-rails (~> 2.0)
|
|
7
|
+
killbill-client (~> 0.1.1)
|
|
8
|
+
money-rails (~> 0.5.0)
|
|
9
|
+
rails (~> 3.2.3)
|
|
10
|
+
rest-client (~> 1.6.7)
|
|
11
|
+
|
|
1
12
|
GEM
|
|
2
13
|
remote: http://rubygems.org/
|
|
3
14
|
specs:
|
|
4
|
-
actionmailer (3.2.
|
|
5
|
-
actionpack (= 3.2.
|
|
15
|
+
actionmailer (3.2.9)
|
|
16
|
+
actionpack (= 3.2.9)
|
|
6
17
|
mail (~> 2.4.4)
|
|
7
|
-
actionpack (3.2.
|
|
8
|
-
activemodel (= 3.2.
|
|
9
|
-
activesupport (= 3.2.
|
|
18
|
+
actionpack (3.2.9)
|
|
19
|
+
activemodel (= 3.2.9)
|
|
20
|
+
activesupport (= 3.2.9)
|
|
10
21
|
builder (~> 3.0.0)
|
|
11
22
|
erubis (~> 2.7.0)
|
|
12
|
-
journey (~> 1.0.
|
|
23
|
+
journey (~> 1.0.4)
|
|
13
24
|
rack (~> 1.4.0)
|
|
14
25
|
rack-cache (~> 1.2)
|
|
15
26
|
rack-test (~> 0.6.1)
|
|
16
|
-
sprockets (~> 2.1
|
|
17
|
-
activemodel (3.2.
|
|
18
|
-
activesupport (= 3.2.
|
|
27
|
+
sprockets (~> 2.2.1)
|
|
28
|
+
activemodel (3.2.9)
|
|
29
|
+
activesupport (= 3.2.9)
|
|
19
30
|
builder (~> 3.0.0)
|
|
20
|
-
activerecord (3.2.
|
|
21
|
-
activemodel (= 3.2.
|
|
22
|
-
activesupport (= 3.2.
|
|
31
|
+
activerecord (3.2.9)
|
|
32
|
+
activemodel (= 3.2.9)
|
|
33
|
+
activesupport (= 3.2.9)
|
|
23
34
|
arel (~> 3.0.2)
|
|
24
35
|
tzinfo (~> 0.3.29)
|
|
25
|
-
activeresource (3.2.
|
|
26
|
-
activemodel (= 3.2.
|
|
27
|
-
activesupport (= 3.2.
|
|
28
|
-
activesupport (3.2.
|
|
36
|
+
activeresource (3.2.9)
|
|
37
|
+
activemodel (= 3.2.9)
|
|
38
|
+
activesupport (= 3.2.9)
|
|
39
|
+
activesupport (3.2.9)
|
|
29
40
|
i18n (~> 0.6)
|
|
30
41
|
multi_json (~> 1.0)
|
|
31
42
|
arel (3.0.2)
|
|
32
|
-
builder (3.0.
|
|
33
|
-
d3_rails (2.10.
|
|
43
|
+
builder (3.0.4)
|
|
44
|
+
d3_rails (2.10.3)
|
|
34
45
|
railties (>= 3.1.0)
|
|
35
46
|
erubis (2.7.0)
|
|
36
47
|
hike (1.2.1)
|
|
37
|
-
i18n (0.6.
|
|
38
|
-
journey (1.0.
|
|
39
|
-
jquery-rails (2.0
|
|
40
|
-
railties (>= 3.
|
|
41
|
-
thor (
|
|
42
|
-
json (1.
|
|
43
|
-
|
|
48
|
+
i18n (0.6.4)
|
|
49
|
+
journey (1.0.4)
|
|
50
|
+
jquery-rails (2.2.0)
|
|
51
|
+
railties (>= 3.0, < 5.0)
|
|
52
|
+
thor (>= 0.14, < 2.0)
|
|
53
|
+
json (1.8.0)
|
|
54
|
+
killbill-client (0.1.1)
|
|
44
55
|
mail (2.4.4)
|
|
45
56
|
i18n (>= 0.4.0)
|
|
46
57
|
mime-types (~> 1.16)
|
|
47
58
|
treetop (~> 1.4.8)
|
|
48
|
-
mime-types (1.
|
|
59
|
+
mime-types (1.23)
|
|
49
60
|
money (5.0.0)
|
|
50
61
|
i18n (~> 0.4)
|
|
51
62
|
json
|
|
@@ -53,55 +64,52 @@ GEM
|
|
|
53
64
|
activesupport (~> 3.0)
|
|
54
65
|
money (~> 5.0.0)
|
|
55
66
|
railties (~> 3.0)
|
|
56
|
-
multi_json (1.
|
|
67
|
+
multi_json (1.7.4)
|
|
57
68
|
mysql2 (0.3.11)
|
|
58
69
|
polyglot (0.3.3)
|
|
59
|
-
rack (1.4.
|
|
70
|
+
rack (1.4.5)
|
|
60
71
|
rack-cache (1.2)
|
|
61
72
|
rack (>= 0.4)
|
|
62
|
-
rack-ssl (1.3.
|
|
73
|
+
rack-ssl (1.3.3)
|
|
63
74
|
rack
|
|
64
|
-
rack-test (0.6.
|
|
75
|
+
rack-test (0.6.2)
|
|
65
76
|
rack (>= 1.0)
|
|
66
|
-
rails (3.2.
|
|
67
|
-
actionmailer (= 3.2.
|
|
68
|
-
actionpack (= 3.2.
|
|
69
|
-
activerecord (= 3.2.
|
|
70
|
-
activeresource (= 3.2.
|
|
71
|
-
activesupport (= 3.2.
|
|
77
|
+
rails (3.2.9)
|
|
78
|
+
actionmailer (= 3.2.9)
|
|
79
|
+
actionpack (= 3.2.9)
|
|
80
|
+
activerecord (= 3.2.9)
|
|
81
|
+
activeresource (= 3.2.9)
|
|
82
|
+
activesupport (= 3.2.9)
|
|
72
83
|
bundler (~> 1.0)
|
|
73
|
-
railties (= 3.2.
|
|
74
|
-
railties (3.2.
|
|
75
|
-
actionpack (= 3.2.
|
|
76
|
-
activesupport (= 3.2.
|
|
84
|
+
railties (= 3.2.9)
|
|
85
|
+
railties (3.2.9)
|
|
86
|
+
actionpack (= 3.2.9)
|
|
87
|
+
activesupport (= 3.2.9)
|
|
77
88
|
rack-ssl (~> 1.3.2)
|
|
78
89
|
rake (>= 0.8.7)
|
|
79
90
|
rdoc (~> 3.4)
|
|
80
|
-
thor (
|
|
81
|
-
rake (0.
|
|
82
|
-
rdoc (3.12)
|
|
91
|
+
thor (>= 0.14.6, < 2.0)
|
|
92
|
+
rake (10.0.4)
|
|
93
|
+
rdoc (3.12.2)
|
|
83
94
|
json (~> 1.4)
|
|
84
95
|
rest-client (1.6.7)
|
|
85
96
|
mime-types (>= 1.16)
|
|
86
|
-
sprockets (2.
|
|
97
|
+
sprockets (2.2.2)
|
|
87
98
|
hike (~> 1.2)
|
|
99
|
+
multi_json (~> 1.0)
|
|
88
100
|
rack (~> 1.0)
|
|
89
101
|
tilt (~> 1.1, != 1.3.0)
|
|
90
|
-
thor (0.
|
|
91
|
-
tilt (1.
|
|
92
|
-
treetop (1.4.
|
|
102
|
+
thor (0.18.1)
|
|
103
|
+
tilt (1.4.1)
|
|
104
|
+
treetop (1.4.12)
|
|
93
105
|
polyglot
|
|
94
106
|
polyglot (>= 0.3.1)
|
|
95
|
-
tzinfo (0.3.
|
|
107
|
+
tzinfo (0.3.37)
|
|
96
108
|
|
|
97
109
|
PLATFORMS
|
|
98
110
|
java
|
|
99
111
|
ruby
|
|
100
112
|
|
|
101
113
|
DEPENDENCIES
|
|
102
|
-
|
|
103
|
-
jquery-rails
|
|
104
|
-
money-rails (~> 0.5.0)
|
|
114
|
+
kaui!
|
|
105
115
|
mysql2
|
|
106
|
-
rails (~> 3.2.3)
|
|
107
|
-
rest-client (~> 1.6.7)
|
|
@@ -86,11 +86,8 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
|
86
86
|
|
|
87
87
|
def do_add_payment_method
|
|
88
88
|
account_id = params[:id]
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
rescue => e
|
|
92
|
-
flash[:error] = "Error while adding payment method: #{as_string(e)}"
|
|
93
|
-
end
|
|
89
|
+
# Needed in the failure case scenario
|
|
90
|
+
@account = Kaui::KillbillHelper::get_account(account_id)
|
|
94
91
|
|
|
95
92
|
# Implementation example using standard credit card fields
|
|
96
93
|
@card_type = params[:card_type]
|
|
@@ -108,35 +105,31 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
|
108
105
|
@reason = params[:reason]
|
|
109
106
|
@comment = params[:comment]
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
'pluginName' => Kaui.creditcard_plugin_name.call,
|
|
128
|
-
'pluginInfo' => plugin_info)
|
|
108
|
+
payment_method = KillBillClient::Model::PaymentMethod.new
|
|
109
|
+
payment_method.account_id = account_id
|
|
110
|
+
payment_method.plugin_name = params[:plugin_name] || Kaui.creditcard_plugin_name.call
|
|
111
|
+
payment_method.plugin_info = {
|
|
112
|
+
'type' => 'CreditCard',
|
|
113
|
+
'cardType' => @card_type,
|
|
114
|
+
'cardHolderName' => @card_holder_name,
|
|
115
|
+
'expirationDate' => "#{@expiration_year}-#{@expiration_month}",
|
|
116
|
+
'maskNumber' => @credit_card_number,
|
|
117
|
+
'address1' => @address1,
|
|
118
|
+
'address2' => @address2,
|
|
119
|
+
'city' => @city,
|
|
120
|
+
'country' => @country,
|
|
121
|
+
'postalCode' => @postal_code,
|
|
122
|
+
'state' => @state
|
|
123
|
+
}
|
|
129
124
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
end
|
|
125
|
+
begin
|
|
126
|
+
Kaui::KillbillHelper::add_payment_method(@is_default == 1, payment_method, current_user, @reason, @comment)
|
|
127
|
+
flash[:info] = 'Payment method created'
|
|
128
|
+
redirect_to kaui_engine.account_timeline_path(account_id)
|
|
129
|
+
rescue => e
|
|
130
|
+
flash[:error] = "Error while adding payment method: #{as_string(e)}"
|
|
131
|
+
render "kaui/payment_methods/new"
|
|
138
132
|
end
|
|
139
|
-
render "kaui/payment_methods/new"
|
|
140
133
|
end
|
|
141
134
|
|
|
142
135
|
def set_default_payment_method
|
|
@@ -144,12 +137,12 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
|
144
137
|
@payment_method_id = params[:payment_method_id]
|
|
145
138
|
if @account_id.present? && @payment_method_id.present?
|
|
146
139
|
begin
|
|
147
|
-
@payment_methods = Kaui::KillbillHelper::set_payment_method_as_default(@account_id, @payment_method_id)
|
|
140
|
+
@payment_methods = Kaui::KillbillHelper::set_payment_method_as_default(@account_id, @payment_method_id, current_user, params[:reason], params[:comment])
|
|
148
141
|
rescue => e
|
|
149
|
-
flash[:error] = "Error while setting payment method as default #{
|
|
142
|
+
flash[:error] = "Error while setting payment method as default #{@payment_method_id}: #{as_string(e)}"
|
|
150
143
|
end
|
|
151
144
|
else
|
|
152
|
-
flash[:notice] =
|
|
145
|
+
flash[:notice] = 'No account_id or payment_method_id given'
|
|
153
146
|
end
|
|
154
147
|
redirect_to :back
|
|
155
148
|
end
|
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
require 'kaui/killbill_helper'
|
|
2
2
|
|
|
3
3
|
class Kaui::PaymentMethodsController < Kaui::EngineController
|
|
4
|
+
def index
|
|
5
|
+
if params[:account_id]
|
|
6
|
+
begin
|
|
7
|
+
@payment_methods = Kaui::KillbillHelper.get_payment_methods params[:account_id]
|
|
8
|
+
render :show
|
|
9
|
+
rescue => e
|
|
10
|
+
flash.now[:error] = "Error while retrieving payment method for account #{params[:id]}: #{as_string(e)}"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
4
15
|
def show
|
|
5
|
-
|
|
16
|
+
@payment_methods = []
|
|
17
|
+
begin
|
|
18
|
+
@payment_methods << Kaui::KillbillHelper.get_payment_method(params[:id])
|
|
19
|
+
rescue => e
|
|
20
|
+
flash.now[:error] = "Error while retrieving payment method #{params[:id]}: #{as_string(e)}"
|
|
21
|
+
end
|
|
6
22
|
end
|
|
7
23
|
|
|
8
24
|
def destroy
|
|
9
25
|
payment_method_id = params[:id]
|
|
10
26
|
if payment_method_id.present?
|
|
11
27
|
begin
|
|
12
|
-
Kaui::KillbillHelper.delete_payment_method(payment_method_id, params[:set_auto_pay_off])
|
|
28
|
+
Kaui::KillbillHelper.delete_payment_method(payment_method_id, params[:set_auto_pay_off], current_user, params[:reason], params[:comment])
|
|
13
29
|
rescue => e
|
|
14
30
|
flash[:error] = "Error while deleting payment method #{payment_method_id}: #{as_string(e)}"
|
|
15
31
|
end
|
|
16
32
|
else
|
|
17
|
-
flash[:notice] =
|
|
33
|
+
flash[:notice] = 'Did not get the payment method id'
|
|
18
34
|
end
|
|
19
35
|
redirect_to :back
|
|
20
36
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'killbill_client'
|
|
2
|
+
|
|
1
3
|
module Kaui
|
|
2
4
|
module KillbillHelper
|
|
3
5
|
|
|
@@ -6,7 +8,7 @@ module Kaui
|
|
|
6
8
|
Rails.logger.info "Performing #{method} request to #{url}"
|
|
7
9
|
begin
|
|
8
10
|
response = RestClient.send(method.to_sym, url, *args)
|
|
9
|
-
data = {
|
|
11
|
+
data = {:code => response.code}
|
|
10
12
|
if response.code < 300 && response.body.present?
|
|
11
13
|
if response.headers[:content_type] =~ /application\/json.*/
|
|
12
14
|
data[:json] = JSON.parse(response.body)
|
|
@@ -25,7 +27,7 @@ module Kaui
|
|
|
25
27
|
if response.nil? || response[:json].nil?
|
|
26
28
|
arity == :single ? nil : []
|
|
27
29
|
elsif block_given?
|
|
28
|
-
arity == :single ? yield(response[:json]) : response[:json].collect {|item| yield(item) }
|
|
30
|
+
arity == :single ? yield(response[:json]) : response[:json].collect { |item| yield(item) }
|
|
29
31
|
else
|
|
30
32
|
response[:json]
|
|
31
33
|
end
|
|
@@ -52,17 +54,17 @@ module Kaui
|
|
|
52
54
|
|
|
53
55
|
def self.get_account_timeline(account_id)
|
|
54
56
|
data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/timeline?audit=MINIMAL"
|
|
55
|
-
process_response(data, :single) {|json| Kaui::AccountTimeline.new(json) }
|
|
57
|
+
process_response(data, :single) { |json| Kaui::AccountTimeline.new(json) }
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
def self.get_account(account_id, with_balance = false, with_balance_and_cba = false)
|
|
59
61
|
data = call_killbill :get, "/1.0/kb/accounts/#{account_id}?accountWithBalance=#{with_balance}&accountWithBalanceAndCBA=#{with_balance_and_cba}"
|
|
60
|
-
process_response(data, :single) {|json| Kaui::Account.new(json) }
|
|
62
|
+
process_response(data, :single) { |json| Kaui::Account.new(json) }
|
|
61
63
|
end
|
|
62
64
|
|
|
63
65
|
def self.get_account_by_external_key(external_key, with_balance = false, with_balance_and_cba = false)
|
|
64
66
|
data = call_killbill :get, "/1.0/kb/accounts?externalKey=#{external_key}&accountWithBalance=#{with_balance}&accountWithBalanceAndCBA=#{with_balance_and_cba}"
|
|
65
|
-
process_response(data, :single) {|json| Kaui::Account.new(json) }
|
|
67
|
+
process_response(data, :single) { |json| Kaui::Account.new(json) }
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def self.get_account_by_bundle_id(bundle_id)
|
|
@@ -95,7 +97,7 @@ module Kaui
|
|
|
95
97
|
end
|
|
96
98
|
|
|
97
99
|
def self.update_email_notifications(account_id, is_notified, current_user = nil, reason = nil, comment = nil)
|
|
98
|
-
email_data = {
|
|
100
|
+
email_data = {:isNotifiedForInvoices => is_notified}
|
|
99
101
|
call_killbill :put,
|
|
100
102
|
"/1.0/kb/accounts/#{account_id}/emailNotifications",
|
|
101
103
|
ActiveSupport::JSON.encode(email_data, :root => false),
|
|
@@ -118,17 +120,17 @@ module Kaui
|
|
|
118
120
|
|
|
119
121
|
def self.get_bundles(account_id)
|
|
120
122
|
data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/bundles"
|
|
121
|
-
process_response(data, :multiple) {|json| Kaui::Bundle.new(json) }
|
|
123
|
+
process_response(data, :multiple) { |json| Kaui::Bundle.new(json) }
|
|
122
124
|
end
|
|
123
125
|
|
|
124
126
|
def self.get_bundle_by_external_key(account_id, external_key)
|
|
125
127
|
data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/bundles?externalKey=#{external_key}"
|
|
126
|
-
process_response(data, :single) {|json| Kaui::Bundle.new(json) }
|
|
128
|
+
process_response(data, :single) { |json| Kaui::Bundle.new(json) }
|
|
127
129
|
end
|
|
128
130
|
|
|
129
131
|
def self.get_bundle(bundle_id)
|
|
130
132
|
data = call_killbill :get, "/1.0/kb/bundles/#{bundle_id}"
|
|
131
|
-
process_response(data, :single) {|json| Kaui::Bundle.new(json) }
|
|
133
|
+
process_response(data, :single) { |json| Kaui::Bundle.new(json) }
|
|
132
134
|
end
|
|
133
135
|
|
|
134
136
|
def self.transfer_bundle(bundle_id, new_account_id, cancel_immediately = false, transfer_addons = true, current_user = nil, reason = nil, comment = nil)
|
|
@@ -145,7 +147,7 @@ module Kaui
|
|
|
145
147
|
|
|
146
148
|
def self.get_subscriptions_for_bundle(bundle_id)
|
|
147
149
|
data = call_killbill :get, "/1.0/kb/bundles/#{bundle_id}/subscriptions"
|
|
148
|
-
process_response(data, :multiple) {|json| Kaui::Subscription.new(json) }
|
|
150
|
+
process_response(data, :multiple) { |json| Kaui::Subscription.new(json) }
|
|
149
151
|
end
|
|
150
152
|
|
|
151
153
|
def self.get_subscriptions(account_id)
|
|
@@ -159,7 +161,7 @@ module Kaui
|
|
|
159
161
|
|
|
160
162
|
def self.get_subscription(subscription_id)
|
|
161
163
|
data = call_killbill :get, "/1.0/kb/subscriptions/#{subscription_id}"
|
|
162
|
-
process_response(data, :single) {|json| Kaui::Subscription.new(json) }
|
|
164
|
+
process_response(data, :single) { |json| Kaui::Subscription.new(json) }
|
|
163
165
|
end
|
|
164
166
|
|
|
165
167
|
def self.create_subscription(subscription, current_user = nil, reason = nil, comment = nil)
|
|
@@ -235,7 +237,7 @@ module Kaui
|
|
|
235
237
|
|
|
236
238
|
def self.get_invoice(invoice_id)
|
|
237
239
|
data = call_killbill :get, "/1.0/kb/invoices/#{invoice_id}?withItems=true"
|
|
238
|
-
process_response(data, :single) {|json| Kaui::Invoice.new(json) }
|
|
240
|
+
process_response(data, :single) { |json| Kaui::Invoice.new(json) }
|
|
239
241
|
end
|
|
240
242
|
|
|
241
243
|
def self.get_invoice_item(invoice_id, invoice_item_id)
|
|
@@ -307,14 +309,14 @@ module Kaui
|
|
|
307
309
|
def self.get_available_addons(base_product_name)
|
|
308
310
|
data = call_killbill :get, "/1.0/kb/catalog/availableAddons?baseProductName=#{base_product_name}"
|
|
309
311
|
if data.has_key?(:json)
|
|
310
|
-
data[:json].inject({}) {|catalog_hash, item| catalog_hash.merge!(item["planName"] => item) }
|
|
312
|
+
data[:json].inject({}) { |catalog_hash, item| catalog_hash.merge!(item["planName"] => item) }
|
|
311
313
|
end
|
|
312
314
|
end
|
|
313
315
|
|
|
314
316
|
def self.get_available_base_plans()
|
|
315
317
|
data = call_killbill :get, "/1.0/kb/catalog/availableBasePlans"
|
|
316
318
|
if data.has_key?(:json)
|
|
317
|
-
data[:json].inject({}) {|catalog_hash, item| catalog_hash.merge!(item["planName"] => item) }
|
|
319
|
+
data[:json].inject({}) { |catalog_hash, item| catalog_hash.merge!(item["planName"] => item) }
|
|
318
320
|
end
|
|
319
321
|
end
|
|
320
322
|
|
|
@@ -327,18 +329,18 @@ module Kaui
|
|
|
327
329
|
|
|
328
330
|
def self.get_payments(invoice_id)
|
|
329
331
|
data = call_killbill :get, "/1.0/kb/invoices/#{invoice_id}/payments"
|
|
330
|
-
response_data = process_response(data, :multiple) {|json| Kaui::Payment.new(json) }
|
|
332
|
+
response_data = process_response(data, :multiple) { |json| Kaui::Payment.new(json) }
|
|
331
333
|
return response_data
|
|
332
334
|
end
|
|
333
335
|
|
|
334
336
|
def self.pay_all_invoices(account_id, external = false, current_user = nil, reason = nil, comment = nil)
|
|
335
337
|
call_killbill :post,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
338
|
+
"/1.0/kb/invoices/payments?externalPayment=#{external}",
|
|
339
|
+
ActiveSupport::JSON.encode({:accountId => account_id}, :root => false),
|
|
340
|
+
:content_type => "application/json",
|
|
341
|
+
"X-Killbill-CreatedBy" => current_user,
|
|
342
|
+
"X-Killbill-Reason" => extract_reason_code(reason),
|
|
343
|
+
"X-Killbill-Comment" => "#{comment}"
|
|
342
344
|
end
|
|
343
345
|
|
|
344
346
|
def self.create_payment(payment, external, current_user = nil, reason = nil, comment = nil)
|
|
@@ -351,24 +353,19 @@ module Kaui
|
|
|
351
353
|
payment_data.delete(:chargebacks)
|
|
352
354
|
payment_data.delete(:audit_logs)
|
|
353
355
|
call_killbill :post,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
"/1.0/kb/invoices/#{payment.invoice_id}/payments?externalPayment=#{external}",
|
|
357
|
+
ActiveSupport::JSON.encode(payment_data, :root => false),
|
|
358
|
+
:content_type => "application/json",
|
|
359
|
+
"X-Killbill-CreatedBy" => current_user,
|
|
360
|
+
"X-Killbill-Reason" => extract_reason_code(reason),
|
|
361
|
+
"X-Killbill-Comment" => "#{comment}"
|
|
360
362
|
end
|
|
361
363
|
end
|
|
362
364
|
|
|
363
365
|
############## PAYMENT METHOD ##############
|
|
364
366
|
|
|
365
|
-
def self.delete_payment_method(payment_method_id, set_auto_pay_off = false,
|
|
366
|
-
|
|
367
|
-
call_killbill :delete,
|
|
368
|
-
"/1.0/kb/paymentMethods/#{payment_method_id}#{set_auto_pay_off_param}",
|
|
369
|
-
"X-Killbill-CreatedBy" => current_user,
|
|
370
|
-
"X-Killbill-Reason" => "#{reason}",
|
|
371
|
-
"X-Killbill-Comment" => "#{comment}"
|
|
367
|
+
def self.delete_payment_method(payment_method_id, set_auto_pay_off = false, current_user = nil, reason = nil, comment = nil)
|
|
368
|
+
KillBillClient::Model::PaymentMethod.destroy payment_method_id, set_auto_pay_off, current_user, reason, comment
|
|
372
369
|
end
|
|
373
370
|
|
|
374
371
|
def self.get_non_external_payment_methods(account_id)
|
|
@@ -376,34 +373,19 @@ module Kaui
|
|
|
376
373
|
end
|
|
377
374
|
|
|
378
375
|
def self.get_payment_methods(account_id)
|
|
379
|
-
|
|
380
|
-
process_response(data, :multiple) {|json| Kaui::PaymentMethod.new(json) }
|
|
376
|
+
KillBillClient::Model::PaymentMethod.find_all_by_account_id account_id, true
|
|
381
377
|
end
|
|
382
378
|
|
|
383
379
|
def self.get_payment_method(payment_method_id)
|
|
384
|
-
|
|
385
|
-
process_response(data, :single) {|json| Kaui::PaymentMethod.new(json) }
|
|
380
|
+
KillBillClient::Model::PaymentMethod.find_by_id payment_method_id, true
|
|
386
381
|
end
|
|
387
382
|
|
|
388
383
|
def self.set_payment_method_as_default(account_id, payment_method_id, current_user = nil, reason = nil, comment = nil)
|
|
389
|
-
|
|
390
|
-
"/1.0/kb/accounts/#{account_id}/paymentMethods/#{payment_method_id}/setDefault",
|
|
391
|
-
"",
|
|
392
|
-
:content_type => :json,
|
|
393
|
-
"X-Killbill-CreatedBy" => current_user,
|
|
394
|
-
"X-Killbill-Reason" => extract_reason_code(reason),
|
|
395
|
-
"X-Killbill-Comment" => "#{comment}"
|
|
384
|
+
KillBillClient::Model::PaymentMethod.set_default payment_method_id, account_id, current_user, reason, comment
|
|
396
385
|
end
|
|
397
386
|
|
|
398
|
-
def self.add_payment_method(payment_method, current_user = nil, reason = nil, comment = nil)
|
|
399
|
-
|
|
400
|
-
call_killbill :post,
|
|
401
|
-
"/1.0/kb/accounts/#{payment_method.account_id}/paymentMethods?isDefault=#{payment_method.is_default}",
|
|
402
|
-
ActiveSupport::JSON.encode(payment_method_data, :root => false),
|
|
403
|
-
:content_type => :json,
|
|
404
|
-
"X-Killbill-CreatedBy" => current_user,
|
|
405
|
-
"X-Killbill-Reason" => extract_reason_code(reason),
|
|
406
|
-
"X-Killbill-Comment" => "#{comment}"
|
|
387
|
+
def self.add_payment_method(is_default, payment_method, current_user = nil, reason = nil, comment = nil)
|
|
388
|
+
payment_method.create is_default, current_user, reason, comment
|
|
407
389
|
end
|
|
408
390
|
|
|
409
391
|
############## REFUND ##############
|
|
@@ -415,7 +397,7 @@ module Kaui
|
|
|
415
397
|
|
|
416
398
|
def self.get_refunds_for_payment(payment_id)
|
|
417
399
|
data = call_killbill :get, "/1.0/kb/payments/#{payment_id}/refunds"
|
|
418
|
-
process_response(data, :multiple) {|json| Kaui::Refund.new(json) }
|
|
400
|
+
process_response(data, :multiple) { |json| Kaui::Refund.new(json) }
|
|
419
401
|
end
|
|
420
402
|
|
|
421
403
|
def self.create_refund(payment_id, refund, current_user = nil, reason = nil, comment = nil)
|
|
@@ -436,7 +418,7 @@ module Kaui
|
|
|
436
418
|
|
|
437
419
|
def self.get_chargebacks_for_payment(payment_id)
|
|
438
420
|
data = call_killbill :get, "/1.0/kb/chargebacks/payments/#{payment_id}"
|
|
439
|
-
process_response(data, :multiple) {|json| Kaui::Chargeback.new(json) }
|
|
421
|
+
process_response(data, :multiple) { |json| Kaui::Chargeback.new(json) }
|
|
440
422
|
end
|
|
441
423
|
|
|
442
424
|
def self.create_chargeback(chargeback, current_user = nil, reason = nil, comment = nil)
|
|
@@ -580,5 +562,23 @@ module Kaui
|
|
|
580
562
|
data = call_killbill :get, "/1.0/kb/analytics/sanity"
|
|
581
563
|
process_response(data, :single) { |json| Kaui::AnalyticsSanity.new(json) }
|
|
582
564
|
end
|
|
565
|
+
|
|
566
|
+
def self.before_all
|
|
567
|
+
methods.each do |method_name|
|
|
568
|
+
method = method(method_name)
|
|
569
|
+
(
|
|
570
|
+
class << self;
|
|
571
|
+
self
|
|
572
|
+
end
|
|
573
|
+
).instance_eval {
|
|
574
|
+
define_method(method_name) do |*args, &block|
|
|
575
|
+
yield
|
|
576
|
+
method.call(*args, &block)
|
|
577
|
+
end
|
|
578
|
+
}
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
before_all { KillBillClient.url = Kaui.killbill_finder.call }
|
|
583
583
|
end
|
|
584
584
|
end
|
|
@@ -3,41 +3,47 @@
|
|
|
3
3
|
</div>
|
|
4
4
|
<table class="table table-condensed table-striped">
|
|
5
5
|
<thead>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<th>Actions</th>
|
|
14
|
-
</tr>
|
|
6
|
+
<tr>
|
|
7
|
+
<th>Plugin</th>
|
|
8
|
+
<th>External id</th>
|
|
9
|
+
<th>Plugin info</th>
|
|
10
|
+
<th>Default Method</th>
|
|
11
|
+
<th>Actions</th>
|
|
12
|
+
</tr>
|
|
15
13
|
</thead>
|
|
16
14
|
<tbody>
|
|
17
|
-
|
|
15
|
+
<% if payment_methods.present? && !payment_methods.nil? %>
|
|
18
16
|
<% payment_methods.each do |payment_method| %>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
<tr>
|
|
18
|
+
<td><%= payment_method.plugin_name %></a></td>
|
|
19
|
+
<td>
|
|
20
|
+
<%= payment_method.plugin_info.external_payment_id unless payment_method.plugin_info.blank? %>
|
|
21
|
+
</td>
|
|
22
|
+
<td>
|
|
23
|
+
<% unless payment_method.plugin_info.blank? and payment_method.plugin_info.properties.blank? %>
|
|
24
|
+
<ul>
|
|
25
|
+
<% payment_method.plugin_info.properties.each do |property| %>
|
|
26
|
+
<li><%= property.key %>: <%= property.value %></li>
|
|
27
|
+
<% end %>
|
|
28
|
+
</ul>
|
|
29
|
+
<% end %>
|
|
30
|
+
</td>
|
|
31
|
+
<td>
|
|
32
|
+
<% if payment_method.is_default %>
|
|
33
|
+
<i class="icon-ok"></i>
|
|
34
|
+
<% else %>
|
|
35
|
+
<%= link_to "Make Default", kaui_engine.set_default_payment_method_account_path(payment_method.account_id, :params => {:payment_method_id => payment_method.payment_method_id}), :method => :put, :confirm => "Are you sure you want to make this payment method default?", :class => "btn btn-mini" %>
|
|
36
|
+
<% end %>
|
|
37
|
+
</td>
|
|
38
|
+
<td>
|
|
39
|
+
<% if payment_method.is_default %>
|
|
40
|
+
<%= link_to "Delete", kaui_engine.payment_method_path(payment_method.payment_method_id, :params => {:set_auto_pay_off => "true"}), :method => :delete, :confirm => "Are you sure you want to delete this payment method?", :class => "btn btn-mini" %>
|
|
41
|
+
<% else %>
|
|
42
|
+
<%= link_to "Delete", kaui_engine.payment_method_path(payment_method.payment_method_id), :method => :delete, :confirm => "Are you sure you want to delete this payment method?", :class => "btn btn-mini" %>
|
|
43
|
+
<% end %>
|
|
44
|
+
</td>
|
|
45
|
+
</tr>
|
|
40
46
|
<% end %>
|
|
41
|
-
|
|
47
|
+
<% end %>
|
|
42
48
|
</tbody>
|
|
43
|
-
</table>
|
|
49
|
+
</table>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<%= form_tag payment_methods_path, :class => "form-horizontal", :method => :get do %>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<fieldset>
|
|
3
|
+
<legend>Please enter account id</legend>
|
|
4
|
+
<div class="control-group">
|
|
5
|
+
<label class="control-label" for="account_id">Account</label>
|
|
6
|
+
|
|
7
|
+
<div class="controls">
|
|
8
|
+
<%= text_field_tag 'account_id', nil, :class => "input-xlarge", :id => "account_id" %>
|
|
9
|
+
</div>
|
|
8
10
|
</div>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
</fieldset>
|
|
11
|
+
<div class="form-actions">
|
|
12
|
+
<%= button_tag "Search", :class => "btn btn-primary" %>
|
|
13
|
+
</div>
|
|
14
|
+
</fieldset>
|
|
14
15
|
<% end %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= render :partial => 'payment_methods_table' %>
|
|
1
|
+
<%= render :partial => 'payment_methods_table', :locals => {:payment_methods => @payment_methods} %>
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<td><%= format_date(payment.effective_date, @account.timezone).html_safe if payment.effective_date.present? %></td>
|
|
23
23
|
<td><%= humanized_money_with_symbol payment.amount_to_money %> (<%= payment.currency %>)</td>
|
|
24
24
|
<td><%= humanized_money_with_symbol payment.paid_amount_to_money %> (<%= payment.currency %>)</td>
|
|
25
|
-
<td><%= "#{@payment_methods[payment.payment_id].type} #{@payment_methods[payment.payment_id].
|
|
25
|
+
<td><%= "#{@payment_methods[payment.payment_id].plugin_info.type} #{@payment_methods[payment.payment_id].plugin_info.cc_type} #{@payment_methods[payment.payment_id].plugin_info.cc_last4}" if @payment_methods.present? and @payment_methods[payment.payment_id].present? and @payment_methods[payment.payment_id].plugin_info.present? %></td>
|
|
26
26
|
<td><%= payment.ext_first_payment_id_ref %> <%= " / " if payment.ext_second_payment_id_ref.present? %> <%= payment.ext_second_payment_id_ref %></td>
|
|
27
27
|
<td><%= payment.retry_count %></td>
|
|
28
28
|
<td><%= payment.status %> <%= payment.gateway_error_code unless payment.status == 'SUCCESS' %> <%= payment.gateway_error_msg %></td>
|
data/config/routes.rb
CHANGED
|
@@ -37,7 +37,7 @@ Kaui::Engine.routes.draw do
|
|
|
37
37
|
|
|
38
38
|
resources :payments, :only => [ :create, :new, :index, :show ]
|
|
39
39
|
|
|
40
|
-
resources :payment_methods, :only => [ :show, :destroy ]
|
|
40
|
+
resources :payment_methods, :only => [ :index, :show, :destroy ]
|
|
41
41
|
|
|
42
42
|
resources :refunds, :only => [ :index, :show, :create, :new ]
|
|
43
43
|
|
data/kaui.gemspec
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require "kaui/version"
|
|
3
|
+
require 'kaui/version'
|
|
5
4
|
|
|
6
|
-
# Describe your gem and declare its dependencies:
|
|
7
5
|
Gem::Specification.new do |s|
|
|
8
|
-
s.name
|
|
9
|
-
s.version
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
12
|
-
|
|
13
|
-
s.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
s.
|
|
18
|
-
s.
|
|
19
|
-
s.
|
|
20
|
-
|
|
6
|
+
s.name = 'kaui'
|
|
7
|
+
s.version = Kaui::VERSION
|
|
8
|
+
s.summary = 'Killbill Admin UI plugin'
|
|
9
|
+
s.description = 'Rails UI plugin for Killbill administration.'
|
|
10
|
+
|
|
11
|
+
s.required_ruby_version = '>= 1.8.7'
|
|
12
|
+
|
|
13
|
+
s.license = 'Apache License (2.0)'
|
|
14
|
+
|
|
15
|
+
s.author = 'Killbill core team'
|
|
16
|
+
s.email = 'killbilling-users@googlegroups.com'
|
|
17
|
+
s.homepage = 'http://www.killbilling.org'
|
|
18
|
+
|
|
19
|
+
s.files = `git ls-files`.split("\n")
|
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
21
|
+
s.bindir = 'bin'
|
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
23
|
+
s.require_paths = %w(lib)
|
|
21
24
|
|
|
22
25
|
s.add_dependency 'rails', '~> 3.2.3'
|
|
23
26
|
s.add_dependency 'jquery-rails', '~> 2.0'
|
|
24
27
|
s.add_dependency 'rest-client', '~> 1.6.7'
|
|
25
28
|
s.add_dependency 'money-rails', '~> 0.5.0'
|
|
26
29
|
s.add_dependency 'd3_rails', '~> 2.10.3'
|
|
30
|
+
s.add_dependency 'killbill-client', '~> 0.1.1'
|
|
31
|
+
|
|
32
|
+
if defined?(JRUBY_VERSION)
|
|
33
|
+
s.add_development_dependency 'activerecord-jdbc-adapter', '~> 1.2.2'
|
|
34
|
+
s.add_development_dependency 'activerecord-jdbcmysql-adapter', '~> 1.2.2'
|
|
35
|
+
#s.add_development_dependency 'jdbc-mysql', :require => false
|
|
36
|
+
else
|
|
37
|
+
s.add_development_dependency 'mysql2'
|
|
38
|
+
end
|
|
27
39
|
end
|
data/lib/kaui/engine.rb
CHANGED
data/lib/kaui/error_helper.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require 'rest_client'
|
|
2
|
-
|
|
3
1
|
module Kaui
|
|
4
2
|
module ErrorHelper
|
|
5
3
|
def as_string(e)
|
|
6
4
|
if e.is_a?(RestClient::Exception)
|
|
7
5
|
"#{e.message} #{e.response}".split(/\n/).take(5).join("\n")
|
|
6
|
+
elsif e.is_a?(KillBillClient::API::ResponseError)
|
|
7
|
+
"Error #{e.response.code}: #{e.response.message}"
|
|
8
8
|
else
|
|
9
9
|
e.message
|
|
10
10
|
end
|
data/lib/kaui/version.rb
CHANGED
data/lib/kaui.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Kaui
|
|
|
19
19
|
self.bundle_home_path = lambda {|bundle_id| Kaui::Engine.routes.url_helpers.bundle_path(:id => bundle_id) }
|
|
20
20
|
self.invoice_home_path = lambda {|invoice_id| Kaui::Engine.routes.url_helpers.invoice_path(:id => invoice_id) }
|
|
21
21
|
self.bundle_key_display_string = lambda {|bundle_key| bundle_key }
|
|
22
|
-
self.creditcard_plugin_name = lambda {
|
|
22
|
+
self.creditcard_plugin_name = lambda { '__EXTERNAL_PAYMENT__' }
|
|
23
23
|
|
|
24
24
|
def self.config(&block)
|
|
25
25
|
# TODO
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kaui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
prerelease:
|
|
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-
|
|
12
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -91,9 +91,40 @@ dependencies:
|
|
|
91
91
|
- - ~>
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
93
|
version: 2.10.3
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: killbill-client
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
none: false
|
|
98
|
+
requirements:
|
|
99
|
+
- - ~>
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: 0.1.1
|
|
102
|
+
type: :runtime
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ~>
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 0.1.1
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: mysql2
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
none: false
|
|
114
|
+
requirements:
|
|
115
|
+
- - ! '>='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
none: false
|
|
122
|
+
requirements:
|
|
123
|
+
- - ! '>='
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
94
126
|
description: Rails UI plugin for Killbill administration.
|
|
95
|
-
email:
|
|
96
|
-
- alenad@glam.com
|
|
127
|
+
email: killbilling-users@googlegroups.com
|
|
97
128
|
executables:
|
|
98
129
|
- kaui
|
|
99
130
|
extensions: []
|
|
@@ -162,9 +193,6 @@ files:
|
|
|
162
193
|
- app/models/kaui/overdue_state.rb
|
|
163
194
|
- app/models/kaui/payment.rb
|
|
164
195
|
- app/models/kaui/payment_attempt.rb
|
|
165
|
-
- app/models/kaui/payment_method.rb
|
|
166
|
-
- app/models/kaui/plugin_info.rb
|
|
167
|
-
- app/models/kaui/plugin_info_property.rb
|
|
168
196
|
- app/models/kaui/product.rb
|
|
169
197
|
- app/models/kaui/refund.rb
|
|
170
198
|
- app/models/kaui/subscription.rb
|
|
@@ -309,7 +337,6 @@ files:
|
|
|
309
337
|
- test/unit/helpers/kaui/home_helper_test.rb
|
|
310
338
|
- test/unit/helpers/kaui/invoices_helper_test.rb
|
|
311
339
|
- test/unit/helpers/kaui/payments_helper_test.rb
|
|
312
|
-
- test/unit/helpers/kaui/plugin_infos_helper_test.rb
|
|
313
340
|
- test/unit/helpers/kaui/refunds_helper_test.rb
|
|
314
341
|
- test/unit/kaui/account_test.rb
|
|
315
342
|
- test/unit/kaui/base_test.rb
|
|
@@ -317,9 +344,6 @@ files:
|
|
|
317
344
|
- test/unit/kaui/invoice_item_test.rb
|
|
318
345
|
- test/unit/kaui/invoice_test.rb
|
|
319
346
|
- test/unit/kaui/overdue_state_test.rb
|
|
320
|
-
- test/unit/kaui/payment_method_test.rb
|
|
321
|
-
- test/unit/kaui/plugin_info_property_test.rb
|
|
322
|
-
- test/unit/kaui/plugin_info_test.rb
|
|
323
347
|
- test/unit/kaui/refund_test.rb
|
|
324
348
|
- test/unit/kaui/tag_definition_test.rb
|
|
325
349
|
- test/unit/model_test.rb
|
|
@@ -330,8 +354,9 @@ files:
|
|
|
330
354
|
- vendor/assets/javascripts/js/jquery.dataTables.v1.9.3.min.js
|
|
331
355
|
- vendor/assets/stylesheets/css/bootstrap-datepicker.cd46d38.css
|
|
332
356
|
- vendor/assets/stylesheets/css/bootstrap.v2.2.1.min.css
|
|
333
|
-
homepage:
|
|
334
|
-
licenses:
|
|
357
|
+
homepage: http://www.killbilling.org
|
|
358
|
+
licenses:
|
|
359
|
+
- Apache License (2.0)
|
|
335
360
|
post_install_message:
|
|
336
361
|
rdoc_options: []
|
|
337
362
|
require_paths:
|
|
@@ -341,16 +366,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
341
366
|
requirements:
|
|
342
367
|
- - ! '>='
|
|
343
368
|
- !ruby/object:Gem::Version
|
|
344
|
-
version:
|
|
345
|
-
segments:
|
|
346
|
-
- 0
|
|
347
|
-
hash: 451527317018567128
|
|
369
|
+
version: 1.8.7
|
|
348
370
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
349
371
|
none: false
|
|
350
372
|
requirements:
|
|
351
373
|
- - ! '>='
|
|
352
374
|
- !ruby/object:Gem::Version
|
|
353
375
|
version: '0'
|
|
376
|
+
segments:
|
|
377
|
+
- 0
|
|
378
|
+
hash: 3422084026111820071
|
|
354
379
|
requirements: []
|
|
355
380
|
rubyforge_project:
|
|
356
381
|
rubygems_version: 1.8.24
|
|
@@ -422,7 +447,6 @@ test_files:
|
|
|
422
447
|
- test/unit/helpers/kaui/home_helper_test.rb
|
|
423
448
|
- test/unit/helpers/kaui/invoices_helper_test.rb
|
|
424
449
|
- test/unit/helpers/kaui/payments_helper_test.rb
|
|
425
|
-
- test/unit/helpers/kaui/plugin_infos_helper_test.rb
|
|
426
450
|
- test/unit/helpers/kaui/refunds_helper_test.rb
|
|
427
451
|
- test/unit/kaui/account_test.rb
|
|
428
452
|
- test/unit/kaui/base_test.rb
|
|
@@ -430,9 +454,6 @@ test_files:
|
|
|
430
454
|
- test/unit/kaui/invoice_item_test.rb
|
|
431
455
|
- test/unit/kaui/invoice_test.rb
|
|
432
456
|
- test/unit/kaui/overdue_state_test.rb
|
|
433
|
-
- test/unit/kaui/payment_method_test.rb
|
|
434
|
-
- test/unit/kaui/plugin_info_property_test.rb
|
|
435
|
-
- test/unit/kaui/plugin_info_test.rb
|
|
436
457
|
- test/unit/kaui/refund_test.rb
|
|
437
458
|
- test/unit/kaui/tag_definition_test.rb
|
|
438
459
|
- test/unit/model_test.rb
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
class Kaui::PaymentMethod < Kaui::Base
|
|
2
|
-
define_attr :account_id
|
|
3
|
-
define_attr :is_default
|
|
4
|
-
define_attr :payment_method_id
|
|
5
|
-
define_attr :plugin_name
|
|
6
|
-
|
|
7
|
-
has_one :plugin_info, Kaui::PluginInfo
|
|
8
|
-
|
|
9
|
-
def card_type
|
|
10
|
-
plugin_info.property("cardType") if plugin_info.present?
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def type
|
|
14
|
-
plugin_info.property("type") if plugin_info.present?
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def mask_number
|
|
18
|
-
plugin_info.property("maskNumber") if plugin_info.present?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def card_holder_name
|
|
22
|
-
plugin_info.property("cardHolderName") if plugin_info.present?
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def expiration_dt
|
|
26
|
-
plugin_info.property("expirationDate") if plugin_info.present?
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def baid
|
|
30
|
-
plugin_info.property("baid") if plugin_info.present?
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def email
|
|
34
|
-
plugin_info.property("email") if plugin_info.present?
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
class Kaui::PluginInfo < Kaui::Base
|
|
2
|
-
define_attr :external_payment_id
|
|
3
|
-
|
|
4
|
-
has_many :properties, Kaui::PluginInfoProperty
|
|
5
|
-
|
|
6
|
-
def property(key)
|
|
7
|
-
prop = properties.find { |prop| prop.key == key } unless properties.nil?
|
|
8
|
-
prop.value unless prop.nil?
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
module Kaui::PluginInfosHelperTest
|
|
4
|
-
@@plugin_info_keys = [:accountId, :type, :cardHolderName, :cardType, :expirationDate, :maskNumber,
|
|
5
|
-
:address1, :address2, :city, :postalCode, :state, :country]
|
|
6
|
-
|
|
7
|
-
def plugin_info_properies
|
|
8
|
-
properties = []
|
|
9
|
-
@@plugin_info_keys.each do |key|
|
|
10
|
-
as_json = plugin_info_properties("plugin_info_property_#{key.to_s}".to_sym)
|
|
11
|
-
properties << Kaui::PluginInfoProperty.new(as_json).to_hash
|
|
12
|
-
end
|
|
13
|
-
properties
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def create_plugin_info(plugin_info_json)
|
|
17
|
-
plugin_info_json["properties"] = plugin_info_properies
|
|
18
|
-
Kaui::PluginInfo.new(plugin_info_json)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class Kaui::PaymentMethodTest < ActiveSupport::TestCase
|
|
4
|
-
fixtures :payment_methods, :plugin_infos, :plugin_info_properties
|
|
5
|
-
|
|
6
|
-
include Kaui::PluginInfosHelperTest
|
|
7
|
-
|
|
8
|
-
test "can serialize from json" do
|
|
9
|
-
as_json = plugin_infos(:plugin_info_for_pierre)
|
|
10
|
-
plugin_info = create_plugin_info(as_json)
|
|
11
|
-
|
|
12
|
-
as_json = payment_methods(:payment_method_for_pierre)
|
|
13
|
-
as_json["pluginInfo"] = plugin_info
|
|
14
|
-
payment_method = Kaui::PaymentMethod.new(as_json)
|
|
15
|
-
|
|
16
|
-
assert_equal as_json["accountId"], payment_method.account_id
|
|
17
|
-
assert_equal as_json["isDefault"], payment_method.is_default
|
|
18
|
-
assert_equal as_json["paymentMethodId"], payment_method.payment_method_id
|
|
19
|
-
assert_equal as_json["pluginName"], payment_method.plugin_name
|
|
20
|
-
@@plugin_info_keys.each_with_index do |key, i|
|
|
21
|
-
assert_equal plugin_info_properies[i]["key"], payment_method.plugin_info.properties[i].key
|
|
22
|
-
assert_equal plugin_info_properies[i]["value"], payment_method.plugin_info.properties[i].value
|
|
23
|
-
assert_equal plugin_info_properies[i]["is_updatable"], payment_method.plugin_info.properties[i].is_updatable
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class Kaui::PluginInfoPropertyTest < ActiveSupport::TestCase
|
|
4
|
-
fixtures :plugin_info_properties
|
|
5
|
-
|
|
6
|
-
keys = [:accountId, :type, :cardHolderName, :cardType, :expirationDate, :maskNumber,
|
|
7
|
-
:address1, :address2, :city, :postalCode, :state, :country]
|
|
8
|
-
|
|
9
|
-
test "can serialize from json" do
|
|
10
|
-
keys.each do |key|
|
|
11
|
-
as_json = plugin_info_properties("plugin_info_property_#{key.to_s}".to_sym)
|
|
12
|
-
plugin_info_property = Kaui::PluginInfoProperty.new(as_json)
|
|
13
|
-
|
|
14
|
-
assert_equal as_json["isUpdatable"], plugin_info_property.is_updatable
|
|
15
|
-
assert_equal as_json["key"], plugin_info_property.key
|
|
16
|
-
assert_equal key.to_s, plugin_info_property.key
|
|
17
|
-
assert_equal as_json["value"], plugin_info_property.value
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class Kaui::PluginInfoTest < ActiveSupport::TestCase
|
|
4
|
-
fixtures :plugin_infos, :plugin_info_properties
|
|
5
|
-
|
|
6
|
-
include Kaui::PluginInfosHelperTest
|
|
7
|
-
|
|
8
|
-
test "can serialize from json" do
|
|
9
|
-
as_json = plugin_infos(:plugin_info_for_pierre)
|
|
10
|
-
plugin_info = create_plugin_info(as_json)
|
|
11
|
-
|
|
12
|
-
assert_equal as_json["externalPaymentId"], plugin_info.external_payment_id
|
|
13
|
-
@@plugin_info_keys.each_with_index do |key, i|
|
|
14
|
-
assert_equal plugin_info_properies[i]["key"], plugin_info.properties[i].key
|
|
15
|
-
assert_equal plugin_info_properies[i]["value"], plugin_info.properties[i].value
|
|
16
|
-
assert_equal plugin_info_properies[i]["is_updatable"], plugin_info.properties[i].is_updatable
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|