killbill 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Jarfile +5 -5
  4. data/NEWS +4 -0
  5. data/README.md +45 -8
  6. data/VERSION +1 -1
  7. data/generators/active_merchant/active_merchant_generator.rb +38 -0
  8. data/generators/active_merchant/templates/.gitignore.rb +36 -0
  9. data/generators/active_merchant/templates/.travis.yml.rb +19 -0
  10. data/generators/active_merchant/templates/Gemfile.rb +3 -0
  11. data/generators/active_merchant/templates/Jarfile.rb +6 -0
  12. data/generators/active_merchant/templates/LICENSE.rb +201 -0
  13. data/generators/active_merchant/templates/NEWS.rb +2 -0
  14. data/generators/active_merchant/templates/Rakefile.rb +30 -0
  15. data/generators/active_merchant/templates/VERSION.rb +1 -0
  16. data/generators/active_merchant/templates/config.ru.rb +4 -0
  17. data/generators/active_merchant/templates/config.yml.rb +13 -0
  18. data/generators/active_merchant/templates/db/ddl.sql.rb +64 -0
  19. data/generators/active_merchant/templates/db/schema.rb +64 -0
  20. data/generators/active_merchant/templates/killbill.properties.rb +3 -0
  21. data/generators/active_merchant/templates/lib/api.rb +119 -0
  22. data/generators/active_merchant/templates/lib/application.rb +84 -0
  23. data/generators/active_merchant/templates/lib/models/payment_method.rb +22 -0
  24. data/generators/active_merchant/templates/lib/models/response.rb +22 -0
  25. data/generators/active_merchant/templates/lib/models/transaction.rb +11 -0
  26. data/generators/active_merchant/templates/lib/plugin.rb +23 -0
  27. data/generators/active_merchant/templates/lib/private_api.rb +6 -0
  28. data/generators/active_merchant/templates/lib/views/form.erb +8 -0
  29. data/generators/active_merchant/templates/plugin.gemspec.rb +48 -0
  30. data/generators/active_merchant/templates/pom.xml.rb +44 -0
  31. data/generators/active_merchant/templates/release.sh.rb +41 -0
  32. data/generators/active_merchant/templates/spec/base_plugin_spec.rb +30 -0
  33. data/generators/active_merchant/templates/spec/integration_spec.rb +31 -0
  34. data/generators/active_merchant/templates/spec/spec_helper.rb +24 -0
  35. data/generators/killbill_generator.rb +38 -0
  36. data/killbill.gemspec +10 -2
  37. data/lib/killbill/gen/api/block.rb +82 -0
  38. data/lib/killbill/gen/api/direct_payment.rb +176 -0
  39. data/lib/killbill/gen/api/direct_payment_api.rb +329 -0
  40. data/lib/killbill/gen/api/direct_payment_transaction.rb +156 -0
  41. data/lib/killbill/gen/api/fixed.rb +63 -0
  42. data/lib/killbill/gen/api/invoice_item.rb +7 -1
  43. data/lib/killbill/gen/api/invoice_item_formatter.rb +7 -1
  44. data/lib/killbill/gen/api/invoice_user_api.rb +18 -136
  45. data/lib/killbill/gen/api/migration_plan.rb +6 -6
  46. data/lib/killbill/gen/api/payment_api.rb +216 -54
  47. data/lib/killbill/gen/api/payment_method_plugin.rb +3 -3
  48. data/lib/killbill/gen/api/plan.rb +6 -6
  49. data/lib/killbill/gen/api/plan_phase.rb +16 -23
  50. data/lib/killbill/gen/api/plugin_property.rb +71 -0
  51. data/lib/killbill/gen/api/recurring.rb +63 -0
  52. data/lib/killbill/gen/api/require_gen.rb +10 -1
  53. data/lib/killbill/gen/api/static_catalog.rb +8 -1
  54. data/lib/killbill/gen/api/tier.rb +77 -0
  55. data/lib/killbill/gen/api/tiered_block.rb +88 -0
  56. data/lib/killbill/gen/api/usage.rb +111 -0
  57. data/lib/killbill/gen/api/usage_user_api.rb +59 -3
  58. data/lib/killbill/gen/plugin-api/billing_address.rb +85 -0
  59. data/lib/killbill/gen/plugin-api/customer.rb +73 -0
  60. data/lib/killbill/gen/plugin-api/hosted_payment_page_descriptor_fields.rb +145 -0
  61. data/lib/killbill/gen/plugin-api/hosted_payment_page_form_descriptor.rb +80 -0
  62. data/lib/killbill/gen/plugin-api/hosted_payment_page_notification.rb +129 -0
  63. data/lib/killbill/gen/plugin-api/payment_info_plugin.rb +20 -1
  64. data/lib/killbill/gen/plugin-api/payment_plugin_api.rb +358 -39
  65. data/lib/killbill/gen/plugin-api/refund_info_plugin.rb +20 -1
  66. data/lib/killbill/gen/plugin-api/require_gen.rb +3 -0
  67. data/lib/killbill/helpers/active_merchant.rb +21 -0
  68. data/lib/killbill/helpers/active_merchant/active_record.rb +17 -0
  69. data/lib/killbill/helpers/active_merchant/active_record/models/helpers.rb +25 -0
  70. data/lib/killbill/helpers/active_merchant/active_record/models/payment_method.rb +195 -0
  71. data/lib/killbill/helpers/active_merchant/active_record/models/response.rb +178 -0
  72. data/lib/killbill/helpers/active_merchant/active_record/models/streamy_result_set.rb +35 -0
  73. data/lib/killbill/helpers/active_merchant/active_record/models/transaction.rb +63 -0
  74. data/lib/killbill/helpers/active_merchant/configuration.rb +54 -0
  75. data/lib/killbill/helpers/active_merchant/core_ext.rb +41 -0
  76. data/lib/killbill/helpers/active_merchant/gateway.rb +35 -0
  77. data/lib/killbill/helpers/active_merchant/killbill_spec_helper.rb +117 -0
  78. data/lib/killbill/helpers/active_merchant/payment_plugin.rb +365 -0
  79. data/lib/killbill/helpers/active_merchant/private_payment_plugin.rb +119 -0
  80. data/lib/killbill/helpers/active_merchant/properties.rb +20 -0
  81. data/lib/killbill/helpers/active_merchant/sinatra.rb +30 -0
  82. data/lib/killbill/helpers/active_merchant/utils.rb +23 -0
  83. data/lib/killbill/payment.rb +22 -10
  84. data/script/generate +15 -0
  85. data/spec/killbill/helpers/payment_method_spec.rb +101 -0
  86. data/spec/killbill/helpers/response_spec.rb +74 -0
  87. data/spec/killbill/helpers/test_schema.rb +57 -0
  88. data/spec/killbill/helpers/utils_spec.rb +22 -0
  89. data/spec/killbill/payment_plugin_api_spec.rb +23 -18
  90. data/spec/killbill/payment_plugin_spec.rb +11 -10
  91. data/spec/killbill/payment_test.rb +9 -9
  92. data/spec/spec_helper.rb +8 -3
  93. metadata +130 -5
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env rake
2
+
3
+ # Install tasks to build and release the plugin
4
+ require 'bundler/setup'
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ # Install test tasks
8
+ require 'rspec/core/rake_task'
9
+ namespace :test do
10
+ desc 'Run RSpec tests'
11
+ RSpec::Core::RakeTask.new do |task|
12
+ task.name = 'spec'
13
+ task.pattern = './spec/*/*_spec.rb'
14
+ end
15
+
16
+ namespace :remote do
17
+ desc 'Run RSpec remote tests'
18
+ RSpec::Core::RakeTask.new do |task|
19
+ task.name = 'spec'
20
+ task.pattern = './spec/*/remote/*_spec.rb'
21
+ end
22
+ end
23
+ end
24
+
25
+ # Install tasks to package the plugin for Killbill
26
+ require 'killbill/rake_task'
27
+ Killbill::PluginHelper.install_tasks
28
+
29
+ # Run tests by default
30
+ task :default => 'test:spec'
@@ -0,0 +1,4 @@
1
+ require '<%= identifier %>'
2
+ require '<%= identifier %>/application'
3
+
4
+ run Sinatra::Application
@@ -0,0 +1,13 @@
1
+ :<%= identifier %>:
2
+ :test: true
3
+ :log_file: /var/tmp/<%= identifier %>.log
4
+
5
+ :database:
6
+ :adapter: sqlite3
7
+ :database: test.db
8
+ # For MySQL
9
+ # :adapter: 'jdbc'
10
+ # :username: 'your-username'
11
+ # :password: 'your-password'
12
+ # :driver: 'com.mysql.jdbc.Driver'
13
+ # :url: 'jdbc:mysql://127.0.0.1:3306/your-database'
@@ -0,0 +1,64 @@
1
+ CREATE TABLE `<%= identifier %>_payment_methods` (
2
+ `id` int(11) NOT NULL AUTO_INCREMENT,
3
+ `kb_account_id` varchar(255) NOT NULL,
4
+ `kb_payment_method_id` varchar(255) DEFAULT NULL,
5
+ `token` varchar(255) DEFAULT NULL,
6
+ `cc_first_name` varchar(255) DEFAULT NULL,
7
+ `cc_last_name` varchar(255) DEFAULT NULL,
8
+ `cc_type` varchar(255) DEFAULT NULL,
9
+ `cc_exp_month` int(11) DEFAULT NULL,
10
+ `cc_exp_year` int(11) DEFAULT NULL,
11
+ `cc_number` int(11) DEFAULT NULL,
12
+ `cc_last_4` int(11) DEFAULT NULL,
13
+ `cc_start_month` varchar(255) DEFAULT NULL,
14
+ `cc_start_year` varchar(255) DEFAULT NULL,
15
+ `cc_issue_number` varchar(255) DEFAULT NULL,
16
+ `cc_verification_value` varchar(255) DEFAULT NULL,
17
+ `cc_track_data` varchar(255) DEFAULT NULL,
18
+ `address1` varchar(255) DEFAULT NULL,
19
+ `address2` varchar(255) DEFAULT NULL,
20
+ `city` varchar(255) DEFAULT NULL,
21
+ `state` varchar(255) DEFAULT NULL,
22
+ `zip` varchar(255) DEFAULT NULL,
23
+ `country` varchar(255) DEFAULT NULL,
24
+ `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
25
+ `created_at` datetime NOT NULL,
26
+ `updated_at` datetime NOT NULL,
27
+ PRIMARY KEY (`id`),
28
+ KEY `index_<%= identifier %>_payment_methods_on_kb_account_id` (`kb_account_id`),
29
+ KEY `index_<%= identifier %>_payment_methods_on_kb_payment_method_id` (`kb_payment_method_id`)
30
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
31
+
32
+ CREATE TABLE `<%= identifier %>_transactions` (
33
+ `id` int(11) NOT NULL AUTO_INCREMENT,
34
+ `<%= identifier %>_response_id` int(11) NOT NULL,
35
+ `api_call` varchar(255) NOT NULL,
36
+ `kb_payment_id` varchar(255) NOT NULL,
37
+ `txn_id` varchar(255) NOT NULL,
38
+ `amount_in_cents` int(11) NOT NULL,
39
+ `currency` varchar(255) NOT NULL,
40
+ `created_at` datetime NOT NULL,
41
+ `updated_at` datetime NOT NULL,
42
+ PRIMARY KEY (`id`),
43
+ KEY `index_<%= identifier %>_transactions_on_kb_payment_id` (`kb_payment_id`)
44
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
45
+
46
+ CREATE TABLE `<%= identifier %>_responses` (
47
+ `id` int(11) NOT NULL AUTO_INCREMENT,
48
+ `api_call` varchar(255) NOT NULL,
49
+ `kb_payment_id` varchar(255) DEFAULT NULL,
50
+ `message` varchar(255) DEFAULT NULL,
51
+ `authorization` varchar(255) DEFAULT NULL,
52
+ `fraud_review` tinyint(1) DEFAULT NULL,
53
+ `test` tinyint(1) DEFAULT NULL,
54
+ `avs_result_code` varchar(255) DEFAULT NULL,
55
+ `avs_result_message` varchar(255) DEFAULT NULL,
56
+ `avs_result_street_match` varchar(255) DEFAULT NULL,
57
+ `avs_result_postal_match` varchar(255) DEFAULT NULL,
58
+ `cvv_result_code` varchar(255) DEFAULT NULL,
59
+ `cvv_result_message` varchar(255) DEFAULT NULL,
60
+ `success` tinyint(1) DEFAULT NULL,
61
+ `created_at` datetime NOT NULL,
62
+ `updated_at` datetime NOT NULL,
63
+ PRIMARY KEY (`id`)
64
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
@@ -0,0 +1,64 @@
1
+ require 'active_record'
2
+
3
+ ActiveRecord::Schema.define(:version => 20140410153635) do
4
+ create_table "<%= identifier %>_payment_methods", :force => true do |t|
5
+ t.string "kb_account_id", :null => false
6
+ t.string "kb_payment_method_id" # NULL before Kill Bill knows about it
7
+ t.string "token" # <%= identifier %> id
8
+ t.string "cc_first_name"
9
+ t.string "cc_last_name"
10
+ t.string "cc_type"
11
+ t.integer "cc_exp_month"
12
+ t.integer "cc_exp_year"
13
+ t.integer "cc_number"
14
+ t.integer "cc_last_4"
15
+ t.integer "cc_start_month"
16
+ t.integer "cc_start_year"
17
+ t.integer "cc_issue_number"
18
+ t.integer "cc_verification_value"
19
+ t.integer "cc_track_data"
20
+ t.string "address1"
21
+ t.string "address2"
22
+ t.string "city"
23
+ t.string "state"
24
+ t.string "zip"
25
+ t.string "country"
26
+ t.boolean "is_deleted", :null => false, :default => false
27
+ t.datetime "created_at", :null => false
28
+ t.datetime "updated_at", :null => false
29
+ end
30
+
31
+ add_index(:<%= identifier %>_payment_methods, :kb_account_id)
32
+ add_index(:<%= identifier %>_payment_methods, :kb_payment_method_id)
33
+
34
+ create_table "<%= identifier %>_transactions", :force => true do |t|
35
+ t.integer "<%= identifier %>_response_id", :null => false
36
+ t.string "api_call", :null => false
37
+ t.string "kb_payment_id", :null => false
38
+ t.string "txn_id" # <%= identifier %> transaction id
39
+ t.integer "amount_in_cents", :null => false
40
+ t.string "currency", :null => false
41
+ t.datetime "created_at", :null => false
42
+ t.datetime "updated_at", :null => false
43
+ end
44
+
45
+ add_index(:<%= identifier %>_transactions, :kb_payment_id)
46
+
47
+ create_table "<%= identifier %>_responses", :force => true do |t|
48
+ t.string "api_call", :null => false
49
+ t.string "kb_payment_id"
50
+ t.string "message"
51
+ t.string "authorization"
52
+ t.boolean "fraud_review"
53
+ t.boolean "test"
54
+ t.string "avs_result_code"
55
+ t.string "avs_result_message"
56
+ t.string "avs_result_street_match"
57
+ t.string "avs_result_postal_match"
58
+ t.string "cvv_result_code"
59
+ t.string "cvv_result_message"
60
+ t.boolean "success"
61
+ t.datetime "created_at", :null => false
62
+ t.datetime "updated_at", :null => false
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ mainClass=Killbill::<%= class_name %>::PaymentPlugin
2
+ require=<%= identifier %>
3
+ pluginType=PAYMENT
@@ -0,0 +1,119 @@
1
+ module Killbill #:nodoc:
2
+ module <%= class_name %> #:nodoc:
3
+ class PaymentPlugin < ::Killbill::Plugin::ActiveMerchant::PaymentPlugin
4
+
5
+ def initialize
6
+ gateway_builder = Proc.new do |config|
7
+ # Change this if needed
8
+ ::ActiveMerchant::Billing::<%= class_name %>Gateway.new :login => config[:login]
9
+ end
10
+
11
+ super(gateway_builder,
12
+ :<%= identifier %>,
13
+ ::Killbill::<%= class_name %>::<%= class_name %>PaymentMethod,
14
+ ::Killbill::<%= class_name %>::<%= class_name %>Transaction,
15
+ ::Killbill::<%= class_name %>::<%= class_name %>Response)
16
+ end
17
+
18
+ def authorize_payment(kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency, properties, context)
19
+ # Pass extra parameters for the gateway here
20
+ options = {}
21
+
22
+ properties = merge_properties(properties, options)
23
+ super(kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency, context, properties)
24
+ end
25
+
26
+ def capture_payment(kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency, properties, context)
27
+ # Pass extra parameters for the gateway here
28
+ options = {}
29
+
30
+ properties = merge_properties(properties, options)
31
+ super(kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency, properties, context)
32
+ end
33
+
34
+ def void_payment(kb_account_id, kb_payment_id, kb_payment_method_id, properties, context)
35
+ # Pass extra parameters for the gateway here
36
+ options = {}
37
+
38
+ properties = merge_properties(properties, options)
39
+ super(kb_account_id, kb_payment_id, kb_payment_method_id, properties, context)
40
+ end
41
+
42
+ def process_payment(kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency, properties, context)
43
+ # Pass extra parameters for the gateway here
44
+ options = {}
45
+
46
+ properties = merge_properties(properties, options)
47
+ super(kb_account_id, kb_payment_id, kb_payment_method_id, amount, currency, properties, context)
48
+ end
49
+
50
+ def get_payment_info(kb_account_id, kb_payment_id, properties, context)
51
+ super
52
+ end
53
+
54
+ def search_payments(search_key, offset, limit, properties, context)
55
+ super
56
+ end
57
+
58
+ def process_refund(kb_account_id, kb_payment_id, refund_amount, currency, properties, context)
59
+ # Pass extra parameters for the gateway here
60
+ options = {}
61
+
62
+ properties = merge_properties(properties, options)
63
+ super(kb_account_id, kb_payment_id, refund_amount, currency, properties, context)
64
+ end
65
+
66
+ def get_refund_info(kb_account_id, kb_payment_id, properties, context)
67
+ super
68
+ end
69
+
70
+ def search_refunds(search_key, offset, limit, properties, context)
71
+ super
72
+ end
73
+
74
+ def add_payment_method(kb_account_id, kb_payment_method_id, payment_method_props, set_default, properties, context)
75
+ # Pass extra parameters for the gateway here
76
+ options = {}
77
+
78
+ properties = merge_properties(properties, options)
79
+ super(kb_account_id, kb_payment_method_id, payment_method_props, set_default, properties, context)
80
+ end
81
+
82
+ def delete_payment_method(kb_account_id, kb_payment_method_id, properties, context)
83
+ # Pass extra parameters for the gateway here
84
+ options = {}
85
+
86
+ properties = merge_properties(properties, options)
87
+ super(kb_account_id, kb_payment_method_id, properties, context)
88
+ end
89
+
90
+ def get_payment_method_detail(kb_account_id, kb_payment_method_id, properties, context)
91
+ super
92
+ end
93
+
94
+ def set_default_payment_method(kb_account_id, kb_payment_method_id, properties, context)
95
+ # TODO
96
+ end
97
+
98
+ def get_payment_methods(kb_account_id, refresh_from_gateway, properties, context)
99
+ super
100
+ end
101
+
102
+ def search_payment_methods(search_key, offset, limit, properties, context)
103
+ super
104
+ end
105
+
106
+ def reset_payment_methods(kb_account_id, payment_methods, properties)
107
+ super
108
+ end
109
+
110
+ def build_form_descriptor(kb_account_id, descriptor_fields, properties, context)
111
+ super
112
+ end
113
+
114
+ def process_notification(notification, properties, context)
115
+ super
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,84 @@
1
+ # -- encoding : utf-8 --
2
+
3
+ set :views, File.expand_path(File.dirname(__FILE__) + '/views')
4
+
5
+ include Killbill::Plugin::ActiveMerchant::Sinatra
6
+
7
+ configure do
8
+ # Usage: rackup -Ilib -E test
9
+ if development? or test?
10
+ # Make sure the plugin is initialized
11
+ plugin = ::Killbill::<%= class_name %>::PaymentPlugin.new
12
+ plugin.logger = Logger.new(STDOUT)
13
+ plugin.logger.level = Logger::INFO
14
+ plugin.conf_dir = File.dirname(File.dirname(__FILE__)) + '/..'
15
+ plugin.start_plugin
16
+ end
17
+ end
18
+
19
+ helpers do
20
+ def plugin(session = {})
21
+ ::Killbill::<%= class_name %>::PrivatePaymentPlugin.new(:<%= identifier %>,
22
+ ::Killbill::<%= class_name %>::<%= class_name %>PaymentMethod,
23
+ ::Killbill::<%= class_name %>::<%= class_name %>Transaction,
24
+ ::Killbill::<%= class_name %>::<%= class_name %>Response,
25
+ session)
26
+ end
27
+ end
28
+
29
+ # curl -v http://127.0.0.1:9292/plugins/killbill-<%= identifier %>/form
30
+ get '/plugins/killbill-<%= identifier %>/form', :provides => 'html' do
31
+ order_id = request.GET['order_id']
32
+ account_id = request.GET['account_id']
33
+ options = {
34
+ :amount => request.GET['amount'],
35
+ :currency => request.GET['currency'],
36
+ :test => request.GET['test'],
37
+ :credential2 => request.GET['credential2'],
38
+ :credential3 => request.GET['credential3'],
39
+ :credential4 => request.GET['credential4'],
40
+ :country => request.GET['country'],
41
+ :account_name => request.GET['account_name'],
42
+ :transaction_type => request.GET['transaction_type'],
43
+ :authcode => request.GET['authcode'],
44
+ :notify_url => request.GET['notify_url'],
45
+ :return_url => request.GET['return_url'],
46
+ :redirect_param => request.GET['redirect_param'],
47
+ :forward_url => request.GET['forward_url']
48
+ }
49
+
50
+ @form = plugin(session).payment_form_for(order_id, account_id, :<%= identifier %>, options) do |service|
51
+ # Add your custom hidden tags here, e.g.
52
+ #service.token = config[:<%= identifier %>][:token]
53
+ submit_tag 'Submit'
54
+ end
55
+
56
+ erb :form
57
+ end
58
+
59
+ # curl -v http://127.0.0.1:9292/plugins/killbill-<%= identifier %>/1.0/pms/1
60
+ get '/plugins/killbill-<%= identifier %>/1.0/pms/:id', :provides => 'json' do
61
+ if pm = ::Killbill::<%= class_name %>::<%= class_name %>PaymentMethod.find_by_id(params[:id].to_i)
62
+ pm.to_json
63
+ else
64
+ status 404
65
+ end
66
+ end
67
+
68
+ # curl -v http://127.0.0.1:9292/plugins/killbill-<%= identifier %>/1.0/transactions/1
69
+ get '/plugins/killbill-<%= identifier %>/1.0/transactions/:id', :provides => 'json' do
70
+ if transaction = ::Killbill::<%= class_name %>::<%= class_name %>Transaction.find_by_id(params[:id].to_i)
71
+ transaction.to_json
72
+ else
73
+ status 404
74
+ end
75
+ end
76
+
77
+ # curl -v http://127.0.0.1:9292/plugins/killbill-<%= identifier %>/1.0/responses/1
78
+ get '/plugins/killbill-<%= identifier %>/1.0/responses/:id', :provides => 'json' do
79
+ if transaction = ::Killbill::<%= class_name %>::<%= class_name %>Response.find_by_id(params[:id].to_i)
80
+ transaction.to_json
81
+ else
82
+ status 404
83
+ end
84
+ end
@@ -0,0 +1,22 @@
1
+ module Killbill #:nodoc:
2
+ module <%= class_name %> #:nodoc:
3
+ class <%= class_name %>PaymentMethod < ::Killbill::Plugin::ActiveMerchant::ActiveRecord::PaymentMethod
4
+
5
+ self.table_name = '<%= identifier %>_payment_methods'
6
+
7
+ def self.from_response(kb_account_id, kb_payment_method_id, cc_or_token, response, options, extra_params = {})
8
+ super(kb_account_id,
9
+ kb_payment_method_id,
10
+ cc_or_token,
11
+ response,
12
+ options,
13
+ {
14
+ # Pass custom key/values here
15
+ #:params_id => extract(response, 'id'),
16
+ #:params_card_id => extract(response, 'card', 'id')
17
+ }.merge!(extra_params),
18
+ ::Killbill::<%= class_name %>::<%= class_name %>PaymentMethod)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Killbill #:nodoc:
2
+ module <%= class_name %> #:nodoc:
3
+ class <%= class_name %>Response < ::Killbill::Plugin::ActiveMerchant::ActiveRecord::Response
4
+
5
+ self.table_name = '<%= identifier %>_responses'
6
+
7
+ has_one :<%= identifier %>_transaction
8
+
9
+ def self.from_response(api_call, kb_payment_id, response, extra_params = {})
10
+ super(api_call,
11
+ kb_payment_id,
12
+ response,
13
+ {
14
+ # Pass custom key/values here
15
+ #:params_id => extract(response, 'id'),
16
+ #:params_card_id => extract(response, 'card', 'id')
17
+ }.merge!(extra_params),
18
+ ::Killbill::<%= class_name %>::<%= class_name %>Response)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ module Killbill #:nodoc:
2
+ module <%= class_name %> #:nodoc:
3
+ class <%= class_name %>Transaction < ::Killbill::Plugin::ActiveMerchant::ActiveRecord::Transaction
4
+
5
+ self.table_name = '<%= identifier %>_transactions'
6
+
7
+ belongs_to :<%= identifier %>_response
8
+
9
+ end
10
+ end
11
+ end